summaryrefslogtreecommitdiff
path: root/postprocessor/fbprocessor/CopyProcessor.cpp (plain)
blob: 93abb7d981e0ffd2b135c4c1a963b4dfc5d3f60d
1/*
2 * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
3 *
4 * This source code is subject to the terms and conditions defined in the
5 * file 'LICENSE' which is part of this source code package.
6 *
7 * Description:
8 */
9#include "CopyProcessor.h"
10#include <MesonLog.h>
11
12#include <ui/PixelFormat.h>
13
14CopyProcessor::CopyProcessor() {
15}
16
17CopyProcessor::~CopyProcessor() {
18}
19
20int32_t CopyProcessor::setup() {
21 return 0;
22}
23
24int32_t CopyProcessor::process(
25 std::shared_ptr<DrmFramebuffer> & inputfb,
26 std::shared_ptr<DrmFramebuffer> & outfb) {
27
28 void * inmem = NULL, * outmem = NULL;
29 int infmt = am_gralloc_get_format (inputfb->mBufferHandle);
30 int outfmt = am_gralloc_get_format (outfb->mBufferHandle);
31 int w = am_gralloc_get_width(inputfb->mBufferHandle);
32 int h = am_gralloc_get_height(inputfb->mBufferHandle);
33 int instride = am_gralloc_get_stride_in_pixel(inputfb->mBufferHandle);
34 int outstride = am_gralloc_get_stride_in_pixel(outfb->mBufferHandle);
35
36 MESON_LOGD("CopyProcessor %dx%d stride (%d,%d), fmt %d, %d",
37 w, h, instride, outstride, infmt, outfmt);
38
39 if (inputfb->lock(&inmem) == 0 && outfb->lock(&outmem) == 0) {
40 char * src = (char *)inmem;
41 char * dst = (char *)outmem;
42
43 if (infmt == outfmt) {
44 int32_t bytes = bytesPerPixel(infmt);
45 for (int ir = 0; ir < h; ir++) {
46 memcpy(dst, src, w * bytes);
47 src += instride * bytes;
48 dst += outstride * bytes;
49 }
50 }
51
52 inputfb->unlock();
53 outfb->unlock();
54 }
55
56 return 0;
57}
58
59int32_t CopyProcessor::teardown() {
60 return 0;
61}
62
63