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

Side by Side Diff: src/core/SkMaskFilter.cpp

Issue 729463002: Cache blur mask for rects which can not break into nine-patch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: formatting Created 5 years, 11 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkMaskFilter.h" 10 #include "SkMaskFilter.h"
11 #include "SkBlitter.h" 11 #include "SkBlitter.h"
12 #include "SkDraw.h" 12 #include "SkDraw.h"
13 #include "SkMaskCache.h"
13 #include "SkRasterClip.h" 14 #include "SkRasterClip.h"
14 #include "SkRRect.h" 15 #include "SkRRect.h"
15 #include "SkTypes.h" 16 #include "SkTypes.h"
16 17
17 #if SK_SUPPORT_GPU 18 #if SK_SUPPORT_GPU
18 #include "GrTexture.h" 19 #include "GrTexture.h"
19 #include "SkGr.h" 20 #include "SkGr.h"
20 #include "SkGrPixelRef.h" 21 #include "SkGrPixelRef.h"
21 #endif 22 #endif
22 23
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 257
257 SkMask srcM, dstM; 258 SkMask srcM, dstM;
258 259
259 if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), this, &matrix, &srcM, 260 if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), this, &matrix, &srcM,
260 SkMask::kComputeBoundsAndRenderImage_CreateMode, 261 SkMask::kComputeBoundsAndRenderImage_CreateMode,
261 style)) { 262 style)) {
262 return false; 263 return false;
263 } 264 }
264 SkAutoMaskFreeImage autoSrc(srcM.fImage); 265 SkAutoMaskFreeImage autoSrc(srcM.fImage);
265 266
266 if (!this->filterMask(&dstM, srcM, matrix, NULL)) { 267 BlurRec rec;
267 return false; 268 if (this->asABlur(&rec) && rectCount) {
269 if (!SkMaskCache::FindAndCopy(matrix.mapRadius(rec.fSigma), rec.fStyle,
reed1 2015/01/07 16:45:46 nit: tmp variable caching the computed radius? Sk
qiankun 2015/01/08 03:01:12 Done.
270 rec.fQuality, rects, rectCount, &dstM)) {
271 if (!this->filterMask(&dstM, srcM, matrix, NULL)) {
272 return false;
273 }
274 SkMaskCache::AddAndCopy(matrix.mapRadius(rec.fSigma), rec.fStyle,
275 rec.fQuality, rects, rectCount, dstM);
276 } else {
277 // Compute the correct bounds of dst mask if dst mask is got from ca che.
278 SkMask tmpSrc, tmpDst;
279 tmpSrc = srcM;
280 tmpSrc.fImage = NULL;
281 if (!this->filterMask(&tmpDst, tmpSrc, matrix, NULL)) {
282 return false;
283 }
284
285 // Fallback to original calculation if size of bounds is different w ith
286 // size of the cached mask.
287 if (dstM.fBounds.width() != tmpDst.fBounds.width() ||
288 dstM.fBounds.height() != tmpDst.fBounds.height()) {
289 if (this->filterMask(&dstM, srcM, matrix, NULL)) {
290 return false;
291 }
292 } else {
293 dstM.fBounds = tmpDst.fBounds;
294 }
295 }
296 } else {
297 if (!this->filterMask(&dstM, srcM, matrix, NULL)) {
298 return false;
299 }
268 } 300 }
301
269 SkAutoMaskFreeImage autoDst(dstM.fImage); 302 SkAutoMaskFreeImage autoDst(dstM.fImage);
270 303
271 // if we get here, we need to (possibly) resolve the clip and blitter 304 // if we get here, we need to (possibly) resolve the clip and blitter
272 SkAAClipBlitterWrapper wrapper(clip, blitter); 305 SkAAClipBlitterWrapper wrapper(clip, blitter);
273 blitter = wrapper.getBlitter(); 306 blitter = wrapper.getBlitter();
274 307
275 SkRegion::Cliperator clipper(wrapper.getRgn(), dstM.fBounds); 308 SkRegion::Cliperator clipper(wrapper.getRgn(), dstM.fBounds);
276 309
277 if (!clipper.done()) { 310 if (!clipper.done()) {
278 const SkIRect& cr = clipper.rect(); 311 const SkIRect& cr = clipper.rect();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 srcM.fRowBytes = 0; 376 srcM.fRowBytes = 0;
344 srcM.fFormat = SkMask::kA8_Format; 377 srcM.fFormat = SkMask::kA8_Format;
345 378
346 SkIPoint margin; // ignored 379 SkIPoint margin; // ignored
347 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) { 380 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) {
348 dst->set(dstM.fBounds); 381 dst->set(dstM.fBounds);
349 } else { 382 } else {
350 dst->set(srcM.fBounds); 383 dst->set(srcM.fBounds);
351 } 384 }
352 } 385 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698