Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 1 | /* |
| 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> |
Mathias Agopian | ff63ae3 | 2012-02-24 17:21:43 -0800 | [diff] [blame] | 23 | #include <system/window.h> |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 24 | #include <ui/GraphicBufferMapper.h> |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 25 | |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | class Surface; |
| 30 | |
| 31 | class PreviewRenderer { |
| 32 | public: |
| 33 | |
Chih-Chung Chang | 08b82bd | 2011-08-11 18:36:45 +0800 | [diff] [blame] | 34 | static PreviewRenderer* CreatePreviewRenderer ( |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 35 | const sp<Surface> &surface, |
Chih-Chung Chang | 08b82bd | 2011-08-11 18:36:45 +0800 | [diff] [blame] | 36 | size_t width, size_t height); |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 37 | |
| 38 | ~PreviewRenderer(); |
| 39 | |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 40 | void getBufferYV12(uint8_t **data, size_t *stride); |
| 41 | |
| 42 | void renderYV12(); |
| 43 | |
| 44 | static size_t ALIGN(size_t x, size_t alignment) { |
| 45 | return (x + alignment - 1) & ~(alignment - 1); |
| 46 | } |
| 47 | |
| 48 | private: |
| 49 | PreviewRenderer( |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 50 | const sp<Surface> &surface, |
Chih-Chung Chang | 08b82bd | 2011-08-11 18:36:45 +0800 | [diff] [blame] | 51 | size_t width, size_t height); |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 52 | |
Chih-Chung Chang | 08b82bd | 2011-08-11 18:36:45 +0800 | [diff] [blame] | 53 | int init(); |
| 54 | |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 55 | sp<Surface> mSurface; |
Chih-Chung Chang | 08b82bd | 2011-08-11 18:36:45 +0800 | [diff] [blame] | 56 | size_t mWidth, mHeight; |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 57 | |
| 58 | ANativeWindowBuffer *mBuf; |
| 59 | |
| 60 | PreviewRenderer(const PreviewRenderer &); |
| 61 | PreviewRenderer &operator=(const PreviewRenderer &); |
| 62 | }; |
| 63 | |
| 64 | } // namespace android |
| 65 | |
| 66 | #endif // PREVIEW_RENDERER_H_ |