blob: 616adde51aa06e465f126dd49b1efef51e3ea926 [file] [log] [blame]
Chris Craikb565df12015-10-05 13:00:52 -07001/*
2 * Copyright (C) 2015 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_BAKED_OP_RENDERER_H
18#define ANDROID_HWUI_BAKED_OP_RENDERER_H
19
20#include "BakedOpState.h"
21#include "Matrix.h"
22
23namespace android {
24namespace uirenderer {
25
26class Caches;
27struct Glop;
Chris Craik818c9fb2015-10-23 14:33:42 -070028class Layer;
Chris Craikb565df12015-10-05 13:00:52 -070029class RenderState;
30
31class BakedOpRenderer {
32public:
33 class Info {
34 public:
Chris Craik818c9fb2015-10-23 14:33:42 -070035 Info(Caches& caches, RenderState& renderState, bool opaque)
Chris Craikb565df12015-10-05 13:00:52 -070036 : renderState(renderState)
37 , caches(caches)
Chris Craik818c9fb2015-10-23 14:33:42 -070038 , opaque(opaque) {
Chris Craikb565df12015-10-05 13:00:52 -070039 }
40
Chris Craik818c9fb2015-10-23 14:33:42 -070041 void setViewport(uint32_t width, uint32_t height);
42
Chris Craikb565df12015-10-05 13:00:52 -070043 Texture* getTexture(const SkBitmap* bitmap);
44
45 void renderGlop(const BakedOpState& state, const Glop& glop);
46 RenderState& renderState;
47 Caches& caches;
48
49 bool didDraw = false;
Chris Craikb565df12015-10-05 13:00:52 -070050
Chris Craik818c9fb2015-10-23 14:33:42 -070051 Layer* layer = nullptr;
Chris Craikb565df12015-10-05 13:00:52 -070052
53 // where should these live? layer state object?
Chris Craik818c9fb2015-10-23 14:33:42 -070054 bool opaque;
55 uint32_t viewportWidth = 0;
56 uint32_t viewportHeight = 0;
Chris Craikb565df12015-10-05 13:00:52 -070057 Matrix4 orthoMatrix;
58 };
59
Chris Craik818c9fb2015-10-23 14:33:42 -070060 static Layer* startLayer(Info& info, uint32_t width, uint32_t height);
61 static void endLayer(Info& info);
62 static void startFrame(Info& info, uint32_t width, uint32_t height);
Chris Craikb565df12015-10-05 13:00:52 -070063 static void endFrame(Info& info);
64
65 /**
66 * Declare all "onBitmapOp(...)" style function for every op type.
67 *
68 * These functions will perform the actual rendering of the individual operations in OpenGL,
69 * given the transform/clip and other state built into the BakedOpState object passed in.
70 */
Chris Craik6fe991e52015-10-20 09:39:42 -070071 #define BAKED_OP_RENDERER_METHOD(Type) static void on##Type(Info& info, const Type& op, const BakedOpState& state);
Chris Craikb565df12015-10-05 13:00:52 -070072 MAP_OPS(BAKED_OP_RENDERER_METHOD);
73};
74
75}; // namespace uirenderer
76}; // namespace android
77
78#endif // ANDROID_HWUI_BAKED_OP_RENDERER_H