OLD | NEW |
1 | 1 |
2 #include "SkTestImageFilters.h" | 2 #include "SkTestImageFilters.h" |
3 #include "SkCanvas.h" | 3 #include "SkCanvas.h" |
4 #include "SkDevice.h" | 4 #include "SkDevice.h" |
5 #include "SkReadBuffer.h" | 5 #include "SkReadBuffer.h" |
6 #include "SkWriteBuffer.h" | 6 #include "SkWriteBuffer.h" |
7 | 7 |
8 // Simple helper canvas that "takes ownership" of the provided device, so that | 8 // Simple helper canvas that "takes ownership" of the provided device, so that |
9 // when this canvas goes out of scope, so will its device. Could be replaced | 9 // when this canvas goes out of scope, so will its device. Could be replaced |
10 // with the following: | 10 // with the following: |
11 // | 11 // |
12 // SkCanvas canvas(device); | 12 // SkCanvas canvas(device); |
13 // SkAutoTUnref<SkBaseDevice> aur(device); | 13 // SkAutoTUnref<SkBaseDevice> aur(device); |
14 // | 14 // |
15 class OwnDeviceCanvas : public SkCanvas { | 15 class OwnDeviceCanvas : public SkCanvas { |
16 public: | 16 public: |
17 OwnDeviceCanvas(SkBaseDevice* device) : SkCanvas(device) { | 17 OwnDeviceCanvas(SkBaseDevice* device) : SkCanvas(device) { |
18 SkSafeUnref(device); | 18 SkSafeUnref(device); |
19 } | 19 } |
20 }; | 20 }; |
21 | 21 |
22 /////////////////////////////////////////////////////////////////////////////// | 22 /////////////////////////////////////////////////////////////////////////////// |
23 | 23 |
24 bool SkDownSampleImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, | 24 bool SkDownSampleImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, |
25 const SkMatrix&, | 25 const Context&, |
26 SkBitmap* result, SkIPoint*) const { | 26 SkBitmap* result, SkIPoint*) const { |
27 SkScalar scale = fScale; | 27 SkScalar scale = fScale; |
28 if (scale > SK_Scalar1 || scale <= 0) { | 28 if (scale > SK_Scalar1 || scale <= 0) { |
29 return false; | 29 return false; |
30 } | 30 } |
31 | 31 |
32 int dstW = SkScalarRoundToInt(src.width() * scale); | 32 int dstW = SkScalarRoundToInt(src.width() * scale); |
33 int dstH = SkScalarRoundToInt(src.height() * scale); | 33 int dstH = SkScalarRoundToInt(src.height() * scale); |
34 if (dstW < 1) { | 34 if (dstW < 1) { |
35 dstW = 1; | 35 dstW = 1; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 this->INHERITED::flatten(buffer); | 75 this->INHERITED::flatten(buffer); |
76 | 76 |
77 buffer.writeScalar(fScale); | 77 buffer.writeScalar(fScale); |
78 } | 78 } |
79 | 79 |
80 SkDownSampleImageFilter::SkDownSampleImageFilter(SkReadBuffer& buffer) | 80 SkDownSampleImageFilter::SkDownSampleImageFilter(SkReadBuffer& buffer) |
81 : INHERITED(1, buffer) { | 81 : INHERITED(1, buffer) { |
82 fScale = buffer.readScalar(); | 82 fScale = buffer.readScalar(); |
83 buffer.validate(SkScalarIsFinite(fScale)); | 83 buffer.validate(SkScalarIsFinite(fScale)); |
84 } | 84 } |
OLD | NEW |