GlopBuilder.h revision 0519c810a56bded1284fcb2ae40f438878c6585f
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#ifndef RENDERSTATE_GLOPBUILDER_H 17#define RENDERSTATE_GLOPBUILDER_H 18 19#include "OpenGLRenderer.h" 20#include "Program.h" 21#include "utils/Macros.h" 22 23class SkPaint; 24 25namespace android { 26namespace uirenderer { 27 28class Caches; 29struct Glop; 30class Matrix4; 31class RenderState; 32class Texture; 33class VertexBuffer; 34 35class GlopBuilder { 36 PREVENT_COPY_AND_ASSIGN(GlopBuilder); 37public: 38 GlopBuilder(RenderState& renderState, Caches& caches, Glop* outGlop); 39 40 GlopBuilder& setMeshUnitQuad(); 41 GlopBuilder& setMeshTexturedUnitQuad(const UvMapper* uvMapper, bool isAlphaMaskTexture); 42 GlopBuilder& setMeshVertexBuffer(const VertexBuffer& vertexBuffer, bool shadowInterp); 43 GlopBuilder& setMeshIndexedQuads(void* vertexData, int quadCount); 44 45 GlopBuilder& setFillPaint(const SkPaint& paint, float alphaScale); 46 GlopBuilder& setFillTexturePaint(Texture& texture, bool isAlphaMaskTexture, 47 const SkPaint* paint, float alphaScale); 48 49 GlopBuilder& setTransformClip(const Matrix4& ortho, const Matrix4& transform, bool fudgingOffset); 50 51 GlopBuilder& setModelViewMapUnitToRect(const Rect destination); 52 GlopBuilder& setModelViewMapUnitToRectSnap(const Rect destination); 53 GlopBuilder& setModelViewOffsetRect(float offsetX, float offsetY, const Rect source); 54 55 GlopBuilder& setRoundRectClipState(const RoundRectClipState* roundRectClipState); 56 57 void build(); 58private: 59 void setFill(int color, float alphaScale, SkXfermode::Mode mode, 60 const SkShader* shader, const SkColorFilter* colorFilter); 61 62 enum StageFlags { 63 kInitialStage = 0, 64 kMeshStage = 1 << 0, 65 kTransformStage = 1 << 1, 66 kModelViewStage = 1 << 2, 67 kFillStage = 1 << 3, 68 kRoundRectClipStage = 1 << 4, 69 kAllStages = kMeshStage | kFillStage | kTransformStage | kModelViewStage | kRoundRectClipStage, 70 } mStageFlags; 71 72 ProgramDescription mDescription; 73 RenderState& mRenderState; 74 Caches& mCaches; 75 Glop* mOutGlop; 76}; 77 78} /* namespace uirenderer */ 79} /* namespace android */ 80 81#endif // RENDERSTATE_GLOPBUILDER_H 82