blob: d724041c663577050bf1a36459e569930f0e7a24 [file] [log] [blame]
Chris Craik03188872015-02-02 18:39:33 -08001/*
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;
Chris Craik117bdbc2015-02-05 10:12:38 -080030class Matrix4;
Chris Craik03188872015-02-02 18:39:33 -080031class RenderState;
32class Texture;
Chris Craik117bdbc2015-02-05 10:12:38 -080033class VertexBuffer;
Chris Craik03188872015-02-02 18:39:33 -080034
35class GlopBuilder {
36 PREVENT_COPY_AND_ASSIGN(GlopBuilder);
37public:
38 GlopBuilder(RenderState& renderState, Caches& caches, Glop* outGlop);
Chris Craik2ab95d72015-02-06 15:25:51 -080039
Chris Craik03188872015-02-02 18:39:33 -080040 GlopBuilder& setMeshUnitQuad();
Chris Craik0519c8102015-02-11 13:17:06 -080041 GlopBuilder& setMeshTexturedUnitQuad(const UvMapper* uvMapper, bool isAlphaMaskTexture);
Chris Craik117bdbc2015-02-05 10:12:38 -080042 GlopBuilder& setMeshVertexBuffer(const VertexBuffer& vertexBuffer, bool shadowInterp);
Chris Craik2ab95d72015-02-06 15:25:51 -080043 GlopBuilder& setMeshIndexedQuads(void* vertexData, int quadCount);
Chris Craik117bdbc2015-02-05 10:12:38 -080044
Chris Craik0519c8102015-02-11 13:17:06 -080045 GlopBuilder& setFillPaint(const SkPaint& paint, float alphaScale);
46 GlopBuilder& setFillTexturePaint(Texture& texture, bool isAlphaMaskTexture,
47 const SkPaint* paint, float alphaScale);
Chris Craik30036092015-02-12 10:41:39 -080048 GlopBuilder& setFillPathTexturePaint(Texture& texture,
49 const SkPaint& paint, float alphaScale);
Chris Craik0519c8102015-02-11 13:17:06 -080050
51 GlopBuilder& setTransformClip(const Matrix4& ortho, const Matrix4& transform, bool fudgingOffset);
Chris Craik117bdbc2015-02-05 10:12:38 -080052
53 GlopBuilder& setModelViewMapUnitToRect(const Rect destination);
Chris Craik0519c8102015-02-11 13:17:06 -080054 GlopBuilder& setModelViewMapUnitToRectSnap(const Rect destination);
Chris Craik117bdbc2015-02-05 10:12:38 -080055 GlopBuilder& setModelViewOffsetRect(float offsetX, float offsetY, const Rect source);
56
Chris Craik0519c8102015-02-11 13:17:06 -080057 GlopBuilder& setRoundRectClipState(const RoundRectClipState* roundRectClipState);
58
Chris Craik03188872015-02-02 18:39:33 -080059 void build();
60private:
Chris Craik0519c8102015-02-11 13:17:06 -080061 void setFill(int color, float alphaScale, SkXfermode::Mode mode,
62 const SkShader* shader, const SkColorFilter* colorFilter);
63
Chris Craik117bdbc2015-02-05 10:12:38 -080064 enum StageFlags {
65 kInitialStage = 0,
66 kMeshStage = 1 << 0,
67 kTransformStage = 1 << 1,
68 kModelViewStage = 1 << 2,
69 kFillStage = 1 << 3,
Chris Craik0519c8102015-02-11 13:17:06 -080070 kRoundRectClipStage = 1 << 4,
71 kAllStages = kMeshStage | kFillStage | kTransformStage | kModelViewStage | kRoundRectClipStage,
Chris Craik117bdbc2015-02-05 10:12:38 -080072 } mStageFlags;
73
Chris Craik03188872015-02-02 18:39:33 -080074 ProgramDescription mDescription;
75 RenderState& mRenderState;
76 Caches& mCaches;
77 Glop* mOutGlop;
78};
79
80} /* namespace uirenderer */
81} /* namespace android */
82
83#endif // RENDERSTATE_GLOPBUILDER_H