BakedOpRenderer.h revision 818c9fbf1d76d5df19253ba4eb964efa939ec9ec
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 23namespace android { 24namespace uirenderer { 25 26class Caches; 27struct Glop; 28class Layer; 29class RenderState; 30 31class BakedOpRenderer { 32public: 33 class Info { 34 public: 35 Info(Caches& caches, RenderState& renderState, bool opaque) 36 : renderState(renderState) 37 , caches(caches) 38 , opaque(opaque) { 39 } 40 41 void setViewport(uint32_t width, uint32_t height); 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 51 Layer* layer = nullptr; 52 53 // where should these live? layer state object? 54 bool opaque; 55 uint32_t viewportWidth = 0; 56 uint32_t viewportHeight = 0; 57 Matrix4 orthoMatrix; 58 }; 59 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); 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 */ 71 #define BAKED_OP_RENDERER_METHOD(Type) static void on##Type(Info& info, const Type& op, const BakedOpState& state); 72 MAP_OPS(BAKED_OP_RENDERER_METHOD); 73}; 74 75}; // namespace uirenderer 76}; // namespace android 77 78#endif // ANDROID_HWUI_BAKED_OP_RENDERER_H 79