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

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

Issue 66813002: Revert "Do not apply hairline optimization for paths if nv_path_rendering is used" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrDrawTarget.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 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "GrDrawState.h" 8 #include "GrDrawState.h"
9 #include "GrPaint.h" 9 #include "GrPaint.h"
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // These have no equivalent in GrPaint, set them to defaults 47 // These have no equivalent in GrPaint, set them to defaults
48 fCommon.fBlendConstant = 0x0; 48 fCommon.fBlendConstant = 0x0;
49 fCommon.fDrawFace = kBoth_DrawFace; 49 fCommon.fDrawFace = kBoth_DrawFace;
50 fCommon.fStencilSettings.setDisabled(); 50 fCommon.fStencilSettings.setDisabled();
51 this->resetStateFlags(); 51 this->resetStateFlags();
52 52
53 // Enable the clip bit 53 // Enable the clip bit
54 this->enableState(GrDrawState::kClip_StateBit); 54 this->enableState(GrDrawState::kClip_StateBit);
55 55
56 this->setColor(paint.getColor()); 56 this->setColor(paint.getColor());
57 this->setCoverage4(paint.getCoverage());
57 this->setState(GrDrawState::kDither_StateBit, paint.isDither()); 58 this->setState(GrDrawState::kDither_StateBit, paint.isDither());
58 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias()); 59 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias());
59 60
60 this->setBlendFunc(paint.getSrcBlendCoeff(), paint.getDstBlendCoeff()); 61 this->setBlendFunc(paint.getSrcBlendCoeff(), paint.getDstBlendCoeff());
61 this->setCoverage(paint.getCoverage()); 62 this->setCoverage(paint.getCoverage());
62 } 63 }
63 64
64 //////////////////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////////////////
65 66
66 static size_t vertex_size(const GrVertexAttrib* attribs, int count) { 67 static size_t vertex_size(const GrVertexAttrib* attribs, int count) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 213 }
213 214
214 // Run through the color stages 215 // Run through the color stages
215 for (int s = 0; s < fColorStages.count(); ++s) { 216 for (int s = 0; s < fColorStages.count(); ++s) {
216 const GrEffectRef* effect = fColorStages[s].getEffect(); 217 const GrEffectRef* effect = fColorStages[s].getEffect();
217 (*effect)->getConstantColorComponents(&color, &validComponentFlags); 218 (*effect)->getConstantColorComponents(&color, &validComponentFlags);
218 } 219 }
219 220
220 // Check whether coverage is treated as color. If so we run through the cove rage computation. 221 // Check whether coverage is treated as color. If so we run through the cove rage computation.
221 if (this->isCoverageDrawing()) { 222 if (this->isCoverageDrawing()) {
222 GrColor coverageColor = this->getCoverageColor(); 223 GrColor coverageColor = this->getCoverage();
223 GrColor oldColor = color; 224 GrColor oldColor = color;
224 color = 0; 225 color = 0;
225 for (int c = 0; c < 4; ++c) { 226 for (int c = 0; c < 4; ++c) {
226 if (validComponentFlags & (1 << c)) { 227 if (validComponentFlags & (1 << c)) {
227 U8CPU a = (oldColor >> (c * 8)) & 0xff; 228 U8CPU a = (oldColor >> (c * 8)) & 0xff;
228 U8CPU b = (coverageColor >> (c * 8)) & 0xff; 229 U8CPU b = (coverageColor >> (c * 8)) & 0xff;
229 color |= (SkMulDiv255Round(a, b) << (c * 8)); 230 color |= (SkMulDiv255Round(a, b) << (c * 8));
230 } 231 }
231 } 232 }
232 for (int s = 0; s < fCoverageStages.count(); ++s) { 233 for (int s = 0; s < fCoverageStages.count(); ++s) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 305 }
305 306
306 bool srcAIsOne = this->srcAlphaWillBeOne(); 307 bool srcAIsOne = this->srcAlphaWillBeOne();
307 bool dstCoeffIsOne = kOne_GrBlendCoeff == *dstCoeff || 308 bool dstCoeffIsOne = kOne_GrBlendCoeff == *dstCoeff ||
308 (kSA_GrBlendCoeff == *dstCoeff && srcAIsOne); 309 (kSA_GrBlendCoeff == *dstCoeff && srcAIsOne);
309 bool dstCoeffIsZero = kZero_GrBlendCoeff == *dstCoeff || 310 bool dstCoeffIsZero = kZero_GrBlendCoeff == *dstCoeff ||
310 (kISA_GrBlendCoeff == *dstCoeff && srcAIsOne); 311 (kISA_GrBlendCoeff == *dstCoeff && srcAIsOne);
311 312
312 bool covIsZero = !this->isCoverageDrawing() && 313 bool covIsZero = !this->isCoverageDrawing() &&
313 !this->hasCoverageVertexAttribute() && 314 !this->hasCoverageVertexAttribute() &&
314 0 == this->getCoverageColor(); 315 0 == this->getCoverage();
315 // When coeffs are (0,1) there is no reason to draw at all, unless 316 // When coeffs are (0,1) there is no reason to draw at all, unless
316 // stenciling is enabled. Having color writes disabled is effectively 317 // stenciling is enabled. Having color writes disabled is effectively
317 // (0,1). The same applies when coverage is known to be 0. 318 // (0,1). The same applies when coverage is known to be 0.
318 if ((kZero_GrBlendCoeff == *srcCoeff && dstCoeffIsOne) || covIsZero) { 319 if ((kZero_GrBlendCoeff == *srcCoeff && dstCoeffIsOne) || covIsZero) {
319 if (this->getStencil().doesWrite()) { 320 if (this->getStencil().doesWrite()) {
320 return kDisableBlend_BlendOptFlag | 321 return kDisableBlend_BlendOptFlag |
321 kEmitCoverage_BlendOptFlag; 322 kEmitCoverage_BlendOptFlag;
322 } else { 323 } else {
323 return kSkipDraw_BlendOptFlag; 324 return kSkipDraw_BlendOptFlag;
324 } 325 }
325 } 326 }
326 327
327 // check for coverage due to constant coverage, per-vertex coverage, or cove rage stage 328 // check for coverage due to constant coverage, per-vertex coverage, or cove rage stage
328 bool hasCoverage = forceCoverage || 329 bool hasCoverage = forceCoverage ||
329 0xffffffff != this->getCoverageColor() || 330 0xffffffff != this->getCoverage() ||
330 this->hasCoverageVertexAttribute() || 331 this->hasCoverageVertexAttribute() ||
331 fCoverageStages.count() > 0; 332 fCoverageStages.count() > 0;
332 333
333 // if we don't have coverage we can check whether the dst 334 // if we don't have coverage we can check whether the dst
334 // has to read at all. If not, we'll disable blending. 335 // has to read at all. If not, we'll disable blending.
335 if (!hasCoverage) { 336 if (!hasCoverage) {
336 if (dstCoeffIsZero) { 337 if (dstCoeffIsZero) {
337 if (kOne_GrBlendCoeff == *srcCoeff) { 338 if (kOne_GrBlendCoeff == *srcCoeff) {
338 // if there is no coverage and coeffs are (1,0) then we 339 // if there is no coverage and coeffs are (1,0) then we
339 // won't need to read the dst at all, it gets replaced by src 340 // won't need to read the dst at all, it gets replaced by src
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 fDrawState->fColorStages[s].saveCoordChange(&fSavedCoordChanges[i]); 467 fDrawState->fColorStages[s].saveCoordChange(&fSavedCoordChanges[i]);
467 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix); 468 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix);
468 } 469 }
469 470
470 int numCoverageStages = fDrawState->numCoverageStages(); 471 int numCoverageStages = fDrawState->numCoverageStages();
471 for (int s = 0; s < numCoverageStages; ++s, ++i) { 472 for (int s = 0; s < numCoverageStages; ++s, ++i) {
472 fDrawState->fCoverageStages[s].saveCoordChange(&fSavedCoordChanges[i]); 473 fDrawState->fCoverageStages[s].saveCoordChange(&fSavedCoordChanges[i]);
473 fDrawState->fCoverageStages[s].localCoordChange(coordChangeMatrix); 474 fDrawState->fCoverageStages[s].localCoordChange(coordChangeMatrix);
474 } 475 }
475 } 476 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698