OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkPaintImageFilter.h" | 8 #include "SkPaintImageFilter.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
11 #include "SkSpecialImage.h" | 11 #include "SkSpecialImage.h" |
12 #include "SkSpecialSurface.h" | 12 #include "SkSpecialSurface.h" |
13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
14 | 14 |
| 15 SkImageFilter* SkPaintImageFilter::Create(const SkPaint& paint, const CropRect*
cropRect) { |
| 16 return new SkPaintImageFilter(paint, cropRect); |
| 17 } |
| 18 |
15 SkPaintImageFilter::SkPaintImageFilter(const SkPaint& paint, const CropRect* cro
pRect) | 19 SkPaintImageFilter::SkPaintImageFilter(const SkPaint& paint, const CropRect* cro
pRect) |
16 : INHERITED(nullptr, 0, cropRect) | 20 : INHERITED(0, nullptr, cropRect) |
17 , fPaint(paint) { | 21 , fPaint(paint) { |
18 } | 22 } |
19 | 23 |
20 SkFlattenable* SkPaintImageFilter::CreateProc(SkReadBuffer& buffer) { | 24 SkFlattenable* SkPaintImageFilter::CreateProc(SkReadBuffer& buffer) { |
21 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); | 25 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); |
22 SkPaint paint; | 26 SkPaint paint; |
23 buffer.readPaint(&paint); | 27 buffer.readPaint(&paint); |
24 return SkPaintImageFilter::Make(paint, &common.cropRect()).release(); | 28 return Create(paint, &common.cropRect()); |
25 } | 29 } |
26 | 30 |
27 void SkPaintImageFilter::flatten(SkWriteBuffer& buffer) const { | 31 void SkPaintImageFilter::flatten(SkWriteBuffer& buffer) const { |
28 this->INHERITED::flatten(buffer); | 32 this->INHERITED::flatten(buffer); |
29 buffer.writePaint(fPaint); | 33 buffer.writePaint(fPaint); |
30 } | 34 } |
31 | 35 |
32 sk_sp<SkSpecialImage> SkPaintImageFilter::onFilterImage(SkSpecialImage* source, | 36 sk_sp<SkSpecialImage> SkPaintImageFilter::onFilterImage(SkSpecialImage* source, |
33 const Context& ctx, | 37 const Context& ctx, |
34 SkIPoint* offset) const
{ | 38 SkIPoint* offset) const
{ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 bool SkPaintImageFilter::canComputeFastBounds() const { | 73 bool SkPaintImageFilter::canComputeFastBounds() const { |
70 // http:skbug.com/4627: "make computeFastBounds and onFilterBounds() CropRec
t-aware" | 74 // http:skbug.com/4627: "make computeFastBounds and onFilterBounds() CropRec
t-aware" |
71 // computeFastBounds() doesn't currently take the crop rect into account, | 75 // computeFastBounds() doesn't currently take the crop rect into account, |
72 // so we can't compute it. If a full crop rect is set, we should return true
here. | 76 // so we can't compute it. If a full crop rect is set, we should return true
here. |
73 return false; | 77 return false; |
74 } | 78 } |
75 | 79 |
76 #ifndef SK_IGNORE_TO_STRING | 80 #ifndef SK_IGNORE_TO_STRING |
77 void SkPaintImageFilter::toString(SkString* str) const { | 81 void SkPaintImageFilter::toString(SkString* str) const { |
78 str->appendf("SkPaintImageFilter: ("); | 82 str->appendf("SkPaintImageFilter: ("); |
79 fPaint.toString(str); | |
80 str->append(")"); | 83 str->append(")"); |
81 } | 84 } |
82 #endif | 85 #endif |
OLD | NEW |