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

Side by Side Diff: samplecode/ClockFaceView.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkFlattenableBuffers.h" 11 #include "SkReadBuffer.h"
12 #include "SkWriteBuffer.h"
12 #include "SkGradientShader.h" 13 #include "SkGradientShader.h"
13 #include "SkPath.h" 14 #include "SkPath.h"
14 #include "SkRegion.h" 15 #include "SkRegion.h"
15 #include "SkShader.h" 16 #include "SkShader.h"
16 #include "SkUtils.h" 17 #include "SkUtils.h"
17 #include "SkColorPriv.h" 18 #include "SkColorPriv.h"
18 #include "SkColorFilter.h" 19 #include "SkColorFilter.h"
19 #include "SkTypeface.h" 20 #include "SkTypeface.h"
20 #include "SkAvoidXfermode.h" 21 #include "SkAvoidXfermode.h"
21 22
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 83 }
83 84
84 virtual void next(const SkPoint& loc, int u, int v, 85 virtual void next(const SkPoint& loc, int u, int v,
85 SkPath* dst) const SK_OVERRIDE { 86 SkPath* dst) const SK_OVERRIDE {
86 if (fPts) { 87 if (fPts) {
87 *fPts->append() = loc; 88 *fPts->append() = loc;
88 } 89 }
89 dst->addCircle(loc.fX, loc.fY, fRadius); 90 dst->addCircle(loc.fX, loc.fY, fRadius);
90 } 91 }
91 92
92 Dot2DPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { 93 Dot2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {
93 fRadius = buffer.readScalar(); 94 fRadius = buffer.readScalar();
94 fPts = NULL; 95 fPts = NULL;
95 } 96 }
96 97
97 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { 98 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
98 this->INHERITED::flatten(buffer); 99 this->INHERITED::flatten(buffer);
99 buffer.writeScalar(fRadius); 100 buffer.writeScalar(fRadius);
100 } 101 }
101 102
102 private: 103 private:
103 SkScalar fRadius; 104 SkScalar fRadius;
104 SkTDArray<SkPoint>* fPts; 105 SkTDArray<SkPoint>* fPts;
105 106
106 typedef Sk2DPathEffect INHERITED; 107 typedef Sk2DPathEffect INHERITED;
107 }; 108 };
108 109
109 class InverseFillPE : public SkPathEffect { 110 class InverseFillPE : public SkPathEffect {
110 public: 111 public:
111 InverseFillPE() {} 112 InverseFillPE() {}
112 virtual bool filterPath(SkPath* dst, const SkPath& src, 113 virtual bool filterPath(SkPath* dst, const SkPath& src,
113 SkStrokeRec*, const SkRect*) const SK_OVERRIDE { 114 SkStrokeRec*, const SkRect*) const SK_OVERRIDE {
114 *dst = src; 115 *dst = src;
115 dst->setFillType(SkPath::kInverseWinding_FillType); 116 dst->setFillType(SkPath::kInverseWinding_FillType);
116 return true; 117 return true;
117 } 118 }
118 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE) 119 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE)
119 120
120 protected: 121 protected:
121 InverseFillPE(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} 122 InverseFillPE(SkReadBuffer& buffer) : INHERITED(buffer) {}
122 private: 123 private:
123 124
124 typedef SkPathEffect INHERITED; 125 typedef SkPathEffect INHERITED;
125 }; 126 };
126 127
127 static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) { 128 static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) {
128 SkMatrix lattice; 129 SkMatrix lattice;
129 SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp); 130 SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp);
130 lattice.setScale(rad*2, rad*2, 0, 0); 131 lattice.setScale(rad*2, rad*2, 0, 0);
131 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); 132 lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 244 }
244 245
245 private: 246 private:
246 typedef SkView INHERITED; 247 typedef SkView INHERITED;
247 }; 248 };
248 249
249 ////////////////////////////////////////////////////////////////////////////// 250 //////////////////////////////////////////////////////////////////////////////
250 251
251 static SkView* MyFactory() { return new ClockFaceView; } 252 static SkView* MyFactory() { return new ClockFaceView; }
252 static SkViewRegister reg(MyFactory); 253 static SkViewRegister reg(MyFactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698