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

Side by Side Diff: src/effects/SkTestImageFilters.cpp

Issue 22438003: Move SkComposeImageFilter into its own {.h, .cpp} files (Closed) Base URL: http://skia.googlecode.com/svn/trunk
Patch Set: Fix nit Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkComposeImageFilter.cpp ('k') | src/ports/SkGlobalInitialization_default.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 #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 "SkFlattenableBuffers.h" 5 #include "SkFlattenableBuffers.h"
6 6
7 // Simple helper canvas that "takes ownership" of the provided device, so that 7 // Simple helper canvas that "takes ownership" of the provided device, so that
8 // when this canvas goes out of scope, so will its device. Could be replaced 8 // when this canvas goes out of scope, so will its device. Could be replaced
9 // with the following: 9 // with the following:
10 // 10 //
11 // SkCanvas canvas(device); 11 // SkCanvas canvas(device);
12 // SkAutoTUnref<SkDevice> aur(device); 12 // SkAutoTUnref<SkDevice> aur(device);
13 // 13 //
14 class OwnDeviceCanvas : public SkCanvas { 14 class OwnDeviceCanvas : public SkCanvas {
15 public: 15 public:
16 OwnDeviceCanvas(SkDevice* device) : SkCanvas(device) { 16 OwnDeviceCanvas(SkDevice* device) : SkCanvas(device) {
17 SkSafeUnref(device); 17 SkSafeUnref(device);
18 } 18 }
19 }; 19 };
20 20
21 /////////////////////////////////////////////////////////////////////////////// 21 ///////////////////////////////////////////////////////////////////////////////
22 22
23 SkComposeImageFilter::~SkComposeImageFilter() {
24 }
25
26 bool SkComposeImageFilter::onFilterImage(Proxy* proxy,
27 const SkBitmap& src,
28 const SkMatrix& ctm,
29 SkBitmap* result,
30 SkIPoint* loc) {
31 SkImageFilter* outer = getInput(0);
32 SkImageFilter* inner = getInput(1);
33
34 if (!outer && !inner) {
35 return false;
36 }
37
38 if (!outer || !inner) {
39 return (outer ? outer : inner)->filterImage(proxy, src, ctm, result, loc );
40 }
41
42 SkBitmap tmp;
43 return inner->filterImage(proxy, src, ctm, &tmp, loc) &&
44 outer->filterImage(proxy, tmp, ctm, result, loc);
45 }
46
47 bool SkComposeImageFilter::onFilterBounds(const SkIRect& src,
48 const SkMatrix& ctm,
49 SkIRect* dst) {
50 SkImageFilter* outer = getInput(0);
51 SkImageFilter* inner = getInput(1);
52
53 if (!outer && !inner) {
54 return false;
55 }
56
57 if (!outer || !inner) {
58 return (outer ? outer : inner)->filterBounds(src, ctm, dst);
59 }
60
61 SkIRect tmp;
62 return inner->filterBounds(src, ctm, &tmp) &&
63 outer->filterBounds(tmp, ctm, dst);
64 }
65
66 SkComposeImageFilter::SkComposeImageFilter(SkFlattenableReadBuffer& buffer) : IN HERITED(buffer) {
67 }
68
69 ///////////////////////////////////////////////////////////////////////////////
70
71 bool SkDownSampleImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, 23 bool SkDownSampleImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
72 const SkMatrix&, 24 const SkMatrix&,
73 SkBitmap* result, SkIPoint*) { 25 SkBitmap* result, SkIPoint*) {
74 SkScalar scale = fScale; 26 SkScalar scale = fScale;
75 if (scale > SK_Scalar1 || scale <= 0) { 27 if (scale > SK_Scalar1 || scale <= 0) {
76 return false; 28 return false;
77 } 29 }
78 30
79 int dstW = SkScalarRoundToInt(src.width() * scale); 31 int dstW = SkScalarRoundToInt(src.width() * scale);
80 int dstH = SkScalarRoundToInt(src.height() * scale); 32 int dstH = SkScalarRoundToInt(src.height() * scale);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 72
121 void SkDownSampleImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { 73 void SkDownSampleImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
122 this->INHERITED::flatten(buffer); 74 this->INHERITED::flatten(buffer);
123 75
124 buffer.writeScalar(fScale); 76 buffer.writeScalar(fScale);
125 } 77 }
126 78
127 SkDownSampleImageFilter::SkDownSampleImageFilter(SkFlattenableReadBuffer& buffer ) : INHERITED(buffer) { 79 SkDownSampleImageFilter::SkDownSampleImageFilter(SkFlattenableReadBuffer& buffer ) : INHERITED(buffer) {
128 fScale = buffer.readScalar(); 80 fScale = buffer.readScalar();
129 } 81 }
OLDNEW
« no previous file with comments | « src/effects/SkComposeImageFilter.cpp ('k') | src/ports/SkGlobalInitialization_default.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698