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

Side by Side Diff: gm/imagefiltersgraph.cpp

Issue 789163006: Add toString methods to SkImageFilter-derived classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make sure leading 0's aren't stripped off colors Created 6 years 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
« no previous file with comments | « gm/imagefiltersbase.cpp ('k') | include/core/SkImageFilter.h » ('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 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "gm.h" 8 #include "gm.h"
9 9
10 #include "SkArithmeticMode.h" 10 #include "SkArithmeticMode.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 SkCanvas canvas(device); 55 SkCanvas canvas(device);
56 SkPaint paint; 56 SkPaint paint;
57 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 57 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
58 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain t); 58 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain t);
59 *dst = device->accessBitmap(false); 59 *dst = device->accessBitmap(false);
60 offset->fX += bounds.left(); 60 offset->fX += bounds.left();
61 offset->fY += bounds.top(); 61 offset->fY += bounds.top();
62 return true; 62 return true;
63 } 63 }
64 64
65 SK_TO_STRING_OVERRIDE()
65 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter); 66 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter);
66 67
67 protected: 68 protected:
68 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { 69 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
69 this->INHERITED::flatten(buffer); 70 this->INHERITED::flatten(buffer);
70 buffer.writeScalar(fDX); 71 buffer.writeScalar(fDX);
71 buffer.writeScalar(fDY); 72 buffer.writeScalar(fDY);
72 } 73 }
73 74
74 private: 75 private:
75 SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input) 76 SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input)
76 : SkImageFilter(1, &input), fDX(dx), fDY(dy) {} 77 : SkImageFilter(1, &input), fDX(dx), fDY(dy) {}
77 78
78 SkScalar fDX, fDY; 79 SkScalar fDX, fDY;
79 80
80 typedef SkImageFilter INHERITED; 81 typedef SkImageFilter INHERITED;
81 }; 82 };
82 83
83 static SimpleOffsetFilter::Registrar gReg; 84 static SimpleOffsetFilter::Registrar gReg;
84 85
85 SkFlattenable* SimpleOffsetFilter::CreateProc(SkReadBuffer& buffer) { 86 SkFlattenable* SimpleOffsetFilter::CreateProc(SkReadBuffer& buffer) {
86 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); 87 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
87 SkScalar dx = buffer.readScalar(); 88 SkScalar dx = buffer.readScalar();
88 SkScalar dy = buffer.readScalar(); 89 SkScalar dy = buffer.readScalar();
89 return Create(dx, dy, common.getInput(0)); 90 return Create(dx, dy, common.getInput(0));
90 } 91 }
91 92
93 #ifndef SK_IGNORE_TO_STRING
94 void SimpleOffsetFilter::toString(SkString* str) const {
95 str->appendf("SimpleOffsetFilter: (");
96 str->append(")");
97 }
98 #endif
99
92 class ImageFiltersGraphGM : public skiagm::GM { 100 class ImageFiltersGraphGM : public skiagm::GM {
93 public: 101 public:
94 ImageFiltersGraphGM() {} 102 ImageFiltersGraphGM() {}
95 103
96 protected: 104 protected:
97 virtual uint32_t onGetFlags() const SK_OVERRIDE { 105 virtual uint32_t onGetFlags() const SK_OVERRIDE {
98 return kSkipTiled_Flag; 106 return kSkipTiled_Flag;
99 } 107 }
100 108
101 virtual SkString onShortName() { 109 virtual SkString onShortName() {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 227
220 private: 228 private:
221 typedef GM INHERITED; 229 typedef GM INHERITED;
222 SkBitmap fBitmap; 230 SkBitmap fBitmap;
223 }; 231 };
224 232
225 /////////////////////////////////////////////////////////////////////////////// 233 ///////////////////////////////////////////////////////////////////////////////
226 234
227 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } 235 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; }
228 static skiagm::GMRegistry reg(MyFactory); 236 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/imagefiltersbase.cpp ('k') | include/core/SkImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698