blob: 38c3705cfa25aced3fde0a7ec78b167b646675d2 [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
Chris Craikd41c4d82015-01-05 15:51:13 -080052 virtual void onViewportInitialized() override { /* do nothing */ }
Chris Craik64e445b2015-09-02 14:23:49 -070053 virtual void prepareDirty(int viewportWidth, int viewportHeight,
54 float left, float top, float right, float bottom, bool opaque) override;
Chris Craikd41c4d82015-01-05 15:51:13 -080055 virtual void clear(float left, float top, float right, float bottom, bool opaque) override;
56 virtual bool finish() override;
Romain Guy6c319ca2011-01-11 14:29:25 -080057
John Reck3b202512014-06-23 13:13:08 -070058 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 Craikd2dfd8f2015-12-16 14:27:20 -080062 bool isOpaque, bool forceFilter, GLenum renderTarget, const float* textureTransform);
John Reck3b202512014-06-23 13:13:08 -070063 static void destroyLayer(Layer* layer);
John Reck3b202512014-06-23 13:13:08 -070064 static bool copyLayer(RenderState& renderState, Layer* layer, SkBitmap* bitmap);
Romain Guy6c319ca2011-01-11 14:29:25 -080065
John Reck3b202512014-06-23 13:13:08 -070066 static void flushLayer(RenderState& renderState, Layer* layer);
Chet Haase98d3a642012-09-26 10:27:40 -070067
Romain Guy11cb6422012-09-21 00:39:43 -070068protected:
Chris Craikd41c4d82015-01-05 15:51:13 -080069 virtual void ensureStencilBuffer() override;
70 virtual bool hasLayer() const override;
71 virtual Region* getRegion() const override;
Chris Craik6b109c72015-02-27 10:55:28 -080072 virtual GLuint getTargetFbo() const override;
Chris Craikd41c4d82015-01-05 15:51:13 -080073 virtual bool suppressErrorChecks() const override;
Romain Guy11cb6422012-09-21 00:39:43 -070074
Romain Guy6c319ca2011-01-11 14:29:25 -080075private:
Romain Guyf219da52011-01-16 12:54:25 -080076 void generateMesh();
77
Romain Guyada830f2011-01-13 12:13:20 -080078 Layer* mLayer;
Romain Guy6c319ca2011-01-11 14:29:25 -080079}; // class LayerRenderer
80
81}; // namespace uirenderer
82}; // namespace android
83
84#endif // ANDROID_HWUI_LAYER_RENDERER_H