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

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

Issue 1486923004: Retract GrRenderTarget a bit (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/GrDrawTarget.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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // Draw the mask into maskTexture with the path's integerized top-left at 141 // Draw the mask into maskTexture with the path's integerized top-left at
142 // the origin using tempPaint. 142 // the origin using tempPaint.
143 SkMatrix translate; 143 SkMatrix translate;
144 translate.setTranslate(-maskRect->fLeft, -maskRect->fTop); 144 translate.setTranslate(-maskRect->fLeft, -maskRect->fTop);
145 drawContext->drawPath(clip, tempPaint, translate, devPath, strokeInfo); 145 drawContext->drawPath(clip, tempPaint, translate, devPath, strokeInfo);
146 return mask; 146 return mask;
147 } 147 }
148 148
149 static void draw_path_with_mask_filter(GrContext* context, 149 static void draw_path_with_mask_filter(GrContext* context,
150 GrDrawContext* drawContext, 150 GrDrawContext* drawContext,
151 GrRenderTarget* renderTarget,
152 const GrClip& clip, 151 const GrClip& clip,
153 GrPaint* paint, 152 GrPaint* paint,
154 const SkMatrix& viewMatrix, 153 const SkMatrix& viewMatrix,
155 const SkMaskFilter* maskFilter, 154 const SkMaskFilter* maskFilter,
156 const SkPathEffect* pathEffect, 155 const SkPathEffect* pathEffect,
157 const GrStrokeInfo& origStrokeInfo, 156 const GrStrokeInfo& origStrokeInfo,
158 SkPath* pathPtr, 157 SkPath* pathPtr,
159 bool pathIsMutable) { 158 bool pathIsMutable) {
160 SkASSERT(maskFilter); 159 SkASSERT(maskFilter);
161 160
162 SkIRect clipBounds; 161 SkIRect clipBounds;
163 clip.getConservativeBounds(renderTarget, &clipBounds); 162 clip.getConservativeBounds(drawContext->width(), drawContext->height(), &cli pBounds);
164 SkTLazy<SkPath> tmpPath; 163 SkTLazy<SkPath> tmpPath;
165 GrStrokeInfo strokeInfo(origStrokeInfo); 164 GrStrokeInfo strokeInfo(origStrokeInfo);
166 165
167 static const SkRect* cullRect = nullptr; // TODO: what is our bounds? 166 static const SkRect* cullRect = nullptr; // TODO: what is our bounds?
168 167
169 SkASSERT(strokeInfo.isDashed() || !pathEffect); 168 SkASSERT(strokeInfo.isDashed() || !pathEffect);
170 169
171 if (!strokeInfo.isHairlineStyle()) { 170 if (!strokeInfo.isHairlineStyle()) {
172 SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init(); 171 SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init();
173 if (strokeInfo.isDashed()) { 172 if (strokeInfo.isDashed()) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // the mask filter was able to draw itself directly, so there's noth ing 217 // the mask filter was able to draw itself directly, so there's noth ing
219 // left to do. 218 // left to do.
220 return; 219 return;
221 } 220 }
222 221
223 SkAutoTUnref<GrTexture> mask(create_mask_GPU(context, 222 SkAutoTUnref<GrTexture> mask(create_mask_GPU(context,
224 &maskRect, 223 &maskRect,
225 *devPathPtr, 224 *devPathPtr,
226 strokeInfo, 225 strokeInfo,
227 paint->isAntiAlias(), 226 paint->isAntiAlias(),
228 renderTarget->numColorSampl es())); 227 drawContext->numColorSample s()));
229 if (mask) { 228 if (mask) {
230 GrTexture* filtered; 229 GrTexture* filtered;
231 230
232 if (maskFilter->filterMaskGPU(mask, viewMatrix, maskRect, &filtered, true)) { 231 if (maskFilter->filterMaskGPU(mask, viewMatrix, maskRect, &filtered, true)) {
233 // filterMaskGPU gives us ownership of a ref to the result 232 // filterMaskGPU gives us ownership of a ref to the result
234 SkAutoTUnref<GrTexture> atu(filtered); 233 SkAutoTUnref<GrTexture> atu(filtered);
235 if (draw_mask(drawContext, clip, viewMatrix, maskRect, paint, fi ltered)) { 234 if (draw_mask(drawContext, clip, viewMatrix, maskRect, paint, fi ltered)) {
236 // This path is completely drawn 235 // This path is completely drawn
237 return; 236 return;
238 } 237 }
239 } 238 }
240 } 239 }
241 } 240 }
242 241
243 // draw the mask on the CPU - this is a fallthrough path in case the 242 // draw the mask on the CPU - this is a fallthrough path in case the
244 // GPU path fails 243 // GPU path fails
245 SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_Style : 244 SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_Style :
246 SkPaint::kFill_Style; 245 SkPaint::kFill_Style;
247 sw_draw_with_mask_filter(drawContext, context->textureProvider(), 246 sw_draw_with_mask_filter(drawContext, context->textureProvider(),
248 clip, viewMatrix, *devPathPtr, 247 clip, viewMatrix, *devPathPtr,
249 maskFilter, clipBounds, paint, style); 248 maskFilter, clipBounds, paint, style);
250 } 249 }
251 250
252 void GrBlurUtils::drawPathWithMaskFilter(GrContext* context, 251 void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
253 GrDrawContext* drawContext, 252 GrDrawContext* drawContext,
254 GrRenderTarget* rt,
255 const GrClip& clip, 253 const GrClip& clip,
256 const SkPath& origPath, 254 const SkPath& origPath,
257 GrPaint* paint, 255 GrPaint* paint,
258 const SkMatrix& viewMatrix, 256 const SkMatrix& viewMatrix,
259 const SkMaskFilter* mf, 257 const SkMaskFilter* mf,
260 const SkPathEffect* pathEffect, 258 const SkPathEffect* pathEffect,
261 const GrStrokeInfo& origStrokeInfo, 259 const GrStrokeInfo& origStrokeInfo,
262 bool pathIsMutable) { 260 bool pathIsMutable) {
263 SkPath* pathPtr = const_cast<SkPath*>(&origPath); 261 SkPath* pathPtr = const_cast<SkPath*>(&origPath);
264 262
265 SkTLazy<SkPath> tmpPath; 263 SkTLazy<SkPath> tmpPath;
266 GrStrokeInfo strokeInfo(origStrokeInfo); 264 GrStrokeInfo strokeInfo(origStrokeInfo);
267 265
268 if (!strokeInfo.isDashed() && pathEffect && pathEffect->filterPath(tmpPath.i nit(), *pathPtr, 266 if (!strokeInfo.isDashed() && pathEffect && pathEffect->filterPath(tmpPath.i nit(), *pathPtr,
269 &strokeIn fo, nullptr)) { 267 &strokeIn fo, nullptr)) {
270 pathPtr = tmpPath.get(); 268 pathPtr = tmpPath.get();
271 pathPtr->setIsVolatile(true); 269 pathPtr->setIsVolatile(true);
272 pathIsMutable = true; 270 pathIsMutable = true;
273 pathEffect = nullptr; 271 pathEffect = nullptr;
274 } 272 }
275 273
276 draw_path_with_mask_filter(context, drawContext, rt, clip, paint, viewMatrix , mf, pathEffect, 274 draw_path_with_mask_filter(context, drawContext, clip, paint, viewMatrix, mf , pathEffect,
277 strokeInfo, pathPtr, pathIsMutable); 275 strokeInfo, pathPtr, pathIsMutable);
278 } 276 }
279 277
280 void GrBlurUtils::drawPathWithMaskFilter(GrContext* context, 278 void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
281 GrDrawContext* drawContext, 279 GrDrawContext* drawContext,
282 GrRenderTarget* renderTarget,
283 const GrClip& clip, 280 const GrClip& clip,
284 const SkPath& origSrcPath, 281 const SkPath& origSrcPath,
285 const SkPaint& paint, 282 const SkPaint& paint,
286 const SkMatrix& origViewMatrix, 283 const SkMatrix& origViewMatrix,
287 const SkMatrix* prePathMatrix, 284 const SkMatrix* prePathMatrix,
288 const SkIRect& clipBounds, 285 const SkIRect& clipBounds,
289 bool pathIsMutable) { 286 bool pathIsMutable) {
290 SkASSERT(!pathIsMutable || origSrcPath.isVolatile()); 287 SkASSERT(!pathIsMutable || origSrcPath.isVolatile());
291 288
292 GrStrokeInfo strokeInfo(paint); 289 GrStrokeInfo strokeInfo(paint);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 pathIsMutable = true; 330 pathIsMutable = true;
334 pathEffect = nullptr; 331 pathEffect = nullptr;
335 } 332 }
336 333
337 GrPaint grPaint; 334 GrPaint grPaint;
338 if (!SkPaintToGrPaint(context, paint, viewMatrix, &grPaint)) { 335 if (!SkPaintToGrPaint(context, paint, viewMatrix, &grPaint)) {
339 return; 336 return;
340 } 337 }
341 338
342 if (paint.getMaskFilter()) { 339 if (paint.getMaskFilter()) {
343 draw_path_with_mask_filter(context, drawContext, renderTarget, clip, &gr Paint, viewMatrix, 340 draw_path_with_mask_filter(context, drawContext, clip, &grPaint, viewMat rix,
344 paint.getMaskFilter(), pathEffect, strokeInfo , 341 paint.getMaskFilter(), pathEffect, strokeInfo ,
345 pathPtr, pathIsMutable); 342 pathPtr, pathIsMutable);
346 } else { 343 } else {
347 drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo); 344 drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo);
348 } 345 }
349 } 346 }
350 347
OLDNEW
« no previous file with comments | « src/gpu/GrBlurUtils.h ('k') | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698