Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 23 | namespace android { |
| 24 | namespace uirenderer { |
| 25 | |
| 26 | class Caches; |
| 27 | struct Glop; |
Chris Craik | 818c9fb | 2015-10-23 14:33:42 -0700 | [diff] [blame^] | 28 | class Layer; |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 29 | class RenderState; |
| 30 | |
| 31 | class BakedOpRenderer { |
| 32 | public: |
| 33 | class Info { |
| 34 | public: |
Chris Craik | 818c9fb | 2015-10-23 14:33:42 -0700 | [diff] [blame^] | 35 | Info(Caches& caches, RenderState& renderState, bool opaque) |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 36 | : renderState(renderState) |
| 37 | , caches(caches) |
Chris Craik | 818c9fb | 2015-10-23 14:33:42 -0700 | [diff] [blame^] | 38 | , opaque(opaque) { |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Chris Craik | 818c9fb | 2015-10-23 14:33:42 -0700 | [diff] [blame^] | 41 | void setViewport(uint32_t width, uint32_t height); |
| 42 | |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 43 | 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 Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 50 | |
Chris Craik | 818c9fb | 2015-10-23 14:33:42 -0700 | [diff] [blame^] | 51 | Layer* layer = nullptr; |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 52 | |
| 53 | // where should these live? layer state object? |
Chris Craik | 818c9fb | 2015-10-23 14:33:42 -0700 | [diff] [blame^] | 54 | bool opaque; |
| 55 | uint32_t viewportWidth = 0; |
| 56 | uint32_t viewportHeight = 0; |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 57 | Matrix4 orthoMatrix; |
| 58 | }; |
| 59 | |
Chris Craik | 818c9fb | 2015-10-23 14:33:42 -0700 | [diff] [blame^] | 60 | 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 Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 63 | 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 Craik | 6fe991e5 | 2015-10-20 09:39:42 -0700 | [diff] [blame] | 71 | #define BAKED_OP_RENDERER_METHOD(Type) static void on##Type(Info& info, const Type& op, const BakedOpState& state); |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 72 | MAP_OPS(BAKED_OP_RENDERER_METHOD); |
| 73 | }; |
| 74 | |
| 75 | }; // namespace uirenderer |
| 76 | }; // namespace android |
| 77 | |
| 78 | #endif // ANDROID_HWUI_BAKED_OP_RENDERER_H |