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

Side by Side Diff: gm/imagefiltersgraph.cpp

Issue 395603002: Simplify flattening to just write enough to call the factory (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 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
« no previous file with comments | « gm/imagefiltersbase.cpp ('k') | include/core/SkColorFilter.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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain t); 50 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain t);
51 *dst = device->accessBitmap(false); 51 *dst = device->accessBitmap(false);
52 offset->fX += bounds.left(); 52 offset->fX += bounds.left();
53 offset->fY += bounds.top(); 53 offset->fY += bounds.top();
54 return true; 54 return true;
55 } 55 }
56 56
57 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter); 57 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter);
58 58
59 protected: 59 protected:
60 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
60 explicit SimpleOffsetFilter(SkReadBuffer& buffer) 61 explicit SimpleOffsetFilter(SkReadBuffer& buffer)
61 : SkImageFilter(1, buffer) { 62 : SkImageFilter(1, buffer) {
62 fDX = buffer.readScalar(); 63 fDX = buffer.readScalar();
63 fDY = buffer.readScalar(); 64 fDY = buffer.readScalar();
64 } 65 }
66 #endif
65 67
66 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { 68 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
67 this->SkImageFilter::flatten(buffer); 69 this->INHERITED::flatten(buffer);
68 buffer.writeScalar(fDX); 70 buffer.writeScalar(fDX);
69 buffer.writeScalar(fDY); 71 buffer.writeScalar(fDY);
70 } 72 }
71 73
72 private: 74 private:
73 SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input) 75 SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input)
74 : SkImageFilter(1, &input), fDX(dx), fDY(dy) {} 76 : SkImageFilter(1, &input), fDX(dx), fDY(dy) {
77 static bool gOnce;
78 if (!gOnce) {
79 gOnce = true;
80 SkFlattenable::Register("SimpleOffsetFilter", this->getFactory(),
81 this->GetFlattenableType());
82 }
83 }
75 84
76 SkScalar fDX, fDY; 85 SkScalar fDX, fDY;
86
87 typedef SkImageFilter INHERITED;
77 }; 88 };
78 89
79 SkFlattenable::Registrar registrar("SimpleOffsetFilter", 90 SkFlattenable* SimpleOffsetFilter::CreateProc(SkReadBuffer& buffer) {
80 SimpleOffsetFilter::CreateProc, 91 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
81 SimpleOffsetFilter::GetFlattenableType()); 92 SkScalar dx = buffer.readScalar();
93 SkScalar dy = buffer.readScalar();
94 return Create(dx, dy, common.getInput(0));
95 }
82 96
83 class ImageFiltersGraphGM : public skiagm::GM { 97 class ImageFiltersGraphGM : public skiagm::GM {
84 public: 98 public:
85 ImageFiltersGraphGM() {} 99 ImageFiltersGraphGM() {}
86 100
87 protected: 101 protected:
88 virtual uint32_t onGetFlags() const SK_OVERRIDE { 102 virtual uint32_t onGetFlags() const SK_OVERRIDE {
89 return kSkipTiled_Flag; 103 return kSkipTiled_Flag;
90 } 104 }
91 105
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 224
211 private: 225 private:
212 typedef GM INHERITED; 226 typedef GM INHERITED;
213 SkBitmap fBitmap; 227 SkBitmap fBitmap;
214 }; 228 };
215 229
216 /////////////////////////////////////////////////////////////////////////////// 230 ///////////////////////////////////////////////////////////////////////////////
217 231
218 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } 232 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; }
219 static skiagm::GMRegistry reg(MyFactory); 233 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/imagefiltersbase.cpp ('k') | include/core/SkColorFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698