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

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 memory leak 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
« no previous file with comments | « src/core/SkMaskCache.cpp ('k') | src/effects/SkBlurMaskFilter.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 /* 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 SkScalar scaledSigma = matrix.mapRadius(rec.fSigma);
270 if (!SkMaskCache::FindAndCopy(scaledSigma, rec.fStyle, rec.fQuality,
reed1 2015/01/08 15:51:21 I think it will be easier to read if we change thi
qiankun 2015/01/12 04:36:26 Done.
271 rects, rectCount, &dstM)) {
272 if (!this->filterMask(&dstM, srcM, matrix, NULL)) {
273 return false;
274 }
275 SkMaskCache::AddAndCopy(scaledSigma, rec.fStyle, 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
reed1 2015/01/08 15:51:21 I'm afraid I still don't understand the scenario t
qiankun 2015/01/12 04:36:26 It was used to handle clipping bounds. Now, the ne
286 // size of the cached mask.
287 if (dstM.fBounds.width() != tmpDst.fBounds.width() ||
288 dstM.fBounds.height() != tmpDst.fBounds.height()) {
289 SkMask::FreeImage(dstM.fImage);
290 if (!this->filterMask(&dstM, srcM, matrix, NULL)) {
291 return false;
292 }
293 } else {
294 dstM.fBounds = tmpDst.fBounds;
295 }
296 }
297 } else {
298 if (!this->filterMask(&dstM, srcM, matrix, NULL)) {
299 return false;
300 }
268 } 301 }
302
269 SkAutoMaskFreeImage autoDst(dstM.fImage); 303 SkAutoMaskFreeImage autoDst(dstM.fImage);
270 304
271 // if we get here, we need to (possibly) resolve the clip and blitter 305 // if we get here, we need to (possibly) resolve the clip and blitter
272 SkAAClipBlitterWrapper wrapper(clip, blitter); 306 SkAAClipBlitterWrapper wrapper(clip, blitter);
273 blitter = wrapper.getBlitter(); 307 blitter = wrapper.getBlitter();
274 308
275 SkRegion::Cliperator clipper(wrapper.getRgn(), dstM.fBounds); 309 SkRegion::Cliperator clipper(wrapper.getRgn(), dstM.fBounds);
276 310
277 if (!clipper.done()) { 311 if (!clipper.done()) {
278 const SkIRect& cr = clipper.rect(); 312 const SkIRect& cr = clipper.rect();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 srcM.fRowBytes = 0; 377 srcM.fRowBytes = 0;
344 srcM.fFormat = SkMask::kA8_Format; 378 srcM.fFormat = SkMask::kA8_Format;
345 379
346 SkIPoint margin; // ignored 380 SkIPoint margin; // ignored
347 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) { 381 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) {
348 dst->set(dstM.fBounds); 382 dst->set(dstM.fBounds);
349 } else { 383 } else {
350 dst->set(srcM.fBounds); 384 dst->set(srcM.fBounds);
351 } 385 }
352 } 386 }
OLDNEW
« no previous file with comments | « src/core/SkMaskCache.cpp ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698