blob: 8727a1d20dfd3c182d2095306d639133a08665de [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#include "GlopBuilder.h"
17
18#include "Caches.h"
Greg Daniel8cd3edf2017-01-09 14:15:41 -050019#include "GlLayer.h"
Chris Craik03188872015-02-02 18:39:33 -080020#include "Glop.h"
Chris Craik5e00c7c2016-07-06 16:10:09 -070021#include "Layer.h"
Chris Craik03188872015-02-02 18:39:33 -080022#include "Matrix.h"
Chris Craik0556d902015-03-03 09:54:14 -080023#include "Patch.h"
Chris Craik5e00c7c2016-07-06 16:10:09 -070024#include "PathCache.h"
Chris Craik03188872015-02-02 18:39:33 -080025#include "renderstate/MeshState.h"
26#include "renderstate/RenderState.h"
Chris Craik117bdbc2015-02-05 10:12:38 -080027#include "SkiaShader.h"
28#include "Texture.h"
Chris Craik03188872015-02-02 18:39:33 -080029#include "utils/PaintUtils.h"
Chris Craik117bdbc2015-02-05 10:12:38 -080030#include "VertexBuffer.h"
Chris Craik03188872015-02-02 18:39:33 -080031
32#include <GLES2/gl2.h>
33#include <SkPaint.h>
34
Chris Craikb1f990d2015-06-12 11:28:52 -070035#define DEBUG_GLOP_BUILDER 0
36
37#if DEBUG_GLOP_BUILDER
Chris Craik03188872015-02-02 18:39:33 -080038
Chris Craik117bdbc2015-02-05 10:12:38 -080039#define TRIGGER_STAGE(stageFlag) \
Chris Craik14100ac2015-02-24 13:46:29 -080040 LOG_ALWAYS_FATAL_IF((stageFlag) & mStageFlags, "Stage %d cannot be run twice", (stageFlag)); \
Chris Craik0519c812015-02-11 13:17:06 -080041 mStageFlags = static_cast<StageFlags>(mStageFlags | (stageFlag))
Chris Craik117bdbc2015-02-05 10:12:38 -080042
Chris Craik08fa43f2015-02-09 18:58:32 -080043#define REQUIRE_STAGES(requiredFlags) \
Chris Craik0519c812015-02-11 13:17:06 -080044 LOG_ALWAYS_FATAL_IF((mStageFlags & (requiredFlags)) != (requiredFlags), \
Chris Craik08fa43f2015-02-09 18:58:32 -080045 "not prepared for current stage")
46
Chris Craikb1f990d2015-06-12 11:28:52 -070047#else
48
49#define TRIGGER_STAGE(stageFlag) ((void)0)
50#define REQUIRE_STAGES(requiredFlags) ((void)0)
51
52#endif
53
54namespace android {
55namespace uirenderer {
56
Chris Craik922d3a72015-02-13 17:47:21 -080057static void setUnitQuadTextureCoords(Rect uvs, TextureVertex* quadVertex) {
Chris Craik14100ac2015-02-24 13:46:29 -080058 quadVertex[0] = {0, 0, uvs.left, uvs.top};
59 quadVertex[1] = {1, 0, uvs.right, uvs.top};
60 quadVertex[2] = {0, 1, uvs.left, uvs.bottom};
61 quadVertex[3] = {1, 1, uvs.right, uvs.bottom};
Chris Craik0519c812015-02-11 13:17:06 -080062}
63
Chris Craik03188872015-02-02 18:39:33 -080064GlopBuilder::GlopBuilder(RenderState& renderState, Caches& caches, Glop* outGlop)
65 : mRenderState(renderState)
66 , mCaches(caches)
Chris Craik922d3a72015-02-13 17:47:21 -080067 , mShader(nullptr)
Chris Craik0519c812015-02-11 13:17:06 -080068 , mOutGlop(outGlop) {
Chris Craik117bdbc2015-02-05 10:12:38 -080069 mStageFlags = kInitialStage;
70}
71
Chris Craik0519c812015-02-11 13:17:06 -080072////////////////////////////////////////////////////////////////////////////////
73// Mesh
74////////////////////////////////////////////////////////////////////////////////
75
Chris Craik8d2cf942015-11-02 14:52:21 -080076GlopBuilder& GlopBuilder::setMeshTexturedIndexedVbo(GLuint vbo, GLsizei elementCount) {
77 TRIGGER_STAGE(kMeshStage);
78
79 mOutGlop->mesh.primitiveMode = GL_TRIANGLES;
80 mOutGlop->mesh.indices = { mRenderState.meshState().getQuadListIBO(), nullptr };
81 mOutGlop->mesh.vertices = {
82 vbo,
83 VertexAttribFlags::TextureCoord,
Chris Craike5b50192016-01-04 15:09:19 -080084 nullptr, (const void*) kMeshTextureOffset, nullptr,
Chris Craik8d2cf942015-11-02 14:52:21 -080085 kTextureVertexStride };
86 mOutGlop->mesh.elementCount = elementCount;
87 return *this;
88}
89
Chris Craik0519c812015-02-11 13:17:06 -080090GlopBuilder& GlopBuilder::setMeshUnitQuad() {
91 TRIGGER_STAGE(kMeshStage);
92
Chris Craik0519c812015-02-11 13:17:06 -080093 mOutGlop->mesh.primitiveMode = GL_TRIANGLE_STRIP;
Chris Craikef250742015-02-25 17:16:16 -080094 mOutGlop->mesh.indices = { 0, nullptr };
95 mOutGlop->mesh.vertices = {
96 mRenderState.meshState().getUnitQuadVBO(),
Chris Craik53e51e42015-06-01 10:35:35 -070097 VertexAttribFlags::None,
Chris Craikef250742015-02-25 17:16:16 -080098 nullptr, nullptr, nullptr,
99 kTextureVertexStride };
Chris Craik0519c812015-02-11 13:17:06 -0800100 mOutGlop->mesh.elementCount = 4;
Chris Craik0519c812015-02-11 13:17:06 -0800101 return *this;
102}
103
Chris Craikf27133d2015-02-19 09:51:53 -0800104GlopBuilder& GlopBuilder::setMeshTexturedUnitQuad(const UvMapper* uvMapper) {
Chris Craik14100ac2015-02-24 13:46:29 -0800105 if (uvMapper) {
106 // can't use unit quad VBO, so build UV vertices manually
Chris Craik5430ab22015-12-10 16:28:16 -0800107 return setMeshTexturedUvQuad(uvMapper, Rect(1, 1));
Chris Craik14100ac2015-02-24 13:46:29 -0800108 }
109
110 TRIGGER_STAGE(kMeshStage);
111
Chris Craik14100ac2015-02-24 13:46:29 -0800112 mOutGlop->mesh.primitiveMode = GL_TRIANGLE_STRIP;
Chris Craikef250742015-02-25 17:16:16 -0800113 mOutGlop->mesh.indices = { 0, nullptr };
114 mOutGlop->mesh.vertices = {
115 mRenderState.meshState().getUnitQuadVBO(),
Chris Craik53e51e42015-06-01 10:35:35 -0700116 VertexAttribFlags::TextureCoord,
Chris Craikef250742015-02-25 17:16:16 -0800117 nullptr, (const void*) kMeshTextureOffset, nullptr,
118 kTextureVertexStride };
Chris Craik14100ac2015-02-24 13:46:29 -0800119 mOutGlop->mesh.elementCount = 4;
Chris Craik14100ac2015-02-24 13:46:29 -0800120 return *this;
121}
122
123GlopBuilder& GlopBuilder::setMeshTexturedUvQuad(const UvMapper* uvMapper, Rect uvs) {
Chris Craik0519c812015-02-11 13:17:06 -0800124 TRIGGER_STAGE(kMeshStage);
125
Chris Craik0519c812015-02-11 13:17:06 -0800126 if (CC_UNLIKELY(uvMapper)) {
Chris Craik0519c812015-02-11 13:17:06 -0800127 uvMapper->map(uvs);
Chris Craik0519c812015-02-11 13:17:06 -0800128 }
Chris Craik14100ac2015-02-24 13:46:29 -0800129 setUnitQuadTextureCoords(uvs, &mOutGlop->mesh.mappedVertices[0]);
130
Chris Craikef250742015-02-25 17:16:16 -0800131 const TextureVertex* textureVertex = mOutGlop->mesh.mappedVertices;
132 mOutGlop->mesh.primitiveMode = GL_TRIANGLE_STRIP;
133 mOutGlop->mesh.indices = { 0, nullptr };
134 mOutGlop->mesh.vertices = {
135 0,
Chris Craik53e51e42015-06-01 10:35:35 -0700136 VertexAttribFlags::TextureCoord,
Chris Craikef250742015-02-25 17:16:16 -0800137 &textureVertex[0].x, &textureVertex[0].u, nullptr,
138 kTextureVertexStride };
Chris Craik0519c812015-02-11 13:17:06 -0800139 mOutGlop->mesh.elementCount = 4;
Chris Craik0519c812015-02-11 13:17:06 -0800140 return *this;
141}
142
Chris Craikef250742015-02-25 17:16:16 -0800143GlopBuilder& GlopBuilder::setMeshIndexedQuads(Vertex* vertexData, int quadCount) {
Chris Craik0519c812015-02-11 13:17:06 -0800144 TRIGGER_STAGE(kMeshStage);
145
Chris Craik0519c812015-02-11 13:17:06 -0800146 mOutGlop->mesh.primitiveMode = GL_TRIANGLES;
Chris Craikef250742015-02-25 17:16:16 -0800147 mOutGlop->mesh.indices = { mRenderState.meshState().getQuadListIBO(), nullptr };
148 mOutGlop->mesh.vertices = {
149 0,
Chris Craik53e51e42015-06-01 10:35:35 -0700150 VertexAttribFlags::None,
Chris Craikef250742015-02-25 17:16:16 -0800151 vertexData, nullptr, nullptr,
152 kVertexStride };
Chris Craik0519c812015-02-11 13:17:06 -0800153 mOutGlop->mesh.elementCount = 6 * quadCount;
Chris Craik0519c812015-02-11 13:17:06 -0800154 return *this;
155}
156
Chris Craikf27133d2015-02-19 09:51:53 -0800157GlopBuilder& GlopBuilder::setMeshTexturedIndexedQuads(TextureVertex* vertexData, int elementCount) {
158 TRIGGER_STAGE(kMeshStage);
159
Chris Craikf27133d2015-02-19 09:51:53 -0800160 mOutGlop->mesh.primitiveMode = GL_TRIANGLES;
Chris Craikef250742015-02-25 17:16:16 -0800161 mOutGlop->mesh.indices = { mRenderState.meshState().getQuadListIBO(), nullptr };
162 mOutGlop->mesh.vertices = {
163 0,
Chris Craik53e51e42015-06-01 10:35:35 -0700164 VertexAttribFlags::TextureCoord,
Chris Craikef250742015-02-25 17:16:16 -0800165 &vertexData[0].x, &vertexData[0].u, nullptr,
166 kTextureVertexStride };
Chris Craikf27133d2015-02-19 09:51:53 -0800167 mOutGlop->mesh.elementCount = elementCount;
Chris Craikef250742015-02-25 17:16:16 -0800168 return *this;
169}
170
171GlopBuilder& GlopBuilder::setMeshColoredTexturedMesh(ColorTextureVertex* vertexData, int elementCount) {
172 TRIGGER_STAGE(kMeshStage);
173
174 mOutGlop->mesh.primitiveMode = GL_TRIANGLES;
175 mOutGlop->mesh.indices = { 0, nullptr };
176 mOutGlop->mesh.vertices = {
177 0,
Chris Craik53e51e42015-06-01 10:35:35 -0700178 VertexAttribFlags::TextureCoord | VertexAttribFlags::Color,
Chris Craikef250742015-02-25 17:16:16 -0800179 &vertexData[0].x, &vertexData[0].u, &vertexData[0].r,
180 kColorTextureVertexStride };
181 mOutGlop->mesh.elementCount = elementCount;
Chris Craikf27133d2015-02-19 09:51:53 -0800182 return *this;
183}
184
Chris Craik138c21f2016-04-28 16:59:42 -0700185GlopBuilder& GlopBuilder::setMeshVertexBuffer(const VertexBuffer& vertexBuffer) {
Chris Craik117bdbc2015-02-05 10:12:38 -0800186 TRIGGER_STAGE(kMeshStage);
187
188 const VertexBuffer::MeshFeatureFlags flags = vertexBuffer.getMeshFeatureFlags();
189
190 bool alphaVertex = flags & VertexBuffer::kAlpha;
191 bool indices = flags & VertexBuffer::kIndices;
Chris Craik117bdbc2015-02-05 10:12:38 -0800192
Chris Craikef250742015-02-25 17:16:16 -0800193 mOutGlop->mesh.primitiveMode = GL_TRIANGLE_STRIP;
194 mOutGlop->mesh.indices = { 0, vertexBuffer.getIndices() };
195 mOutGlop->mesh.vertices = {
196 0,
Chris Craik53e51e42015-06-01 10:35:35 -0700197 alphaVertex ? VertexAttribFlags::Alpha : VertexAttribFlags::None,
Chris Craikef250742015-02-25 17:16:16 -0800198 vertexBuffer.getBuffer(), nullptr, nullptr,
199 alphaVertex ? kAlphaVertexStride : kVertexStride };
200 mOutGlop->mesh.elementCount = indices
201 ? vertexBuffer.getIndexCount() : vertexBuffer.getVertexCount();
Arunb0a94772017-01-23 11:41:06 +0000202 mOutGlop->mesh.vertexCount = vertexBuffer.getVertexCount(); // used for glDrawRangeElements()
Chris Craik117bdbc2015-02-05 10:12:38 -0800203 return *this;
Chris Craik03188872015-02-02 18:39:33 -0800204}
205
Chris Craik0556d902015-03-03 09:54:14 -0800206GlopBuilder& GlopBuilder::setMeshPatchQuads(const Patch& patch) {
207 TRIGGER_STAGE(kMeshStage);
208
209 mOutGlop->mesh.primitiveMode = GL_TRIANGLES;
210 mOutGlop->mesh.indices = { mRenderState.meshState().getQuadListIBO(), nullptr };
211 mOutGlop->mesh.vertices = {
212 mCaches.patchCache.getMeshBuffer(),
Chris Craik53e51e42015-06-01 10:35:35 -0700213 VertexAttribFlags::TextureCoord,
Chris Craik8820fd12015-03-03 14:20:47 -0800214 (void*)patch.positionOffset, (void*)patch.textureOffset, nullptr,
Chris Craik0556d902015-03-03 09:54:14 -0800215 kTextureVertexStride };
216 mOutGlop->mesh.elementCount = patch.indexCount;
217 return *this;
218}
219
Chris Craik0519c812015-02-11 13:17:06 -0800220////////////////////////////////////////////////////////////////////////////////
221// Fill
222////////////////////////////////////////////////////////////////////////////////
Chris Craik117bdbc2015-02-05 10:12:38 -0800223
Chris Craik182952f2015-03-09 14:17:29 -0700224void GlopBuilder::setFill(int color, float alphaScale,
Mike Reed260ab722016-10-07 15:59:20 -0400225 SkBlendMode mode, Blend::ModeOrderSwap modeUsage,
Chris Craik0519c812015-02-11 13:17:06 -0800226 const SkShader* shader, const SkColorFilter* colorFilter) {
Mike Reed260ab722016-10-07 15:59:20 -0400227 if (mode != SkBlendMode::kClear) {
Chris Craik117bdbc2015-02-05 10:12:38 -0800228 if (!shader) {
Romain Guy253f2c22016-09-28 17:34:42 -0700229 FloatColor c;
230 c.set(color);
231 c.r *= alphaScale;
232 c.g *= alphaScale;
233 c.b *= alphaScale;
234 c.a *= alphaScale;
235 mOutGlop->fill.color = c;
Chris Craik117bdbc2015-02-05 10:12:38 -0800236 } else {
Romain Guy253f2c22016-09-28 17:34:42 -0700237 float alpha = (SkColorGetA(color) / 255.0f) * alphaScale;
Chris Craik0519c812015-02-11 13:17:06 -0800238 mOutGlop->fill.color = { 1, 1, 1, alpha };
Chris Craik03188872015-02-02 18:39:33 -0800239 }
Chris Craik03188872015-02-02 18:39:33 -0800240 } else {
Chris Craik0519c812015-02-11 13:17:06 -0800241 mOutGlop->fill.color = { 0, 0, 0, 1 };
Chris Craik03188872015-02-02 18:39:33 -0800242 }
Chris Craik03188872015-02-02 18:39:33 -0800243
Chris Craik117bdbc2015-02-05 10:12:38 -0800244 mOutGlop->blend = { GL_ZERO, GL_ZERO };
Chris Craik03188872015-02-02 18:39:33 -0800245 if (mOutGlop->fill.color.a < 1.0f
Chris Craik53e51e42015-06-01 10:35:35 -0700246 || (mOutGlop->mesh.vertices.attribFlags & VertexAttribFlags::Alpha)
Chris Craikf27133d2015-02-19 09:51:53 -0800247 || (mOutGlop->fill.texture.texture && mOutGlop->fill.texture.texture->blend)
Chris Craik0519c812015-02-11 13:17:06 -0800248 || mOutGlop->roundRectClipState
Chris Craik117bdbc2015-02-05 10:12:38 -0800249 || PaintUtils::isBlendedShader(shader)
Chris Craik03188872015-02-02 18:39:33 -0800250 || PaintUtils::isBlendedColorFilter(colorFilter)
Mike Reed260ab722016-10-07 15:59:20 -0400251 || mode != SkBlendMode::kSrcOver) {
252 if (CC_LIKELY(mode <= SkBlendMode::kScreen)) {
Chris Craik182952f2015-03-09 14:17:29 -0700253 Blend::getFactors(mode, modeUsage,
Chris Craik03188872015-02-02 18:39:33 -0800254 &mOutGlop->blend.src, &mOutGlop->blend.dst);
255 } else {
256 // These blend modes are not supported by OpenGL directly and have
257 // to be implemented using shaders. Since the shader will perform
258 // the blending, don't enable GL blending off here
259 // If the blend mode cannot be implemented using shaders, fall
260 // back to the default SrcOver blend mode instead
Chris Craik117bdbc2015-02-05 10:12:38 -0800261 if (CC_UNLIKELY(mCaches.extensions().hasFramebufferFetch())) {
Mike Reedc2f31df2016-10-28 17:21:45 -0400262 mDescription.framebufferMode = mode;
Chris Craik182952f2015-03-09 14:17:29 -0700263 mDescription.swapSrcDst = (modeUsage == Blend::ModeOrderSwap::Swap);
Chris Craik03188872015-02-02 18:39:33 -0800264 // blending in shader, don't enable
265 } else {
266 // unsupported
Mike Reed260ab722016-10-07 15:59:20 -0400267 Blend::getFactors(SkBlendMode::kSrcOver, modeUsage,
Chris Craik03188872015-02-02 18:39:33 -0800268 &mOutGlop->blend.src, &mOutGlop->blend.dst);
269 }
270 }
271 }
Chris Craik922d3a72015-02-13 17:47:21 -0800272 mShader = shader; // shader resolved in ::build()
Chris Craik03188872015-02-02 18:39:33 -0800273
Chris Craik117bdbc2015-02-05 10:12:38 -0800274 if (colorFilter) {
275 SkColor color;
Mike Reedc2f31df2016-10-28 17:21:45 -0400276 SkBlendMode bmode;
Chris Craik117bdbc2015-02-05 10:12:38 -0800277 SkScalar srcColorMatrix[20];
Mike Reedc2f31df2016-10-28 17:21:45 -0400278 if (colorFilter->asColorMode(&color, &bmode)) {
Chris Craikb9ce116d2015-08-20 15:14:06 -0700279 mOutGlop->fill.filterMode = mDescription.colorOp = ProgramDescription::ColorFilterMode::Blend;
Mike Reedc2f31df2016-10-28 17:21:45 -0400280 mDescription.colorMode = bmode;
Romain Guy253f2c22016-09-28 17:34:42 -0700281 mOutGlop->fill.filter.color.set(color);
Chris Craik117bdbc2015-02-05 10:12:38 -0800282 } else if (colorFilter->asColorMatrix(srcColorMatrix)) {
Chris Craikb9ce116d2015-08-20 15:14:06 -0700283 mOutGlop->fill.filterMode = mDescription.colorOp = ProgramDescription::ColorFilterMode::Matrix;
Chris Craik117bdbc2015-02-05 10:12:38 -0800284
285 float* colorMatrix = mOutGlop->fill.filter.matrix.matrix;
286 memcpy(colorMatrix, srcColorMatrix, 4 * sizeof(float));
287 memcpy(&colorMatrix[4], &srcColorMatrix[5], 4 * sizeof(float));
288 memcpy(&colorMatrix[8], &srcColorMatrix[10], 4 * sizeof(float));
289 memcpy(&colorMatrix[12], &srcColorMatrix[15], 4 * sizeof(float));
290
291 // Skia uses the range [0..255] for the addition vector, but we need
292 // the [0..1] range to apply the vector in GLSL
293 float* colorVector = mOutGlop->fill.filter.matrix.vector;
Romain Guy8762e332016-10-12 12:14:07 -0700294 colorVector[0] = EOCF(srcColorMatrix[4] / 255.0f);
295 colorVector[1] = EOCF(srcColorMatrix[9] / 255.0f);
296 colorVector[2] = EOCF(srcColorMatrix[14] / 255.0f);
297 colorVector[3] = srcColorMatrix[19] / 255.0f; // alpha is linear
Chris Craik2ab95d72015-02-06 15:25:51 -0800298 } else {
Derek Sollenbergerfb0c8fc2017-07-26 13:53:27 -0400299 ALOGE("unsupported ColorFilter type: %s", colorFilter->getTypeName());
Chris Craik2ab95d72015-02-06 15:25:51 -0800300 LOG_ALWAYS_FATAL("unsupported ColorFilter");
Chris Craik117bdbc2015-02-05 10:12:38 -0800301 }
302 } else {
Chris Craikb9ce116d2015-08-20 15:14:06 -0700303 mOutGlop->fill.filterMode = ProgramDescription::ColorFilterMode::None;
Chris Craik117bdbc2015-02-05 10:12:38 -0800304 }
Chris Craik0519c812015-02-11 13:17:06 -0800305}
Chris Craik117bdbc2015-02-05 10:12:38 -0800306
Chris Craik53e51e42015-06-01 10:35:35 -0700307GlopBuilder& GlopBuilder::setFillTexturePaint(Texture& texture,
308 const int textureFillFlags, const SkPaint* paint, float alphaScale) {
Chris Craik0519c812015-02-11 13:17:06 -0800309 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700310 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik0519c812015-02-11 13:17:06 -0800311
Chris Craik53e51e42015-06-01 10:35:35 -0700312 GLenum filter = (textureFillFlags & TextureFillFlags::ForceFilter)
Chris Craika6b52192015-02-27 17:43:02 -0800313 ? GL_LINEAR : PaintUtils::getFilter(paint);
sergeyv2a38c422016-10-25 15:21:50 -0700314 mOutGlop->fill.texture = { &texture, filter, GL_CLAMP_TO_EDGE, nullptr };
Chris Craik0519c812015-02-11 13:17:06 -0800315
316 if (paint) {
317 int color = paint->getColor();
318 SkShader* shader = paint->getShader();
319
Chris Craik53e51e42015-06-01 10:35:35 -0700320 if (!(textureFillFlags & TextureFillFlags::IsAlphaMaskTexture)) {
Chris Craik0519c812015-02-11 13:17:06 -0800321 // Texture defines color, so disable shaders, and reset all non-alpha color channels
322 color |= 0x00FFFFFF;
323 shader = nullptr;
324 }
Chris Craik182952f2015-03-09 14:17:29 -0700325 setFill(color, alphaScale,
Mike Reed260ab722016-10-07 15:59:20 -0400326 paint->getBlendMode(), Blend::ModeOrderSwap::NoSwap,
Chris Craik0519c812015-02-11 13:17:06 -0800327 shader, paint->getColorFilter());
328 } else {
329 mOutGlop->fill.color = { alphaScale, alphaScale, alphaScale, alphaScale };
330
Chris Craik0519c812015-02-11 13:17:06 -0800331 if (alphaScale < 1.0f
Chris Craik53e51e42015-06-01 10:35:35 -0700332 || (mOutGlop->mesh.vertices.attribFlags & VertexAttribFlags::Alpha)
Chris Craik0519c812015-02-11 13:17:06 -0800333 || texture.blend
334 || mOutGlop->roundRectClipState) {
Mike Reed260ab722016-10-07 15:59:20 -0400335 Blend::getFactors(SkBlendMode::kSrcOver, Blend::ModeOrderSwap::NoSwap,
Chris Craik0519c812015-02-11 13:17:06 -0800336 &mOutGlop->blend.src, &mOutGlop->blend.dst);
337 } else {
338 mOutGlop->blend = { GL_ZERO, GL_ZERO };
339 }
340 }
341
Chris Craik53e51e42015-06-01 10:35:35 -0700342 if (textureFillFlags & TextureFillFlags::IsAlphaMaskTexture) {
Chris Craik2bb8f562015-02-17 16:42:02 -0800343 mDescription.modulate = mOutGlop->fill.color.isNotBlack();
Chris Craika6b52192015-02-27 17:43:02 -0800344 mDescription.hasAlpha8Texture = true;
Chris Craik0519c812015-02-11 13:17:06 -0800345 } else {
346 mDescription.modulate = mOutGlop->fill.color.a < 1.0f;
347 }
Chris Craik03188872015-02-02 18:39:33 -0800348 return *this;
349}
350
Chris Craik138c21f2016-04-28 16:59:42 -0700351GlopBuilder& GlopBuilder::setFillPaint(const SkPaint& paint, float alphaScale, bool shadowInterp) {
Chris Craik0519c812015-02-11 13:17:06 -0800352 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700353 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik0519c812015-02-11 13:17:06 -0800354
Chris Craik138c21f2016-04-28 16:59:42 -0700355 if (CC_LIKELY(!shadowInterp)) {
356 mOutGlop->fill.texture = {
sergeyv2a38c422016-10-25 15:21:50 -0700357 nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
Chris Craik138c21f2016-04-28 16:59:42 -0700358 } else {
359 mOutGlop->fill.texture = {
sergeyv2a38c422016-10-25 15:21:50 -0700360 mCaches.textureState().getShadowLutTexture(),
Chris Craik138c21f2016-04-28 16:59:42 -0700361 GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
362 }
Chris Craik0519c812015-02-11 13:17:06 -0800363
Chris Craik182952f2015-03-09 14:17:29 -0700364 setFill(paint.getColor(), alphaScale,
Mike Reed260ab722016-10-07 15:59:20 -0400365 paint.getBlendMode(), Blend::ModeOrderSwap::NoSwap,
Chris Craik0519c812015-02-11 13:17:06 -0800366 paint.getShader(), paint.getColorFilter());
Chris Craik138c21f2016-04-28 16:59:42 -0700367 mDescription.useShadowAlphaInterp = shadowInterp;
Chris Craik0519c812015-02-11 13:17:06 -0800368 mDescription.modulate = mOutGlop->fill.color.a < 1.0f;
369 return *this;
370}
371
Chris Craik2bb8f562015-02-17 16:42:02 -0800372GlopBuilder& GlopBuilder::setFillPathTexturePaint(PathTexture& texture,
Chris Craik30036092015-02-12 10:41:39 -0800373 const SkPaint& paint, float alphaScale) {
374 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700375 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik30036092015-02-12 10:41:39 -0800376
Chris Craikf27133d2015-02-19 09:51:53 -0800377 //specify invalid filter/clamp, since these are always static for PathTextures
sergeyv2a38c422016-10-25 15:21:50 -0700378 mOutGlop->fill.texture = { &texture, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
Chris Craik30036092015-02-12 10:41:39 -0800379
Chris Craik182952f2015-03-09 14:17:29 -0700380 setFill(paint.getColor(), alphaScale,
Mike Reed260ab722016-10-07 15:59:20 -0400381 paint.getBlendMode(), Blend::ModeOrderSwap::NoSwap,
Chris Craik30036092015-02-12 10:41:39 -0800382 paint.getShader(), paint.getColorFilter());
383
Chris Craikf27133d2015-02-19 09:51:53 -0800384 mDescription.hasAlpha8Texture = true;
Chris Craik2bb8f562015-02-17 16:42:02 -0800385 mDescription.modulate = mOutGlop->fill.color.isNotBlack();
Chris Craik30036092015-02-12 10:41:39 -0800386 return *this;
387}
388
Chris Craik2bb8f562015-02-17 16:42:02 -0800389GlopBuilder& GlopBuilder::setFillShadowTexturePaint(ShadowTexture& texture, int shadowColor,
390 const SkPaint& paint, float alphaScale) {
391 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700392 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik2bb8f562015-02-17 16:42:02 -0800393
Chris Craikf27133d2015-02-19 09:51:53 -0800394 //specify invalid filter/clamp, since these are always static for ShadowTextures
sergeyv2a38c422016-10-25 15:21:50 -0700395 mOutGlop->fill.texture = { &texture, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
Chris Craik2bb8f562015-02-17 16:42:02 -0800396
397 const int ALPHA_BITMASK = SK_ColorBLACK;
398 const int COLOR_BITMASK = ~ALPHA_BITMASK;
399 if ((shadowColor & ALPHA_BITMASK) == ALPHA_BITMASK) {
400 // shadow color is fully opaque: override its alpha with that of paint
401 shadowColor &= paint.getColor() | COLOR_BITMASK;
402 }
403
Chris Craik182952f2015-03-09 14:17:29 -0700404 setFill(shadowColor, alphaScale,
Mike Reed260ab722016-10-07 15:59:20 -0400405 paint.getBlendMode(), Blend::ModeOrderSwap::NoSwap,
Chris Craik2bb8f562015-02-17 16:42:02 -0800406 paint.getShader(), paint.getColorFilter());
407
Chris Craikf27133d2015-02-19 09:51:53 -0800408 mDescription.hasAlpha8Texture = true;
Chris Craik2bb8f562015-02-17 16:42:02 -0800409 mDescription.modulate = mOutGlop->fill.color.isNotBlack();
410 return *this;
411}
412
413GlopBuilder& GlopBuilder::setFillBlack() {
414 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700415 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik2bb8f562015-02-17 16:42:02 -0800416
sergeyv2a38c422016-10-25 15:21:50 -0700417 mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
Mike Reed260ab722016-10-07 15:59:20 -0400418 setFill(SK_ColorBLACK, 1.0f, SkBlendMode::kSrcOver, Blend::ModeOrderSwap::NoSwap,
Chris Craik182952f2015-03-09 14:17:29 -0700419 nullptr, nullptr);
Chris Craik2bb8f562015-02-17 16:42:02 -0800420 return *this;
421}
422
423GlopBuilder& GlopBuilder::setFillClear() {
424 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700425 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik2bb8f562015-02-17 16:42:02 -0800426
sergeyv2a38c422016-10-25 15:21:50 -0700427 mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
Mike Reed260ab722016-10-07 15:59:20 -0400428 setFill(SK_ColorBLACK, 1.0f, SkBlendMode::kClear, Blend::ModeOrderSwap::NoSwap,
Chris Craik182952f2015-03-09 14:17:29 -0700429 nullptr, nullptr);
Chris Craik2bb8f562015-02-17 16:42:02 -0800430 return *this;
431}
Chris Craikf27133d2015-02-19 09:51:53 -0800432
433GlopBuilder& GlopBuilder::setFillLayer(Texture& texture, const SkColorFilter* colorFilter,
Mike Reed260ab722016-10-07 15:59:20 -0400434 float alpha, SkBlendMode mode, Blend::ModeOrderSwap modeUsage) {
Chris Craikf27133d2015-02-19 09:51:53 -0800435 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700436 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craikf27133d2015-02-19 09:51:53 -0800437
sergeyv2a38c422016-10-25 15:21:50 -0700438 mOutGlop->fill.texture = { &texture, GL_LINEAR, GL_CLAMP_TO_EDGE, nullptr };
Chris Craikf27133d2015-02-19 09:51:53 -0800439
Chris Craik182952f2015-03-09 14:17:29 -0700440 setFill(SK_ColorWHITE, alpha, mode, modeUsage, nullptr, colorFilter);
Chris Craikf27133d2015-02-19 09:51:53 -0800441
442 mDescription.modulate = mOutGlop->fill.color.a < 1.0f;
443 return *this;
444}
445
Greg Daniel8cd3edf2017-01-09 14:15:41 -0500446GlopBuilder& GlopBuilder::setFillTextureLayer(GlLayer& layer, float alpha) {
Chris Craik26bf3422015-02-26 16:28:17 -0800447 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700448 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik26bf3422015-02-26 16:28:17 -0800449
450 mOutGlop->fill.texture = { &(layer.getTexture()),
sergeyv2a38c422016-10-25 15:21:50 -0700451 GL_LINEAR, GL_CLAMP_TO_EDGE, &layer.getTexTransform() };
Chris Craik26bf3422015-02-26 16:28:17 -0800452
Chris Craik182952f2015-03-09 14:17:29 -0700453 setFill(SK_ColorWHITE, alpha, layer.getMode(), Blend::ModeOrderSwap::NoSwap,
454 nullptr, layer.getColorFilter());
Chris Craik26bf3422015-02-26 16:28:17 -0800455
456 mDescription.modulate = mOutGlop->fill.color.a < 1.0f;
457 mDescription.hasTextureTransform = true;
458 return *this;
459}
460
John Reck7bf96a02017-06-28 11:08:07 -0700461GlopBuilder& GlopBuilder::setFillExternalTexture(Texture& texture, Matrix4& textureTransform,
462 bool requiresFilter) {
John Reck2f783272016-04-19 07:51:13 -0700463 TRIGGER_STAGE(kFillStage);
464 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
465
John Reck7bf96a02017-06-28 11:08:07 -0700466 GLenum filter = requiresFilter ? GL_LINEAR : GL_NEAREST;
467 mOutGlop->fill.texture = { &texture, filter, GL_CLAMP_TO_EDGE, &textureTransform };
John Reck2f783272016-04-19 07:51:13 -0700468
Mike Reed260ab722016-10-07 15:59:20 -0400469 setFill(SK_ColorWHITE, 1.0f, SkBlendMode::kSrc, Blend::ModeOrderSwap::NoSwap,
John Reck2f783272016-04-19 07:51:13 -0700470 nullptr, nullptr);
471
472 mDescription.modulate = mOutGlop->fill.color.a < 1.0f;
John Reck2f69d6d2016-04-28 13:18:51 -0700473 mDescription.hasTextureTransform = true;
John Reck2f783272016-04-19 07:51:13 -0700474 return *this;
475}
476
Romain Guy253f2c22016-09-28 17:34:42 -0700477GlopBuilder& GlopBuilder::setGammaCorrection(bool enabled) {
478 REQUIRE_STAGES(kFillStage);
479
480 mDescription.hasGammaCorrection = enabled;
481 return *this;
482}
483
Chris Craik0519c812015-02-11 13:17:06 -0800484////////////////////////////////////////////////////////////////////////////////
485// Transform
486////////////////////////////////////////////////////////////////////////////////
487
Chris Craikb565df12015-10-05 13:00:52 -0700488GlopBuilder& GlopBuilder::setTransform(const Matrix4& canvas, const int transformFlags) {
Chris Craik0519c812015-02-11 13:17:06 -0800489 TRIGGER_STAGE(kTransformStage);
490
Chris Craik7c85c542015-08-19 15:10:24 -0700491 mOutGlop->transform.canvas = canvas;
Chris Craik53e51e42015-06-01 10:35:35 -0700492 mOutGlop->transform.transformFlags = transformFlags;
Chris Craikb565df12015-10-05 13:00:52 -0700493 return *this;
Chris Craik0519c812015-02-11 13:17:06 -0800494}
495
Chris Craik0519c812015-02-11 13:17:06 -0800496////////////////////////////////////////////////////////////////////////////////
497// ModelView
498////////////////////////////////////////////////////////////////////////////////
499
500GlopBuilder& GlopBuilder::setModelViewMapUnitToRect(const Rect destination) {
501 TRIGGER_STAGE(kModelViewStage);
502
503 mOutGlop->transform.modelView.loadTranslate(destination.left, destination.top, 0.0f);
504 mOutGlop->transform.modelView.scale(destination.getWidth(), destination.getHeight(), 1.0f);
Chris Craik0519c812015-02-11 13:17:06 -0800505 return *this;
506}
507
508GlopBuilder& GlopBuilder::setModelViewMapUnitToRectSnap(const Rect destination) {
509 TRIGGER_STAGE(kModelViewStage);
510 REQUIRE_STAGES(kTransformStage | kFillStage);
511
512 float left = destination.left;
513 float top = destination.top;
514
Chris Craik53e51e42015-06-01 10:35:35 -0700515 const Matrix4& meshTransform = mOutGlop->transform.meshTransform();
516 if (CC_LIKELY(meshTransform.isPureTranslate())) {
Chris Craikf27133d2015-02-19 09:51:53 -0800517 // snap by adjusting the model view matrix
Chris Craik53e51e42015-06-01 10:35:35 -0700518 const float translateX = meshTransform.getTranslateX();
519 const float translateY = meshTransform.getTranslateY();
Chris Craik0519c812015-02-11 13:17:06 -0800520
521 left = (int) floorf(left + translateX + 0.5f) - translateX;
522 top = (int) floorf(top + translateY + 0.5f) - translateY;
Chris Craikf27133d2015-02-19 09:51:53 -0800523 mOutGlop->fill.texture.filter = GL_NEAREST;
Chris Craik0519c812015-02-11 13:17:06 -0800524 }
525
526 mOutGlop->transform.modelView.loadTranslate(left, top, 0.0f);
527 mOutGlop->transform.modelView.scale(destination.getWidth(), destination.getHeight(), 1.0f);
Chris Craik0519c812015-02-11 13:17:06 -0800528 return *this;
529}
530
531GlopBuilder& GlopBuilder::setModelViewOffsetRect(float offsetX, float offsetY, const Rect source) {
532 TRIGGER_STAGE(kModelViewStage);
533
534 mOutGlop->transform.modelView.loadTranslate(offsetX, offsetY, 0.0f);
Chris Craik0519c812015-02-11 13:17:06 -0800535 return *this;
536}
537
Chris Craikf27133d2015-02-19 09:51:53 -0800538GlopBuilder& GlopBuilder::setModelViewOffsetRectSnap(float offsetX, float offsetY, const Rect source) {
539 TRIGGER_STAGE(kModelViewStage);
540 REQUIRE_STAGES(kTransformStage | kFillStage);
541
Chris Craik53e51e42015-06-01 10:35:35 -0700542 const Matrix4& meshTransform = mOutGlop->transform.meshTransform();
543 if (CC_LIKELY(meshTransform.isPureTranslate())) {
Chris Craikf27133d2015-02-19 09:51:53 -0800544 // snap by adjusting the model view matrix
Chris Craik53e51e42015-06-01 10:35:35 -0700545 const float translateX = meshTransform.getTranslateX();
546 const float translateY = meshTransform.getTranslateY();
Chris Craikf27133d2015-02-19 09:51:53 -0800547
548 offsetX = (int) floorf(offsetX + translateX + source.left + 0.5f) - translateX - source.left;
549 offsetY = (int) floorf(offsetY + translateY + source.top + 0.5f) - translateY - source.top;
550 mOutGlop->fill.texture.filter = GL_NEAREST;
551 }
552
553 mOutGlop->transform.modelView.loadTranslate(offsetX, offsetY, 0.0f);
Chris Craikf27133d2015-02-19 09:51:53 -0800554 return *this;
555}
556
557////////////////////////////////////////////////////////////////////////////////
558// RoundRectClip
559////////////////////////////////////////////////////////////////////////////////
560
Chris Craik0519c812015-02-11 13:17:06 -0800561GlopBuilder& GlopBuilder::setRoundRectClipState(const RoundRectClipState* roundRectClipState) {
562 TRIGGER_STAGE(kRoundRectClipStage);
563
564 mOutGlop->roundRectClipState = roundRectClipState;
565 mDescription.hasRoundRectClip = roundRectClipState != nullptr;
566 return *this;
567}
568
569////////////////////////////////////////////////////////////////////////////////
570// Build
571////////////////////////////////////////////////////////////////////////////////
572
Chris Craikf27133d2015-02-19 09:51:53 -0800573void verify(const ProgramDescription& description, const Glop& glop) {
Chris Craikeb911c22015-03-06 17:30:11 -0800574 if (glop.fill.texture.texture != nullptr) {
575 LOG_ALWAYS_FATAL_IF(((description.hasTexture && description.hasExternalTexture)
Chris Craik138c21f2016-04-28 16:59:42 -0700576 || (!description.hasTexture
577 && !description.hasExternalTexture
578 && !description.useShadowAlphaInterp)
579 || ((glop.mesh.vertices.attribFlags & VertexAttribFlags::TextureCoord) == 0
580 && !description.useShadowAlphaInterp)),
Chris Craikeb911c22015-03-06 17:30:11 -0800581 "Texture %p, hT%d, hET %d, attribFlags %x",
582 glop.fill.texture.texture,
583 description.hasTexture, description.hasExternalTexture,
584 glop.mesh.vertices.attribFlags);
585 } else {
586 LOG_ALWAYS_FATAL_IF((description.hasTexture
587 || description.hasExternalTexture
Chris Craik53e51e42015-06-01 10:35:35 -0700588 || ((glop.mesh.vertices.attribFlags & VertexAttribFlags::TextureCoord) != 0)),
Chris Craikeb911c22015-03-06 17:30:11 -0800589 "No texture, hT%d, hET %d, attribFlags %x",
590 description.hasTexture, description.hasExternalTexture,
591 glop.mesh.vertices.attribFlags);
592 }
Chris Craikef250742015-02-25 17:16:16 -0800593
Chris Craik53e51e42015-06-01 10:35:35 -0700594 if ((glop.mesh.vertices.attribFlags & VertexAttribFlags::Alpha)
Chris Craikeb911c22015-03-06 17:30:11 -0800595 && glop.mesh.vertices.bufferObject) {
Chris Craikef250742015-02-25 17:16:16 -0800596 LOG_ALWAYS_FATAL("VBO and alpha attributes are not currently compatible");
597 }
Chris Craik26bf3422015-02-26 16:28:17 -0800598
599 if (description.hasTextureTransform != (glop.fill.texture.textureTransform != nullptr)) {
600 LOG_ALWAYS_FATAL("Texture transform incorrectly specified");
601 }
Chris Craikf27133d2015-02-19 09:51:53 -0800602}
603
Chris Craik03188872015-02-02 18:39:33 -0800604void GlopBuilder::build() {
Chris Craik08fa43f2015-02-09 18:58:32 -0800605 REQUIRE_STAGES(kAllStages);
Chris Craik53e51e42015-06-01 10:35:35 -0700606 if (mOutGlop->mesh.vertices.attribFlags & VertexAttribFlags::TextureCoord) {
Romain Guy55455182017-04-15 21:41:22 -0700607 Texture* texture = mOutGlop->fill.texture.texture;
608 if (texture->target() == GL_TEXTURE_2D) {
Chris Craik48f650c2015-03-10 11:03:39 -0700609 mDescription.hasTexture = true;
610 } else {
611 mDescription.hasExternalTexture = true;
612 }
Romain Guycaaaa662017-03-27 00:40:21 -0700613 mDescription.hasLinearTexture = texture->isLinear();
614 mDescription.hasColorSpaceConversion = texture->hasColorSpaceConversion();
615 mDescription.transferFunction = texture->getTransferFunctionType();
616 mDescription.hasTranslucentConversion = texture->blend;
Chris Craik26bf3422015-02-26 16:28:17 -0800617 }
Chris Craik53e51e42015-06-01 10:35:35 -0700618
619 mDescription.hasColors = mOutGlop->mesh.vertices.attribFlags & VertexAttribFlags::Color;
620 mDescription.hasVertexAlpha = mOutGlop->mesh.vertices.attribFlags & VertexAttribFlags::Alpha;
Chris Craikef250742015-02-25 17:16:16 -0800621
Chris Craik82840732015-04-03 09:37:49 -0700622 // Enable debug highlight when what we're about to draw is tested against
623 // the stencil buffer and if stencil highlight debugging is on
Chris Craik2507c342015-05-04 14:36:49 -0700624 mDescription.hasDebugHighlight = !Properties::debugOverdraw
625 && Properties::debugStencilClip == StencilClipDebug::ShowHighlight
Chris Craik82840732015-04-03 09:37:49 -0700626 && mRenderState.stencil().isTestEnabled();
627
Chris Craik922d3a72015-02-13 17:47:21 -0800628 // serialize shader info into ShaderData
Chris Craikf27133d2015-02-19 09:51:53 -0800629 GLuint textureUnit = mOutGlop->fill.texture.texture ? 1 : 0;
Chris Craik53e51e42015-06-01 10:35:35 -0700630
631 if (CC_LIKELY(!mShader)) {
632 mOutGlop->fill.skiaShaderData.skiaShaderType = kNone_SkiaShaderType;
633 } else {
634 Matrix4 shaderMatrix;
635 if (mOutGlop->transform.transformFlags & TransformFlags::MeshIgnoresCanvasTransform) {
636 // canvas level transform was built into the modelView and geometry,
637 // so the shader matrix must reverse this
638 shaderMatrix.loadInverse(mOutGlop->transform.canvas);
639 shaderMatrix.multiply(mOutGlop->transform.modelView);
640 } else {
Chris Craik7c85c542015-08-19 15:10:24 -0700641 shaderMatrix = mOutGlop->transform.modelView;
Chris Craik53e51e42015-06-01 10:35:35 -0700642 }
643 SkiaShader::store(mCaches, *mShader, shaderMatrix,
644 &textureUnit, &mDescription, &(mOutGlop->fill.skiaShaderData));
645 }
Chris Craik922d3a72015-02-13 17:47:21 -0800646
Chris Craik0519c812015-02-11 13:17:06 -0800647 // duplicates ProgramCache's definition of color uniform presence
648 const bool singleColor = !mDescription.hasTexture
649 && !mDescription.hasExternalTexture
650 && !mDescription.hasGradient
651 && !mDescription.hasBitmap;
652 mOutGlop->fill.colorEnabled = mDescription.modulate || singleColor;
Chris Craikf27133d2015-02-19 09:51:53 -0800653
654 verify(mDescription, *mOutGlop);
Chris Craikef250742015-02-25 17:16:16 -0800655
656 // Final step: populate program and map bounds into render target space
657 mOutGlop->fill.program = mCaches.programCache.get(mDescription);
Chris Craik03188872015-02-02 18:39:33 -0800658}
659
Chris Craikb565df12015-10-05 13:00:52 -0700660void GlopBuilder::dump(const Glop& glop) {
661 ALOGD("Glop Mesh");
662 const Glop::Mesh& mesh = glop.mesh;
663 ALOGD(" primitive mode: %d", mesh.primitiveMode);
664 ALOGD(" indices: buffer obj %x, indices %p", mesh.indices.bufferObject, mesh.indices.indices);
665
666 const Glop::Mesh::Vertices& vertices = glop.mesh.vertices;
667 ALOGD(" vertices: buffer obj %x, flags %x, pos %p, tex %p, clr %p, stride %d",
668 vertices.bufferObject, vertices.attribFlags,
669 vertices.position, vertices.texCoord, vertices.color, vertices.stride);
670 ALOGD(" element count: %d", mesh.elementCount);
671
672 ALOGD("Glop Fill");
673 const Glop::Fill& fill = glop.fill;
674 ALOGD(" program %p", fill.program);
675 if (fill.texture.texture) {
676 ALOGD(" texture %p, target %d, filter %d, clamp %d",
sergeyv2a38c422016-10-25 15:21:50 -0700677 fill.texture.texture, fill.texture.texture->target(),
678 fill.texture.filter, fill.texture.clamp);
Chris Craikb565df12015-10-05 13:00:52 -0700679 if (fill.texture.textureTransform) {
680 fill.texture.textureTransform->dump("texture transform");
681 }
682 }
683 ALOGD_IF(fill.colorEnabled, " color (argb) %.2f %.2f %.2f %.2f",
684 fill.color.a, fill.color.r, fill.color.g, fill.color.b);
685 ALOGD_IF(fill.filterMode != ProgramDescription::ColorFilterMode::None,
686 " filterMode %d", (int)fill.filterMode);
687 ALOGD_IF(fill.skiaShaderData.skiaShaderType, " shader type %d",
688 fill.skiaShaderData.skiaShaderType);
689
690 ALOGD("Glop transform");
Chris Craik701b3cc2016-03-11 18:39:01 -0800691 glop.transform.modelView.dump(" model view");
692 glop.transform.canvas.dump(" canvas");
693 ALOGD_IF(glop.transform.transformFlags, " transformFlags 0x%x", glop.transform.transformFlags);
694
695 ALOGD_IF(glop.roundRectClipState, "Glop RRCS %p", glop.roundRectClipState);
Chris Craikb565df12015-10-05 13:00:52 -0700696
697 ALOGD("Glop blend %d %d", glop.blend.src, glop.blend.dst);
Chris Craikb565df12015-10-05 13:00:52 -0700698}
699
Chris Craik03188872015-02-02 18:39:33 -0800700} /* namespace uirenderer */
701} /* namespace android */