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