Romain Guy | 6c319ca | 2011-01-11 14:29:25 -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 ANDROID_HWUI_LAYER_RENDERER_H |
| 18 | #define ANDROID_HWUI_LAYER_RENDERER_H |
| 19 | |
Romain Guy | 7953745 | 2011-10-12 13:48:51 -0700 | [diff] [blame] | 20 | #include <cutils/compiler.h> |
| 21 | |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 22 | #include "OpenGLRenderer.h" |
Romain Guy | ada830f | 2011-01-13 12:13:20 -0800 | [diff] [blame] | 23 | #include "Layer.h" |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 24 | |
Romain Guy | 77a8116 | 2011-06-14 16:45:55 -0700 | [diff] [blame] | 25 | #include <SkBitmap.h> |
| 26 | |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 27 | namespace android { |
| 28 | namespace uirenderer { |
| 29 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 30 | class RenderState; |
| 31 | |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 32 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | 1fc883b | 2011-01-12 14:30:59 -0800 | [diff] [blame] | 33 | // Defines |
| 34 | /////////////////////////////////////////////////////////////////////////////// |
| 35 | |
| 36 | // Debug |
| 37 | #if DEBUG_LAYER_RENDERER |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 38 | #define LAYER_RENDERER_LOGD(...) ALOGD(__VA_ARGS__) |
Romain Guy | 1fc883b | 2011-01-12 14:30:59 -0800 | [diff] [blame] | 39 | #else |
| 40 | #define LAYER_RENDERER_LOGD(...) |
| 41 | #endif |
| 42 | |
| 43 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 44 | // Renderer |
| 45 | /////////////////////////////////////////////////////////////////////////////// |
| 46 | |
| 47 | class LayerRenderer: public OpenGLRenderer { |
| 48 | public: |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 49 | LayerRenderer(RenderState& renderState, Layer* layer); |
Romain Guy | 7953745 | 2011-10-12 13:48:51 -0700 | [diff] [blame] | 50 | virtual ~LayerRenderer(); |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 51 | |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 52 | virtual void onViewportInitialized() override { /* do nothing */ } |
Chris Craik | 64e445b | 2015-09-02 14:23:49 -0700 | [diff] [blame] | 53 | virtual void prepareDirty(int viewportWidth, int viewportHeight, |
| 54 | float left, float top, float right, float bottom, bool opaque) override; |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 55 | virtual void clear(float left, float top, float right, float bottom, bool opaque) override; |
| 56 | virtual bool finish() override; |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 57 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 58 | static Layer* createTextureLayer(RenderState& renderState); |
| 59 | static Layer* createRenderLayer(RenderState& renderState, uint32_t width, uint32_t height); |
| 60 | static bool resizeLayer(Layer* layer, uint32_t width, uint32_t height); |
| 61 | static void updateTextureLayer(Layer* layer, uint32_t width, uint32_t height, |
Chris Craik | 9757ac0 | 2014-02-25 18:50:17 -0800 | [diff] [blame] | 62 | bool isOpaque, bool forceFilter, GLenum renderTarget, float* textureTransform); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 63 | static void destroyLayer(Layer* layer); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 64 | static bool copyLayer(RenderState& renderState, Layer* layer, SkBitmap* bitmap); |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 65 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 66 | static void flushLayer(RenderState& renderState, Layer* layer); |
Chet Haase | 98d3a64 | 2012-09-26 10:27:40 -0700 | [diff] [blame] | 67 | |
Romain Guy | 11cb642 | 2012-09-21 00:39:43 -0700 | [diff] [blame] | 68 | protected: |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 69 | virtual void ensureStencilBuffer() override; |
| 70 | virtual bool hasLayer() const override; |
| 71 | virtual Region* getRegion() const override; |
Chris Craik | 6b109c7 | 2015-02-27 10:55:28 -0800 | [diff] [blame] | 72 | virtual GLuint getTargetFbo() const override; |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 73 | virtual bool suppressErrorChecks() const override; |
Romain Guy | 11cb642 | 2012-09-21 00:39:43 -0700 | [diff] [blame] | 74 | |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 75 | private: |
Romain Guy | f219da5 | 2011-01-16 12:54:25 -0800 | [diff] [blame] | 76 | void generateMesh(); |
| 77 | |
Romain Guy | ada830f | 2011-01-13 12:13:20 -0800 | [diff] [blame] | 78 | Layer* mLayer; |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 79 | }; // class LayerRenderer |
| 80 | |
| 81 | }; // namespace uirenderer |
| 82 | }; // namespace android |
| 83 | |
| 84 | #endif // ANDROID_HWUI_LAYER_RENDERER_H |