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

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

Issue 1967513002: Revert of Replace GrStrokeInfo with GrStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@resscale
Patch Set: Created 4 years, 7 months 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrAADistanceFieldPathRenderer.h" 8 #include "GrAADistanceFieldPathRenderer.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 delete fAtlas; 75 delete fAtlas;
76 76
77 #ifdef DF_PATH_TRACKING 77 #ifdef DF_PATH_TRACKING
78 SkDebugf("Cached paths: %d, freed paths: %d\n", g_NumCachedPaths, g_NumFreed Paths); 78 SkDebugf("Cached paths: %d, freed paths: %d\n", g_NumCachedPaths, g_NumFreed Paths);
79 #endif 79 #endif
80 } 80 }
81 81
82 //////////////////////////////////////////////////////////////////////////////// 82 ////////////////////////////////////////////////////////////////////////////////
83 bool GrAADistanceFieldPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c onst { 83 bool GrAADistanceFieldPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c onst {
84 // We don't currently apply the dash or factor it into the DF key. (skbug.co m/5082) 84
85 if (args.fStyle->pathEffect()) {
86 return false;
87 }
88 // TODO: Support inverse fill 85 // TODO: Support inverse fill
89 if (!args.fShaderCaps->shaderDerivativeSupport() || !args.fAntiAlias || 86 if (!args.fShaderCaps->shaderDerivativeSupport() || !args.fAntiAlias ||
90 args.fStyle->isSimpleHairline() || args.fPath->isInverseFillType() || 87 SkStrokeRec::kHairline_Style == args.fStroke->getStyle() ||
91 args.fPath->isVolatile()) { 88 args.fPath->isInverseFillType() || args.fPath->isVolatile() ||
89 // We don't currently apply the dash or factor it into the DF key. (skbu g.com/5082)
90 args.fStroke->isDashed()) {
92 return false; 91 return false;
93 } 92 }
94 93
95 // currently don't support perspective 94 // currently don't support perspective
96 if (args.fViewMatrix->hasPerspective()) { 95 if (args.fViewMatrix->hasPerspective()) {
97 return false; 96 return false;
98 } 97 }
99 98
100 // only support paths with bounds within kMediumMIP by kMediumMIP, 99 // only support paths with bounds within kMediumMIP by kMediumMIP,
101 // scaled to have bounds within 2.0f*kLargeMIP by 2.0f*kLargeMIP 100 // scaled to have bounds within 2.0f*kLargeMIP by 2.0f*kLargeMIP
102 // the goal is to accelerate rendering of lots of small paths that may be sc aling 101 // the goal is to accelerate rendering of lots of small paths that may be sc aling
103 SkScalar maxScale = args.fViewMatrix->getMaxScale(); 102 SkScalar maxScale = args.fViewMatrix->getMaxScale();
104 #if 0 // This is more accurate but changes some GMs. TODO: Standalone change to enable this.
105 SkRect bounds;
106 args.fStyle->adjustBounds(&bounds, args.fPath->getBounds());
107 SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height());
108 #else
109 const SkRect& bounds = args.fPath->getBounds(); 103 const SkRect& bounds = args.fPath->getBounds();
110 SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height()); 104 SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height());
111 const SkStrokeRec& stroke = args.fStyle->strokeRec();
112 // Approximate stroked size by adding the maximum of the stroke width or 2x the miter limit 105 // Approximate stroked size by adding the maximum of the stroke width or 2x the miter limit
113 if (!stroke.isFillStyle()) { 106 if (!args.fStroke->isFillStyle()) {
114 SkScalar extraWidth = stroke.getWidth(); 107 SkScalar extraWidth = args.fStroke->getWidth();
115 if (SkPaint::kMiter_Join == stroke.getJoin()) { 108 if (SkPaint::kMiter_Join == args.fStroke->getJoin()) {
116 extraWidth = SkTMax(extraWidth, 2.0f*stroke.getMiter()); 109 extraWidth = SkTMax(extraWidth, 2.0f*args.fStroke->getMiter());
117 } 110 }
118 maxDim += extraWidth; 111 maxDim += extraWidth;
119 } 112 }
120 #endif
121 113
122 return maxDim <= kMediumMIP && maxDim * maxScale <= 2.0f*kLargeMIP; 114 return maxDim <= kMediumMIP && maxDim * maxScale <= 2.0f*kLargeMIP;
123 } 115 }
124 116
125 //////////////////////////////////////////////////////////////////////////////// 117 ////////////////////////////////////////////////////////////////////////////////
126 118
127 // padding around path bounds to allow for antialiased pixels 119 // padding around path bounds to allow for antialiased pixels
128 static const SkScalar kAntiAliasPad = 1.0f; 120 static const SkScalar kAntiAliasPad = 1.0f;
129 121
130 class AADistanceFieldPathBatch : public GrVertexBatch { 122 class AADistanceFieldPathBatch : public GrVertexBatch {
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 fAtlas = args.fResourceProvider->createAtlas(kAlpha_8_GrPixelConfig, 545 fAtlas = args.fResourceProvider->createAtlas(kAlpha_8_GrPixelConfig,
554 ATLAS_TEXTURE_WIDTH, ATLAS_ TEXTURE_HEIGHT, 546 ATLAS_TEXTURE_WIDTH, ATLAS_ TEXTURE_HEIGHT,
555 NUM_PLOTS_X, NUM_PLOTS_Y, 547 NUM_PLOTS_X, NUM_PLOTS_Y,
556 &GrAADistanceFieldPathRende rer::HandleEviction, 548 &GrAADistanceFieldPathRende rer::HandleEviction,
557 (void*)this); 549 (void*)this);
558 if (!fAtlas) { 550 if (!fAtlas) {
559 return false; 551 return false;
560 } 552 }
561 } 553 }
562 554
563 // It's ok to ignore style's path effect because canDrawPath filtered out pa th effects. 555 AADistanceFieldPathBatch::Geometry geometry(*args.fStroke);
564 AADistanceFieldPathBatch::Geometry geometry(args.fStyle->strokeRec()); 556 if (SkStrokeRec::kFill_Style == args.fStroke->getStyle()) {
565 if (args.fStyle->isSimpleFill()) {
566 geometry.fPath = *args.fPath; 557 geometry.fPath = *args.fPath;
567 } else { 558 } else {
568 args.fStyle->strokeRec().applyToPath(&geometry.fPath, *args.fPath); 559 args.fStroke->applyToPath(&geometry.fPath, *args.fPath);
569 } 560 }
570 geometry.fColor = args.fColor; 561 geometry.fColor = args.fColor;
571 geometry.fAntiAlias = args.fAntiAlias; 562 geometry.fAntiAlias = args.fAntiAlias;
572 // Note: this is the generation ID of the _original_ path. When a new path i s 563 // Note: this is the generation ID of the _original_ path. When a new path i s
573 // generated due to stroking it is important that the original path's id is used 564 // generated due to stroking it is important that the original path's id is used
574 // for caching. 565 // for caching.
575 geometry.fGenID = args.fPath->getGenerationID(); 566 geometry.fGenID = args.fPath->getGenerationID();
576 567
577 SkAutoTUnref<GrDrawBatch> batch(AADistanceFieldPathBatch::Create(geometry, 568 SkAutoTUnref<GrDrawBatch> batch(AADistanceFieldPathBatch::Create(geometry,
578 *args.fView Matrix, fAtlas, 569 *args.fView Matrix, fAtlas,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 geometry.fGenID = random->nextU(); 645 geometry.fGenID = random->nextU();
655 646
656 return AADistanceFieldPathBatch::Create(geometry, viewMatrix, 647 return AADistanceFieldPathBatch::Create(geometry, viewMatrix,
657 gTestStruct.fAtlas, 648 gTestStruct.fAtlas,
658 &gTestStruct.fPathCache, 649 &gTestStruct.fPathCache,
659 &gTestStruct.fPathList, 650 &gTestStruct.fPathList,
660 gammaCorrect); 651 gammaCorrect);
661 } 652 }
662 653
663 #endif 654 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAConvexPathRenderer.cpp ('k') | src/gpu/batches/GrAAHairLinePathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698