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

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

Issue 48623006: Add ability to ninepatch blurred rounded rectangle (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
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 "SkBounder.h" 12 #include "SkBounder.h"
13 #include "SkDraw.h" 13 #include "SkDraw.h"
14 #include "SkRasterClip.h" 14 #include "SkRasterClip.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
23 SK_DEFINE_INST_COUNT(SkMaskFilter) 24 SK_DEFINE_INST_COUNT(SkMaskFilter)
24 25
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 198 }
198 } 199 }
199 200
200 static int countNestedRects(const SkPath& path, SkRect rects[2]) { 201 static int countNestedRects(const SkPath& path, SkRect rects[2]) {
201 if (path.isNestedRects(rects)) { 202 if (path.isNestedRects(rects)) {
202 return 2; 203 return 2;
203 } 204 }
204 return path.isRect(&rects[0]); 205 return path.isRect(&rects[0]);
205 } 206 }
206 207
208 bool SkMaskFilter::filterRRect(const SkRRect& devRRect, const SkMatrix& matrix,
209 const SkRasterClip& clip, SkBounder* bounder,
210 SkBlitter* blitter, SkPaint::Style style) const {
robertphillips 2013/10/31 00:24:58 Could you expand on what makes this case sneaky?
scroggo 2013/11/01 21:45:46 Done.
211 // Only handle the sneaky case:
212 NinePatch patch;
213 patch.fMask.fImage = NULL;
214 if (kTrue_FilterReturn != this->filterRRectToNine(devRRect, matrix,
215 clip.getBounds(),
216 &patch)) {
217 return false;
218 }
219 draw_nine(patch.fMask, patch.fOuterRect, patch.fCenter, true, clip,
220 bounder, blitter);
221 SkMask::FreeImage(patch.fMask.fImage);
222 return true;
223 }
224
207 bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix, 225 bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
208 const SkRasterClip& clip, SkBounder* bounder, 226 const SkRasterClip& clip, SkBounder* bounder,
209 SkBlitter* blitter, SkPaint::Style style) const { 227 SkBlitter* blitter, SkPaint::Style style) const {
210 SkRect rects[2]; 228 SkRect rects[2];
211 int rectCount = 0; 229 int rectCount = 0;
212 if (SkPaint::kFill_Style == style) { 230 if (SkPaint::kFill_Style == style) {
213 rectCount = countNestedRects(devPath, rects); 231 rectCount = countNestedRects(devPath, rects);
214 } 232 }
215 if (rectCount > 0) { 233 if (rectCount > 0) {
216 NinePatch patch; 234 NinePatch patch;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 do { 278 do {
261 blitter->blitMask(dstM, cr); 279 blitter->blitMask(dstM, cr);
262 clipper.next(); 280 clipper.next();
263 } while (!clipper.done()); 281 } while (!clipper.done());
264 } 282 }
265 283
266 return true; 284 return true;
267 } 285 }
268 286
269 SkMaskFilter::FilterReturn 287 SkMaskFilter::FilterReturn
288 SkMaskFilter::filterRRectToNine(const SkRRect&, const SkMatrix&,
289 const SkIRect& clipBounds, NinePatch*) const {
290 return kUnimplemented_FilterReturn;
291 }
292
293 SkMaskFilter::FilterReturn
270 SkMaskFilter::filterRectsToNine(const SkRect[], int count, const SkMatrix&, 294 SkMaskFilter::filterRectsToNine(const SkRect[], int count, const SkMatrix&,
271 const SkIRect& clipBounds, NinePatch*) const { 295 const SkIRect& clipBounds, NinePatch*) const {
272 return kUnimplemented_FilterReturn; 296 return kUnimplemented_FilterReturn;
273 } 297 }
274 298
275 #if SK_SUPPORT_GPU 299 #if SK_SUPPORT_GPU
276 bool SkMaskFilter::asNewEffect(GrEffectRef** effect, GrTexture*) const { 300 bool SkMaskFilter::asNewEffect(GrEffectRef** effect, GrTexture*) const {
277 return false; 301 return false;
278 } 302 }
279 303
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 srcM.fRowBytes = 0; 371 srcM.fRowBytes = 0;
348 srcM.fFormat = SkMask::kA8_Format; 372 srcM.fFormat = SkMask::kA8_Format;
349 373
350 SkIPoint margin; // ignored 374 SkIPoint margin; // ignored
351 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) { 375 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) {
352 dst->set(dstM.fBounds); 376 dst->set(dstM.fBounds);
353 } else { 377 } else {
354 dst->set(srcM.fBounds); 378 dst->set(srcM.fBounds);
355 } 379 }
356 } 380 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698