OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkTestImageFilters.h" | 8 #include "SkTestImageFilters.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
11 #include "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
12 #include "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" |
13 | 13 |
14 // Simple helper canvas that "takes ownership" of the provided device, so that | 14 // Simple helper canvas that "takes ownership" of the provided device, so that |
15 // when this canvas goes out of scope, so will its device. Could be replaced | 15 // when this canvas goes out of scope, so will its device. Could be replaced |
16 // with the following: | 16 // with the following: |
17 // | 17 // |
18 // SkCanvas canvas(device); | 18 // SkCanvas canvas(device); |
19 // SkAutoTUnref<SkBaseDevice> aur(device); | 19 // SkAutoTUnref<SkBaseDevice> aur(device); |
20 // | 20 // |
21 class OwnDeviceCanvas : public SkCanvas { | 21 class OwnDeviceCanvas : public SkCanvas { |
22 public: | 22 public: |
23 OwnDeviceCanvas(SkBaseDevice* device) : SkCanvas(device) { | 23 OwnDeviceCanvas(SkBaseDevice* device) : SkCanvas(device) { |
24 SkSafeUnref(device); | 24 SkSafeUnref(device); |
25 } | 25 } |
26 }; | 26 }; |
27 | 27 |
28 /////////////////////////////////////////////////////////////////////////////// | 28 /////////////////////////////////////////////////////////////////////////////// |
29 | 29 |
30 bool SkDownSampleImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, | 30 bool SkDownSampleImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBitm
ap& src, |
31 const Context&, | 31 const Context&, |
32 SkBitmap* result, SkIPoint*) const { | 32 SkBitmap* result, SkIPoint
*) const { |
33 SkScalar scale = fScale; | 33 SkScalar scale = fScale; |
34 if (scale > SK_Scalar1 || scale <= 0) { | 34 if (scale > SK_Scalar1 || scale <= 0) { |
35 return false; | 35 return false; |
36 } | 36 } |
37 | 37 |
38 int dstW = SkScalarRoundToInt(src.width() * scale); | 38 int dstW = SkScalarRoundToInt(src.width() * scale); |
39 int dstH = SkScalarRoundToInt(src.height() * scale); | 39 int dstH = SkScalarRoundToInt(src.height() * scale); |
40 if (dstW < 1) { | 40 if (dstW < 1) { |
41 dstW = 1; | 41 dstW = 1; |
42 } | 42 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 this->INHERITED::flatten(buffer); | 84 this->INHERITED::flatten(buffer); |
85 buffer.writeScalar(fScale); | 85 buffer.writeScalar(fScale); |
86 } | 86 } |
87 | 87 |
88 #ifndef SK_IGNORE_TO_STRING | 88 #ifndef SK_IGNORE_TO_STRING |
89 void SkDownSampleImageFilter::toString(SkString* str) const { | 89 void SkDownSampleImageFilter::toString(SkString* str) const { |
90 str->appendf("SkDownSampleImageFilter: ("); | 90 str->appendf("SkDownSampleImageFilter: ("); |
91 str->append(")"); | 91 str->append(")"); |
92 } | 92 } |
93 #endif | 93 #endif |
OLD | NEW |