Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: src/gpu/GrAADistanceFieldPathRenderer.cpp

Issue 761563002: First step to moving vertex attributes to the geometryProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: adding test to ignore Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrAAConvexPathRenderer.cpp ('k') | src/gpu/GrAAHairLinePathRenderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrAADistanceFieldPathRenderer.h" 9 #include "GrAADistanceFieldPathRenderer.h"
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 GrPathRenderer::StencilSupport 96 GrPathRenderer::StencilSupport
97 GrAADistanceFieldPathRenderer::onGetStencilSupport(const GrDrawTarget*, 97 GrAADistanceFieldPathRenderer::onGetStencilSupport(const GrDrawTarget*,
98 const GrDrawState*, 98 const GrDrawState*,
99 const SkPath&, 99 const SkPath&,
100 const SkStrokeRec&) const { 100 const SkStrokeRec&) const {
101 return GrPathRenderer::kNoSupport_StencilSupport; 101 return GrPathRenderer::kNoSupport_StencilSupport;
102 } 102 }
103 103
104 //////////////////////////////////////////////////////////////////////////////// 104 ////////////////////////////////////////////////////////////////////////////////
105 105
106 // position + texture coord
107 extern const GrVertexAttrib gSDFPathVertexAttribs[] = {
108 { kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding },
109 { kVec2f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAtt ribBinding }
110 };
111 static const size_t kSDFPathVASize = 2 * sizeof(SkPoint);
112
113 bool GrAADistanceFieldPathRenderer::onDrawPath(GrDrawTarget* target, 106 bool GrAADistanceFieldPathRenderer::onDrawPath(GrDrawTarget* target,
114 GrDrawState* drawState, 107 GrDrawState* drawState,
115 const SkPath& path, 108 const SkPath& path,
116 const SkStrokeRec& stroke, 109 const SkStrokeRec& stroke,
117 bool antiAlias) { 110 bool antiAlias) {
118 // we've already bailed on inverse filled paths, so this is safe 111 // we've already bailed on inverse filled paths, so this is safe
119 if (path.isEmpty()) { 112 if (path.isEmpty()) {
120 return true; 113 return true;
121 } 114 }
122 115
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 GrDrawState* drawState, 308 GrDrawState* drawState,
316 const SkPath& path, 309 const SkPath& path,
317 const PathData* pathData) { 310 const PathData* pathData) {
318 GrTexture* texture = fAtlas->getTexture(); 311 GrTexture* texture = fAtlas->getTexture();
319 GrDrawState::AutoRestoreEffects are(drawState); 312 GrDrawState::AutoRestoreEffects are(drawState);
320 313
321 SkASSERT(pathData->fPlot); 314 SkASSERT(pathData->fPlot);
322 GrDrawTarget::DrawToken drawToken = target->getCurrentDrawToken(); 315 GrDrawTarget::DrawToken drawToken = target->getCurrentDrawToken();
323 pathData->fPlot->setDrawToken(drawToken); 316 pathData->fPlot->setDrawToken(drawToken);
324 317
325 // make me some vertices 318 // set up any flags
326 drawState->setVertexAttribs<gSDFPathVertexAttribs>(SK_ARRAY_COUNT(gSDFPathVe rtexAttribs), 319 uint32_t flags = 0;
327 kSDFPathVASize); 320 const SkMatrix& vm = drawState->getViewMatrix();
321 flags |= vm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
322
323 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_ FilterMode);
324 if (flags != fEffectFlags) {
325 fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::Crea te(texture,
326 params,
327 flags));
328 fEffectFlags = flags;
329 }
330 drawState->setGeometryProcessor(fCachedGeometryProcessor.get());
331
328 void* vertices = NULL; 332 void* vertices = NULL;
329 bool success = target->reserveVertexAndIndexSpace(4, drawState->getVertexStr ide(), 0, &vertices, 333 bool success = target->reserveVertexAndIndexSpace(4,
330 NULL); 334 fCachedGeometryProcessor-> getVertexStride(),
335 0, &vertices, NULL);
336 SkASSERT(fCachedGeometryProcessor->getVertexStride() == 2 * sizeof(SkPoint)) ;
331 GrAlwaysAssert(success); 337 GrAlwaysAssert(success);
332 338
333 SkScalar dx = pathData->fBounds.fLeft; 339 SkScalar dx = pathData->fBounds.fLeft;
334 SkScalar dy = pathData->fBounds.fTop; 340 SkScalar dy = pathData->fBounds.fTop;
335 SkScalar width = pathData->fBounds.width(); 341 SkScalar width = pathData->fBounds.width();
336 SkScalar height = pathData->fBounds.height(); 342 SkScalar height = pathData->fBounds.height();
337 343
338 SkScalar invScale = 1.0f/pathData->fScale; 344 SkScalar invScale = 1.0f/pathData->fScale;
339 dx *= invScale; 345 dx *= invScale;
340 dy *= invScale; 346 dy *= invScale;
(...skipping 13 matching lines...) Expand all
354 360
355 // vertex texture coords 361 // vertex texture coords
356 intptr_t intPtr = reinterpret_cast<intptr_t>(positions); 362 intptr_t intPtr = reinterpret_cast<intptr_t>(positions);
357 SkPoint* textureCoords = reinterpret_cast<SkPoint*>(intPtr + vertSize - size of(SkPoint)); 363 SkPoint* textureCoords = reinterpret_cast<SkPoint*>(intPtr + vertSize - size of(SkPoint));
358 textureCoords->setRectFan(SkFixedToFloat(texture->texturePriv().normalizeFix edX(tx)), 364 textureCoords->setRectFan(SkFixedToFloat(texture->texturePriv().normalizeFix edX(tx)),
359 SkFixedToFloat(texture->texturePriv().normalizeFix edY(ty)), 365 SkFixedToFloat(texture->texturePriv().normalizeFix edY(ty)),
360 SkFixedToFloat(texture->texturePriv().normalizeFix edX(tx + tw)), 366 SkFixedToFloat(texture->texturePriv().normalizeFix edX(tx + tw)),
361 SkFixedToFloat(texture->texturePriv().normalizeFix edY(ty + th)), 367 SkFixedToFloat(texture->texturePriv().normalizeFix edY(ty + th)),
362 vertSize); 368 vertSize);
363 369
364 // set up any flags
365 uint32_t flags = 0;
366 const SkMatrix& vm = drawState->getViewMatrix();
367 flags |= vm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
368
369 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_ FilterMode);
370 if (flags != fEffectFlags) {
371 fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::Crea te(texture,
372 params,
373 flags));
374 fEffectFlags = flags;
375 }
376 drawState->setGeometryProcessor(fCachedGeometryProcessor.get());
377
378 vm.mapRect(&r); 370 vm.mapRect(&r);
379 target->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); 371 target->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
380 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &r); 372 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &r);
381 target->resetVertexSource(); 373 target->resetVertexSource();
382 374
383 return true; 375 return true;
384 } 376 }
385 377
OLDNEW
« no previous file with comments | « src/gpu/GrAAConvexPathRenderer.cpp ('k') | src/gpu/GrAAHairLinePathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698