blob: 4d8620b8a4eaa60ab2a2fcb0d225c86b55e85162 [file] [log] [blame]
Romain Guy6c319ca2011-01-11 14:29:25 -08001/*
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 Guy79537452011-10-12 13:48:51 -070020#include <cutils/compiler.h>
21
Romain Guy6c319ca2011-01-11 14:29:25 -080022#include "OpenGLRenderer.h"
Romain Guyada830f2011-01-13 12:13:20 -080023#include "Layer.h"
Romain Guy6c319ca2011-01-11 14:29:25 -080024
Romain Guy77a81162011-06-14 16:45:55 -070025#include <SkBitmap.h>
26
Romain Guy6c319ca2011-01-11 14:29:25 -080027namespace android {
28namespace uirenderer {
29
John Reck3b202512014-06-23 13:13:08 -070030class RenderState;
31
Romain Guy6c319ca2011-01-11 14:29:25 -080032///////////////////////////////////////////////////////////////////////////////
Romain Guy1fc883b2011-01-12 14:30:59 -080033// Defines
34///////////////////////////////////////////////////////////////////////////////
35
36// Debug
37#if DEBUG_LAYER_RENDERER
Steve Block5baa3a62011-12-20 16:23:08 +000038 #define LAYER_RENDERER_LOGD(...) ALOGD(__VA_ARGS__)
Romain Guy1fc883b2011-01-12 14:30:59 -080039#else
40 #define LAYER_RENDERER_LOGD(...)
41#endif
42
43///////////////////////////////////////////////////////////////////////////////
Romain Guy6c319ca2011-01-11 14:29:25 -080044// Renderer
45///////////////////////////////////////////////////////////////////////////////
46
47class LayerRenderer: public OpenGLRenderer {
48public:
John Reck3b202512014-06-23 13:13:08 -070049 LayerRenderer(RenderState& renderState, Layer* layer);
Romain Guy79537452011-10-12 13:48:51 -070050 virtual ~LayerRenderer();
Romain Guy6c319ca2011-01-11 14:29:25 -080051
John Reck1aa5d2d2014-07-24 13:38:28 -070052 virtual void onViewportInitialized() { /* do nothing */ }
Romain Guy7c25aab2012-10-18 15:05:02 -070053 virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque);
54 virtual status_t clear(float left, float top, float right, float bottom, bool opaque);
Romain Guy79537452011-10-12 13:48:51 -070055 virtual void finish();
Romain Guy6c319ca2011-01-11 14:29:25 -080056
John Reck3b202512014-06-23 13:13:08 -070057 static Layer* createTextureLayer(RenderState& renderState);
58 static Layer* createRenderLayer(RenderState& renderState, uint32_t width, uint32_t height);
59 static bool resizeLayer(Layer* layer, uint32_t width, uint32_t height);
60 static void updateTextureLayer(Layer* layer, uint32_t width, uint32_t height,
Chris Craik9757ac02014-02-25 18:50:17 -080061 bool isOpaque, bool forceFilter, GLenum renderTarget, float* textureTransform);
John Reck3b202512014-06-23 13:13:08 -070062 static void destroyLayer(Layer* layer);
John Reck3b202512014-06-23 13:13:08 -070063 static bool copyLayer(RenderState& renderState, Layer* layer, SkBitmap* bitmap);
Romain Guy6c319ca2011-01-11 14:29:25 -080064
John Reck3b202512014-06-23 13:13:08 -070065 static void flushLayer(RenderState& renderState, Layer* layer);
Chet Haase98d3a642012-09-26 10:27:40 -070066
Romain Guy11cb6422012-09-21 00:39:43 -070067protected:
Romain Guy8ce00302013-01-15 18:51:42 -080068 virtual void ensureStencilBuffer();
Romain Guy624234f2013-03-05 16:43:31 -080069 virtual bool hasLayer() const;
70 virtual Region* getRegion() const;
Chris Craik14e51302013-12-30 15:32:54 -080071 virtual GLuint getTargetFbo() const;
Romain Guy624234f2013-03-05 16:43:31 -080072 virtual bool suppressErrorChecks() const;
Romain Guy11cb6422012-09-21 00:39:43 -070073
Romain Guy6c319ca2011-01-11 14:29:25 -080074private:
Romain Guyf219da52011-01-16 12:54:25 -080075 void generateMesh();
76
Romain Guyada830f2011-01-13 12:13:20 -080077 Layer* mLayer;
Romain Guy6c319ca2011-01-11 14:29:25 -080078}; // class LayerRenderer
79
80}; // namespace uirenderer
81}; // namespace android
82
83#endif // ANDROID_HWUI_LAYER_RENDERER_H