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> 23 #include <ui/android_native_buffer.h> 24 #include <ui/GraphicBufferMapper.h> 25 #include "SoftwareRenderer.h" 26 27 28 namespace android { 29 30 class Surface; 31 32 class PreviewRenderer { 33 public: 34 35 static PreviewRenderer* CreatePreviewRenderer ( 36 const sp<Surface> &surface, 37 size_t width, size_t height); 38 39 ~PreviewRenderer(); 40 41 void getBufferYV12(uint8_t **data, size_t *stride); 42 43 void renderYV12(); 44 45 static size_t ALIGN(size_t x, size_t alignment) { 46 return (x + alignment - 1) & ~(alignment - 1); 47 } 48 49 private: 50 PreviewRenderer( 51 const sp<Surface> &surface, 52 size_t width, size_t height); 53 54 int init(); 55 56 sp<Surface> mSurface; 57 size_t mWidth, mHeight; 58 59 ANativeWindowBuffer *mBuf; 60 61 PreviewRenderer(const PreviewRenderer &); 62 PreviewRenderer &operator=(const PreviewRenderer &); 63 }; 64 65 } // namespace android 66 67 #endif // PREVIEW_RENDERER_H_ 68