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

Side by Side Diff: gm/imagefiltersgraph.cpp

Issue 134163010: Refactor read and write buffers. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: original write flags were fine Created 6 years, 10 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
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"
11 #include "SkBitmapSource.h" 11 #include "SkBitmapSource.h"
12 #include "SkBlurImageFilter.h" 12 #include "SkBlurImageFilter.h"
13 #include "SkColorFilter.h" 13 #include "SkColorFilter.h"
14 #include "SkColorFilterImageFilter.h" 14 #include "SkColorFilterImageFilter.h"
15 #include "SkColorMatrixFilter.h" 15 #include "SkColorMatrixFilter.h"
16 #include "SkFlattenableBuffers.h" 16 #include "SkReadBuffer.h"
17 #include "SkWriteBuffer.h"
17 #include "SkMergeImageFilter.h" 18 #include "SkMergeImageFilter.h"
18 #include "SkMorphologyImageFilter.h" 19 #include "SkMorphologyImageFilter.h"
19 #include "SkOnce.h" 20 #include "SkOnce.h"
20 #include "SkTestImageFilters.h" 21 #include "SkTestImageFilters.h"
21 #include "SkXfermodeImageFilter.h" 22 #include "SkXfermodeImageFilter.h"
22 23
23 // More closely models how Blink's OffsetFilter works as of 10/23/13. SkOffsetIm ageFilter doesn't 24 // More closely models how Blink's OffsetFilter works as of 10/23/13. SkOffsetIm ageFilter doesn't
24 // perform a draw and this one does. 25 // perform a draw and this one does.
25 class SimpleOffsetFilter : public SkImageFilter { 26 class SimpleOffsetFilter : public SkImageFilter {
26 public: 27 public:
(...skipping 23 matching lines...) Expand all
50 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain t); 51 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain t);
51 *dst = device->accessBitmap(false); 52 *dst = device->accessBitmap(false);
52 offset->fX += bounds.left(); 53 offset->fX += bounds.left();
53 offset->fY += bounds.top(); 54 offset->fY += bounds.top();
54 return true; 55 return true;
55 } 56 }
56 57
57 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter); 58 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter);
58 59
59 protected: 60 protected:
60 explicit SimpleOffsetFilter(SkFlattenableReadBuffer& 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 }
65 66
66 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { 67 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
67 this->SkImageFilter::flatten(buffer); 68 this->SkImageFilter::flatten(buffer);
68 buffer.writeScalar(fDX); 69 buffer.writeScalar(fDX);
69 buffer.writeScalar(fDY); 70 buffer.writeScalar(fDY);
70 } 71 }
71 72
72 private: 73 private:
73 SkScalar fDX, fDY; 74 SkScalar fDX, fDY;
74 }; 75 };
75 76
76 static void init_flattenable(int*) { 77 static void init_flattenable(int*) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 private: 206 private:
206 typedef GM INHERITED; 207 typedef GM INHERITED;
207 SkBitmap fBitmap; 208 SkBitmap fBitmap;
208 bool fInitialized; 209 bool fInitialized;
209 }; 210 };
210 211
211 /////////////////////////////////////////////////////////////////////////////// 212 ///////////////////////////////////////////////////////////////////////////////
212 213
213 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } 214 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; }
214 static skiagm::GMRegistry reg(MyFactory); 215 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/imagefiltersbase.cpp ('k') | gm/texteffects.cpp » ('j') | include/core/SkFlattenableBuffers.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698