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

Side by Side Diff: src/gpu/effects/GrOvalEffect.cpp

Issue 220233011: Implement drawDRRect for GPU (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | 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 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 "GrOvalEffect.h" 8 #include "GrOvalEffect.h"
9 9
10 #include "gl/GrGLEffect.h" 10 #include "gl/GrGLEffect.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 void GLCircleEffect::emitCode(GrGLShaderBuilder* builder, 131 void GLCircleEffect::emitCode(GrGLShaderBuilder* builder,
132 const GrDrawEffect& drawEffect, 132 const GrDrawEffect& drawEffect,
133 EffectKey key, 133 EffectKey key,
134 const char* outputColor, 134 const char* outputColor,
135 const char* inputColor, 135 const char* inputColor,
136 const TransformedCoordsArray&, 136 const TransformedCoordsArray&,
137 const TextureSamplerArray& samplers) { 137 const TextureSamplerArray& samplers) {
138 const CircleEffect& ce = drawEffect.castEffect<CircleEffect>(); 138 const CircleEffect& ce = drawEffect.castEffect<CircleEffect>();
139 const char *circleName; 139 const char *circleName;
140 // The circle uniform is (center.x, center.y, radius + 0.5) 140 // The circle uniform is (center.x, center.y, radius + 0.5) for regular fill s and
141 // (... ,radius - 0.5) for inverse fills.
141 fCircleUniform = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility , 142 fCircleUniform = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility ,
142 kVec3f_GrSLType, 143 kVec3f_GrSLType,
143 "circle", 144 "circle",
144 &circleName); 145 &circleName);
145 const char* fragmentPos = builder->fragmentPosition(); 146 const char* fragmentPos = builder->fragmentPosition();
146 147
147 SkASSERT(kHairlineAA_GrEffectEdgeType != ce.getEdgeType()); 148 SkASSERT(kHairlineAA_GrEffectEdgeType != ce.getEdgeType());
148 if (GrEffectEdgeTypeIsInverseFill(ce.getEdgeType())) { 149 if (GrEffectEdgeTypeIsInverseFill(ce.getEdgeType())) {
149 builder->fsCodeAppendf("\t\tfloat d = length(%s.xy - %s.xy) - %s.z;\n", 150 builder->fsCodeAppendf("\t\tfloat d = length(%s.xy - %s.xy) - %s.z;\n",
150 circleName, fragmentPos, circleName); 151 circleName, fragmentPos, circleName);
(...skipping 13 matching lines...) Expand all
164 165
165 GrGLEffect::EffectKey GLCircleEffect::GenKey(const GrDrawEffect& drawEffect, 166 GrGLEffect::EffectKey GLCircleEffect::GenKey(const GrDrawEffect& drawEffect,
166 const GrGLCaps&) { 167 const GrGLCaps&) {
167 const CircleEffect& ce = drawEffect.castEffect<CircleEffect>(); 168 const CircleEffect& ce = drawEffect.castEffect<CircleEffect>();
168 return ce.getEdgeType(); 169 return ce.getEdgeType();
169 } 170 }
170 171
171 void GLCircleEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect& drawEffect) { 172 void GLCircleEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect& drawEffect) {
172 const CircleEffect& ce = drawEffect.castEffect<CircleEffect>(); 173 const CircleEffect& ce = drawEffect.castEffect<CircleEffect>();
173 if (ce.getRadius() != fPrevRadius || ce.getCenter() != fPrevCenter) { 174 if (ce.getRadius() != fPrevRadius || ce.getCenter() != fPrevCenter) {
174 uman.set3f(fCircleUniform, ce.getCenter().fX, ce.getCenter().fY, ce.getR adius() + 0.5f); 175 SkScalar radius = ce.getRadius();
176 if (GrEffectEdgeTypeIsInverseFill(ce.getEdgeType())) {
177 radius -= 0.5f;
178 } else {
179 radius += 0.5f;
180 }
181 uman.set3f(fCircleUniform, ce.getCenter().fX, ce.getCenter().fY, radius) ;
175 fPrevCenter = ce.getCenter(); 182 fPrevCenter = ce.getCenter();
176 fPrevRadius = ce.getRadius(); 183 fPrevRadius = ce.getRadius();
177 } 184 }
178 } 185 }
179 186
180 ////////////////////////////////////////////////////////////////////////////// 187 //////////////////////////////////////////////////////////////////////////////
181 188
182 class GLEllipseEffect; 189 class GLEllipseEffect;
183 190
184 class EllipseEffect : public GrEffect { 191 class EllipseEffect : public GrEffect {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 w /= 2; 378 w /= 2;
372 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval .fTop + w), w); 379 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval .fTop + w), w);
373 } else { 380 } else {
374 w /= 2; 381 w /= 2;
375 h /= 2; 382 h /= 2;
376 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova l.fTop + h), w, h); 383 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova l.fTop + h), w, h);
377 } 384 }
378 385
379 return NULL; 386 return NULL;
380 } 387 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698