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; |
| 28 | class RenderState; |
| 29 | |
| 30 | class BakedOpRenderer { |
| 31 | public: |
| 32 | class Info { |
| 33 | public: |
| 34 | Info(Caches& caches, RenderState& renderState, int viewportWidth, int viewportHeight, bool opaque) |
| 35 | : renderState(renderState) |
| 36 | , caches(caches) |
| 37 | , opaque(opaque) |
| 38 | , viewportWidth(viewportWidth) |
| 39 | , viewportHeight(viewportHeight) { |
| 40 | orthoMatrix.loadOrtho(viewportWidth, viewportHeight); |
| 41 | } |
| 42 | |
| 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; |
| 50 | bool opaque; |
| 51 | |
| 52 | |
| 53 | // where should these live? layer state object? |
| 54 | int viewportWidth; |
| 55 | int viewportHeight; |
| 56 | Matrix4 orthoMatrix; |
| 57 | }; |
| 58 | |
| 59 | static void startFrame(Info& info); |
| 60 | static void endFrame(Info& info); |
| 61 | |
| 62 | /** |
| 63 | * Declare all "onBitmapOp(...)" style function for every op type. |
| 64 | * |
| 65 | * These functions will perform the actual rendering of the individual operations in OpenGL, |
| 66 | * given the transform/clip and other state built into the BakedOpState object passed in. |
| 67 | */ |
Chris Craik | 6fe991e5 | 2015-10-20 09:39:42 -0700 | [diff] [blame] | 68 | #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] | 69 | MAP_OPS(BAKED_OP_RENDERER_METHOD); |
| 70 | }; |
| 71 | |
| 72 | }; // namespace uirenderer |
| 73 | }; // namespace android |
| 74 | |
| 75 | #endif // ANDROID_HWUI_BAKED_OP_RENDERER_H |