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

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

Issue 1110033004: Make XPFragmentBuilder only Builder with access to DstCopy. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/gpu/GrDefaultGeoProcFactory.cpp ('k') | src/gpu/effects/GrBezierEffect.cpp » ('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 2013 Google Inc. 2 * Copyright 2013 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 "GrOvalRenderer.h" 8 #include "GrOvalRenderer.h"
9 9
10 #include "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputC olor, NULL, 106 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputC olor, NULL,
107 &fColorUniform); 107 &fColorUniform);
108 108
109 // Setup position 109 // Setup position
110 this->setupPosition(pb, gpArgs, ce.inPosition()->fName, ce.viewMatri x()); 110 this->setupPosition(pb, gpArgs, ce.inPosition()->fName, ce.viewMatri x());
111 111
112 // emit transforms 112 // emit transforms
113 this->emitTransforms(args.fPB, gpArgs->fPositionVar, ce.inPosition() ->fName, 113 this->emitTransforms(args.fPB, gpArgs->fPositionVar, ce.inPosition() ->fName,
114 ce.localMatrix(), args.fTransformsIn, args.fTra nsformsOut); 114 ce.localMatrix(), args.fTransformsIn, args.fTra nsformsOut);
115 115
116 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilde r(); 116 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder( );
117 fsBuilder->codeAppendf("float d = length(%s.xy);", v.fsIn()); 117 fsBuilder->codeAppendf("float d = length(%s.xy);", v.fsIn());
118 fsBuilder->codeAppendf("float edgeAlpha = clamp(%s.z * (1.0 - d), 0. 0, 1.0);", v.fsIn()); 118 fsBuilder->codeAppendf("float edgeAlpha = clamp(%s.z * (1.0 - d), 0. 0, 1.0);", v.fsIn());
119 if (ce.isStroked()) { 119 if (ce.isStroked()) {
120 fsBuilder->codeAppendf("float innerAlpha = clamp(%s.z * (d - %s. w), 0.0, 1.0);", 120 fsBuilder->codeAppendf("float innerAlpha = clamp(%s.z * (d - %s. w), 0.0, 1.0);",
121 v.fsIn(), v.fsIn()); 121 v.fsIn(), v.fsIn());
122 fsBuilder->codeAppend("edgeAlpha *= innerAlpha;"); 122 fsBuilder->codeAppend("edgeAlpha *= innerAlpha;");
123 } 123 }
124 124
125 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage ); 125 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage );
126 } 126 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 &fColorUniform); 286 &fColorUniform);
287 287
288 // Setup position 288 // Setup position
289 this->setupPosition(pb, gpArgs, ee.inPosition()->fName, ee.viewMatri x()); 289 this->setupPosition(pb, gpArgs, ee.inPosition()->fName, ee.viewMatri x());
290 290
291 // emit transforms 291 // emit transforms
292 this->emitTransforms(args.fPB, gpArgs->fPositionVar, ee.inPosition() ->fName, 292 this->emitTransforms(args.fPB, gpArgs->fPositionVar, ee.inPosition() ->fName,
293 ee.localMatrix(), args.fTransformsIn, args.fTra nsformsOut); 293 ee.localMatrix(), args.fTransformsIn, args.fTra nsformsOut);
294 294
295 // for outer curve 295 // for outer curve
296 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilde r(); 296 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder( );
297 fsBuilder->codeAppendf("vec2 scaledOffset = %s*%s.xy;", ellipseOffse ts.fsIn(), 297 fsBuilder->codeAppendf("vec2 scaledOffset = %s*%s.xy;", ellipseOffse ts.fsIn(),
298 ellipseRadii.fsIn()); 298 ellipseRadii.fsIn());
299 fsBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;"); 299 fsBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;");
300 fsBuilder->codeAppendf("vec2 grad = 2.0*scaledOffset*%s.xy;", ellips eRadii.fsIn()); 300 fsBuilder->codeAppendf("vec2 grad = 2.0*scaledOffset*%s.xy;", ellips eRadii.fsIn());
301 fsBuilder->codeAppend("float grad_dot = dot(grad, grad);"); 301 fsBuilder->codeAppend("float grad_dot = dot(grad, grad);");
302 302
303 // avoid calling inversesqrt on zero. 303 // avoid calling inversesqrt on zero.
304 fsBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);"); 304 fsBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);");
305 fsBuilder->codeAppend("float invlen = inversesqrt(grad_dot);"); 305 fsBuilder->codeAppend("float invlen = inversesqrt(grad_dot);");
306 fsBuilder->codeAppend("float edgeAlpha = clamp(0.5-test*invlen, 0.0, 1.0);"); 306 fsBuilder->codeAppend("float edgeAlpha = clamp(0.5-test*invlen, 0.0, 1.0);");
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputC olor, NULL, 486 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputC olor, NULL,
487 &fColorUniform); 487 &fColorUniform);
488 488
489 // Setup position 489 // Setup position
490 this->setupPosition(pb, gpArgs, ee.inPosition()->fName, ee.viewMatri x()); 490 this->setupPosition(pb, gpArgs, ee.inPosition()->fName, ee.viewMatri x());
491 491
492 // emit transforms 492 // emit transforms
493 this->emitTransforms(args.fPB, gpArgs->fPositionVar, ee.inPosition() ->fName, 493 this->emitTransforms(args.fPB, gpArgs->fPositionVar, ee.inPosition() ->fName,
494 ee.localMatrix(), args.fTransformsIn, args.fTra nsformsOut); 494 ee.localMatrix(), args.fTransformsIn, args.fTra nsformsOut);
495 495
496 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilde r(); 496 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder( );
497 SkAssertResult(fsBuilder->enableFeature( 497 SkAssertResult(fsBuilder->enableFeature(
498 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) ); 498 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) );
499 // for outer curve 499 // for outer curve
500 fsBuilder->codeAppendf("vec2 scaledOffset = %s.xy;", offsets0.fsIn() ); 500 fsBuilder->codeAppendf("vec2 scaledOffset = %s.xy;", offsets0.fsIn() );
501 fsBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;"); 501 fsBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;");
502 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s);", offsets0.fsIn()); 502 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s);", offsets0.fsIn());
503 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s);", offsets0.fsIn()); 503 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s);", offsets0.fsIn());
504 fsBuilder->codeAppendf("vec2 grad = vec2(2.0*%s.x*duvdx.x + 2.0*%s.y *duvdx.y," 504 fsBuilder->codeAppendf("vec2 grad = vec2(2.0*%s.x*duvdx.x + 2.0*%s.y *duvdx.y,"
505 " 2.0*%s.x*duvdy.x + 2.0*%s.y *duvdy.y);", 505 " 2.0*%s.x*duvdy.x + 2.0*%s.y *duvdy.y);",
506 offsets0.fsIn(), offsets0.fsIn(), offsets0.fs In(), offsets0.fsIn()); 506 offsets0.fsIn(), offsets0.fsIn(), offsets0.fs In(), offsets0.fsIn());
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 geometry.fInnerXRadius = innerXRadius; 2223 geometry.fInnerXRadius = innerXRadius;
2224 geometry.fInnerYRadius = innerYRadius; 2224 geometry.fInnerYRadius = innerYRadius;
2225 geometry.fStroke = isStrokeOnly; 2225 geometry.fStroke = isStrokeOnly;
2226 geometry.fDevBounds = bounds; 2226 geometry.fDevBounds = bounds;
2227 2227
2228 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry, indexBuffer)); 2228 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry, indexBuffer));
2229 target->drawBatch(pipelineBuilder, batch, &bounds); 2229 target->drawBatch(pipelineBuilder, batch, &bounds);
2230 } 2230 }
2231 return true; 2231 return true;
2232 } 2232 }
OLDNEW
« no previous file with comments | « src/gpu/GrDefaultGeoProcFactory.cpp ('k') | src/gpu/effects/GrBezierEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698