blob: ccfcf86931ad51bb0769ce3fee0409e94052f208 [file] [log] [blame]
Dharmaray Kundargi643290d2011-01-16 16:02:42 -08001/*
2 * Copyright (C) 2011 NXP Software
3 * Copyright (C) 2011 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef PREVIEW_RENDERER_H_
19
20#define PREVIEW_RENDERER_H_
21
22#include <media/stagefright/ColorConverter.h>
23#include <utils/RefBase.h>
24#include <ui/android_native_buffer.h>
25#include <ui/GraphicBufferMapper.h>
26#include "SoftwareRenderer.h"
27
Santosh Madhavabfece172011-02-03 16:59:47 -080028
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080029namespace android {
30
31class Surface;
32
33class PreviewRenderer {
34public:
Santosh Madhavabfece172011-02-03 16:59:47 -080035
36static PreviewRenderer* CreatePreviewRenderer (OMX_COLOR_FORMATTYPE colorFormat,
37 const sp<Surface> &surface,
38 size_t displayWidth, size_t displayHeight,
39 size_t decodedWidth, size_t decodedHeight,
40 int32_t rotationDegrees);
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080041
42 ~PreviewRenderer();
43
44 void render(
45 const void *data, size_t size, void *platformPrivate);
46
47 void getBufferYV12(uint8_t **data, size_t *stride);
48
49 void renderYV12();
50
51 static size_t ALIGN(size_t x, size_t alignment) {
52 return (x + alignment - 1) & ~(alignment - 1);
53 }
54
55private:
Santosh Madhavabfece172011-02-03 16:59:47 -080056 PreviewRenderer(
57 OMX_COLOR_FORMATTYPE colorFormat,
58 const sp<Surface> &surface,
59 size_t displayWidth, size_t displayHeight,
60 size_t decodedWidth, size_t decodedHeight,
61 int32_t rotationDegrees);
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080062 enum YUVMode {
63 None,
64 YUV420ToYUV420sp,
65 YUV420spToYUV420sp,
66 };
67
68 OMX_COLOR_FORMATTYPE mColorFormat;
69 ColorConverter *mConverter;
70 YUVMode mYUVMode;
71 sp<Surface> mSurface;
72 size_t mDisplayWidth, mDisplayHeight;
73 size_t mDecodedWidth, mDecodedHeight;
74
Iliyan Malchevb0038952011-05-01 11:38:07 -070075 ANativeWindowBuffer *mBuf;
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080076
77 PreviewRenderer(const PreviewRenderer &);
78 PreviewRenderer &operator=(const PreviewRenderer &);
79};
80
81} // namespace android
82
83#endif // PREVIEW_RENDERER_H_