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

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

Issue 1472333003: Clean up Ganesh path render a little bit (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Ooops Created 5 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/GrBlurUtils.h ('k') | src/gpu/GrDrawContext.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 2015 Google Inc. 2 * Copyright 2015 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 "GrBlurUtils.h" 8 #include "GrBlurUtils.h"
9 #include "GrDrawContext.h" 9 #include "GrDrawContext.h"
10 #include "GrCaps.h" 10 #include "GrCaps.h"
(...skipping 28 matching lines...) Expand all
39 kDevice_GrCo ordSet))->unref(); 39 kDevice_GrCo ordSet))->unref();
40 40
41 SkMatrix inverse; 41 SkMatrix inverse;
42 if (!viewMatrix.invert(&inverse)) { 42 if (!viewMatrix.invert(&inverse)) {
43 return false; 43 return false;
44 } 44 }
45 drawContext->fillRectWithLocalMatrix(clip, *grp, SkMatrix::I(), maskRect, in verse); 45 drawContext->fillRectWithLocalMatrix(clip, *grp, SkMatrix::I(), maskRect, in verse);
46 return true; 46 return true;
47 } 47 }
48 48
49 static bool draw_with_mask_filter(GrDrawContext* drawContext, 49 static bool sw_draw_with_mask_filter(GrDrawContext* drawContext,
50 GrTextureProvider* textureProvider, 50 GrTextureProvider* textureProvider,
51 const GrClip& clipData, 51 const GrClip& clipData,
52 const SkMatrix& viewMatrix, 52 const SkMatrix& viewMatrix,
53 const SkPath& devPath, 53 const SkPath& devPath,
54 const SkMaskFilter* filter, 54 const SkMaskFilter* filter,
55 const SkIRect& clipBounds, 55 const SkIRect& clipBounds,
56 GrPaint* grp, 56 GrPaint* grp,
57 SkPaint::Style style) { 57 SkPaint::Style style) {
58 SkMask srcM, dstM; 58 SkMask srcM, dstM;
59 59
60 if (!SkDraw::DrawToMask(devPath, &clipBounds, filter, &viewMatrix, &srcM, 60 if (!SkDraw::DrawToMask(devPath, &clipBounds, filter, &viewMatrix, &srcM,
61 SkMask::kComputeBoundsAndRenderImage_CreateMode, sty le)) { 61 SkMask::kComputeBoundsAndRenderImage_CreateMode, sty le)) {
62 return false; 62 return false;
63 } 63 }
64 SkAutoMaskFreeImage autoSrc(srcM.fImage); 64 SkAutoMaskFreeImage autoSrc(srcM.fImage);
65 65
66 if (!filter->filterMask(&dstM, srcM, viewMatrix, nullptr)) { 66 if (!filter->filterMask(&dstM, srcM, viewMatrix, nullptr)) {
67 return false; 67 return false;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 bool pathIsMutable) { 159 bool pathIsMutable) {
160 SkASSERT(maskFilter); 160 SkASSERT(maskFilter);
161 161
162 SkIRect clipBounds; 162 SkIRect clipBounds;
163 clip.getConservativeBounds(renderTarget, &clipBounds); 163 clip.getConservativeBounds(renderTarget, &clipBounds);
164 SkTLazy<SkPath> tmpPath; 164 SkTLazy<SkPath> tmpPath;
165 GrStrokeInfo strokeInfo(origStrokeInfo); 165 GrStrokeInfo strokeInfo(origStrokeInfo);
166 166
167 static const SkRect* cullRect = nullptr; // TODO: what is our bounds? 167 static const SkRect* cullRect = nullptr; // TODO: what is our bounds?
168 168
169 if (!strokeInfo.isDashed() && pathEffect && pathEffect->filterPath(tmpPath.i nit(), *pathPtr, 169 SkASSERT(strokeInfo.isDashed() || !pathEffect);
170 &strokeIn fo, cullRect)) { 170
171 pathPtr = tmpPath.get();
172 pathPtr->setIsVolatile(true);
173 pathIsMutable = true;
174 }
175 if (!strokeInfo.isHairlineStyle()) { 171 if (!strokeInfo.isHairlineStyle()) {
176 SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init(); 172 SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init();
177 if (strokeInfo.isDashed()) { 173 if (strokeInfo.isDashed()) {
178 if (pathEffect->filterPath(strokedPath, *pathPtr, &strokeInfo, cullR ect)) { 174 if (pathEffect->filterPath(strokedPath, *pathPtr, &strokeInfo, cullR ect)) {
179 pathPtr = strokedPath; 175 pathPtr = strokedPath;
180 pathPtr->setIsVolatile(true); 176 pathPtr->setIsVolatile(true);
181 pathIsMutable = true; 177 pathIsMutable = true;
182 } 178 }
183 strokeInfo.removeDash(); 179 strokeInfo.removeDash();
184 } 180 }
185 if (strokeInfo.applyToPath(strokedPath, *pathPtr)) { 181 if (strokeInfo.applyToPath(strokedPath, *pathPtr)) {
182 // Apply the stroke to the path if there is one
186 pathPtr = strokedPath; 183 pathPtr = strokedPath;
187 pathPtr->setIsVolatile(true); 184 pathPtr->setIsVolatile(true);
188 pathIsMutable = true; 185 pathIsMutable = true;
189 strokeInfo.setFillStyle(); 186 strokeInfo.setFillStyle();
190 } 187 }
191 } 188 }
192 189
193 // avoid possibly allocating a new path in transform if we can 190 // avoid possibly allocating a new path in transform if we can
194 SkPath* devPathPtr = pathIsMutable ? pathPtr : tmpPath.init(); 191 SkPath* devPathPtr = pathIsMutable ? pathPtr : tmpPath.init();
195 if (!pathIsMutable) { 192 if (!pathIsMutable) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 return; 237 return;
241 } 238 }
242 } 239 }
243 } 240 }
244 } 241 }
245 242
246 // draw the mask on the CPU - this is a fallthrough path in case the 243 // draw the mask on the CPU - this is a fallthrough path in case the
247 // GPU path fails 244 // GPU path fails
248 SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_Style : 245 SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_Style :
249 SkPaint::kFill_Style; 246 SkPaint::kFill_Style;
250 draw_with_mask_filter(drawContext, context->textureProvider(), 247 sw_draw_with_mask_filter(drawContext, context->textureProvider(),
251 clip, viewMatrix, *devPathPtr, 248 clip, viewMatrix, *devPathPtr,
252 maskFilter, clipBounds, paint, style); 249 maskFilter, clipBounds, paint, style);
253 } 250 }
254 251
255 void GrBlurUtils::drawPathWithMaskFilter(GrContext* context, 252 void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
256 GrDrawContext* drawContext, 253 GrDrawContext* drawContext,
257 GrRenderTarget* rt, 254 GrRenderTarget* rt,
258 const GrClip& clip, 255 const GrClip& clip,
259 const SkPath& origPath, 256 const SkPath& origPath,
260 GrPaint* paint, 257 GrPaint* paint,
261 const SkMatrix& viewMatrix, 258 const SkMatrix& viewMatrix,
262 const SkMaskFilter* mf, 259 const SkMaskFilter* mf,
263 const SkPathEffect* pe, 260 const SkPathEffect* pathEffect,
264 const GrStrokeInfo& strokeInfo) { 261 const GrStrokeInfo& origStrokeInfo,
265 SkPath* path = const_cast<SkPath*>(&origPath); 262 bool pathIsMutable) {
266 draw_path_with_mask_filter(context, drawContext, rt, clip, paint, viewMatrix , mf, pe, 263 SkPath* pathPtr = const_cast<SkPath*>(&origPath);
267 strokeInfo, path, false); 264
265 SkTLazy<SkPath> tmpPath;
266 GrStrokeInfo strokeInfo(origStrokeInfo);
267
268 if (!strokeInfo.isDashed() && pathEffect && pathEffect->filterPath(tmpPath.i nit(), *pathPtr,
269 &strokeIn fo, nullptr)) {
270 pathPtr = tmpPath.get();
271 pathPtr->setIsVolatile(true);
272 pathIsMutable = true;
273 pathEffect = nullptr;
274 }
275
276 draw_path_with_mask_filter(context, drawContext, rt, clip, paint, viewMatrix , mf, pathEffect,
277 strokeInfo, pathPtr, pathIsMutable);
268 } 278 }
269 279
270 void GrBlurUtils::drawPathWithMaskFilter(GrContext* context, 280 void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
271 GrDrawContext* drawContext, 281 GrDrawContext* drawContext,
272 GrRenderTarget* renderTarget, 282 GrRenderTarget* renderTarget,
273 const GrClip& clip, 283 const GrClip& clip,
274 const SkPath& origSrcPath, 284 const SkPath& origSrcPath,
275 const SkPaint& paint, 285 const SkPaint& paint,
276 const SkMatrix& origViewMatrix, 286 const SkMatrix& origViewMatrix,
277 const SkMatrix* prePathMatrix, 287 const SkMatrix* prePathMatrix,
(...skipping 29 matching lines...) Expand all
307 } 317 }
308 // should I push prePathMatrix on our MV stack temporarily, instead 318 // should I push prePathMatrix on our MV stack temporarily, instead
309 // of applying it here? See SkDraw.cpp 319 // of applying it here? See SkDraw.cpp
310 pathPtr->transform(*prePathMatrix, result); 320 pathPtr->transform(*prePathMatrix, result);
311 pathPtr = result; 321 pathPtr = result;
312 } 322 }
313 } 323 }
314 // at this point we're done with prePathMatrix 324 // at this point we're done with prePathMatrix
315 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) 325 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;)
316 326
327 SkTLazy<SkPath> tmpPath2;
328
329 if (!strokeInfo.isDashed() && pathEffect &&
330 pathEffect->filterPath(tmpPath2.init(), *pathPtr, &strokeInfo, nullptr)) {
331 pathPtr = tmpPath2.get();
332 pathPtr->setIsVolatile(true);
333 pathIsMutable = true;
334 pathEffect = nullptr;
335 }
336
317 GrPaint grPaint; 337 GrPaint grPaint;
318 if (!SkPaintToGrPaint(context, paint, viewMatrix, &grPaint)) { 338 if (!SkPaintToGrPaint(context, paint, viewMatrix, &grPaint)) {
319 return; 339 return;
320 } 340 }
321 341
322 if (paint.getMaskFilter()) { 342 if (paint.getMaskFilter()) {
323 draw_path_with_mask_filter(context, drawContext, renderTarget, clip, &gr Paint, viewMatrix, 343 draw_path_with_mask_filter(context, drawContext, renderTarget, clip, &gr Paint, viewMatrix,
324 paint.getMaskFilter(), paint.getPathEffect(), strokeInfo, 344 paint.getMaskFilter(), pathEffect, strokeInfo ,
325 pathPtr, pathIsMutable); 345 pathPtr, pathIsMutable);
326 } else { 346 } else {
327 SkTLazy<SkPath> tmpPath2;
328 if (!strokeInfo.isDashed() && pathEffect &&
329 pathEffect->filterPath(tmpPath2.init(), *pathPtr, &strokeInfo, nullp tr)) {
330 pathPtr = tmpPath2.get();
331 pathPtr->setIsVolatile(true);
332 pathIsMutable = true;
333 }
334 drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo); 347 drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo);
335 } 348 }
336 } 349 }
337 350
OLDNEW
« no previous file with comments | « src/gpu/GrBlurUtils.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698