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

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: fix edge artifacts Created 6 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
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)
269 || !rectCount
reed1 2014/12/22 21:38:16 This 4-part predicate may be correct, but it is pr
qiankun 2014/12/23 10:54:32 What about the latest implementation?
270 || (this->asABlur(&rec) && !SkMaskCache::FindCachedRects(&dstM, matrix.m apRadius(rec.fSigma), rec.fStyle,
271 rec.fQuality, r ects, rectCount))) {
272 if (!this->filterMask(&dstM, srcM, matrix, NULL)) {
273 return false;
274 }
275 if (this->asABlur(&rec) && rectCount) {
276 SkMaskCache::AddCachedRects(dstM, matrix.mapRadius(rec.fSigma), rec. fStyle, rec.fQuality, rects, rectCount);
277 }
278 } else {
279 // Compute the correct bounds of dst mask if dst mask is got from cache.
280 SkMask tmpSrc, tmpDst;
281 tmpSrc = srcM;
282 tmpSrc.fImage = NULL;
283 if (!this->filterMask(&tmpDst, tmpSrc, matrix, NULL)) {
284 return false;
285 }
286
287 // Fallback to original calculation if size of bounds is different with size of the cached mask.
288 if (dstM.fBounds.width() != tmpDst.fBounds.width() || dstM.fBounds.heigh t() != tmpDst.fBounds.height()) {
289 this->filterMask(&dstM, srcM, matrix, NULL);
290 } else {
291 dstM.fBounds = tmpDst.fBounds;
292 }
268 } 293 }
294
269 SkAutoMaskFreeImage autoDst(dstM.fImage); 295 SkAutoMaskFreeImage autoDst(dstM.fImage);
270 296
271 // if we get here, we need to (possibly) resolve the clip and blitter 297 // if we get here, we need to (possibly) resolve the clip and blitter
272 SkAAClipBlitterWrapper wrapper(clip, blitter); 298 SkAAClipBlitterWrapper wrapper(clip, blitter);
273 blitter = wrapper.getBlitter(); 299 blitter = wrapper.getBlitter();
274 300
275 SkRegion::Cliperator clipper(wrapper.getRgn(), dstM.fBounds); 301 SkRegion::Cliperator clipper(wrapper.getRgn(), dstM.fBounds);
276 302
277 if (!clipper.done()) { 303 if (!clipper.done()) {
278 const SkIRect& cr = clipper.rect(); 304 const SkIRect& cr = clipper.rect();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 srcM.fRowBytes = 0; 367 srcM.fRowBytes = 0;
342 srcM.fFormat = SkMask::kA8_Format; 368 srcM.fFormat = SkMask::kA8_Format;
343 369
344 SkIPoint margin; // ignored 370 SkIPoint margin; // ignored
345 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) { 371 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) {
346 dst->set(dstM.fBounds); 372 dst->set(dstM.fBounds);
347 } else { 373 } else {
348 dst->set(srcM.fBounds); 374 dst->set(srcM.fBounds);
349 } 375 }
350 } 376 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698