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

Side by Side Diff: src/effects/Sk2DPathEffect.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 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
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 8
9 9
10 #include "Sk2DPathEffect.h" 10 #include "Sk2DPathEffect.h"
11 #include "SkFlattenableBuffers.h" 11 #include "SkReadBuffer.h"
12 #include "SkWriteBuffer.h"
12 #include "SkPath.h" 13 #include "SkPath.h"
13 #include "SkRegion.h" 14 #include "SkRegion.h"
14 15
15 Sk2DPathEffect::Sk2DPathEffect(const SkMatrix& mat) : fMatrix(mat) { 16 Sk2DPathEffect::Sk2DPathEffect(const SkMatrix& mat) : fMatrix(mat) {
16 fMatrixIsInvertible = mat.invert(&fInverse); 17 fMatrixIsInvertible = mat.invert(&fInverse);
17 } 18 }
18 19
19 bool Sk2DPathEffect::filterPath(SkPath* dst, const SkPath& src, 20 bool Sk2DPathEffect::filterPath(SkPath* dst, const SkPath& src,
20 SkStrokeRec*, const SkRect*) const { 21 SkStrokeRec*, const SkRect*) const {
21 if (!fMatrixIsInvertible) { 22 if (!fMatrixIsInvertible) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 src.fX += SK_Scalar1; 61 src.fX += SK_Scalar1;
61 } while (--count > 0); 62 } while (--count > 0);
62 } 63 }
63 64
64 void Sk2DPathEffect::begin(const SkIRect& uvBounds, SkPath* dst) const {} 65 void Sk2DPathEffect::begin(const SkIRect& uvBounds, SkPath* dst) const {}
65 void Sk2DPathEffect::next(const SkPoint& loc, int u, int v, SkPath* dst) const { } 66 void Sk2DPathEffect::next(const SkPoint& loc, int u, int v, SkPath* dst) const { }
66 void Sk2DPathEffect::end(SkPath* dst) const {} 67 void Sk2DPathEffect::end(SkPath* dst) const {}
67 68
68 /////////////////////////////////////////////////////////////////////////////// 69 ///////////////////////////////////////////////////////////////////////////////
69 70
70 void Sk2DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { 71 void Sk2DPathEffect::flatten(SkWriteBuffer& buffer) const {
71 this->INHERITED::flatten(buffer); 72 this->INHERITED::flatten(buffer);
72 buffer.writeMatrix(fMatrix); 73 buffer.writeMatrix(fMatrix);
73 } 74 }
74 75
75 Sk2DPathEffect::Sk2DPathEffect(SkFlattenableReadBuffer& buffer) { 76 Sk2DPathEffect::Sk2DPathEffect(SkReadBuffer& buffer) {
76 buffer.readMatrix(&fMatrix); 77 buffer.readMatrix(&fMatrix);
77 fMatrixIsInvertible = fMatrix.invert(&fInverse); 78 fMatrixIsInvertible = fMatrix.invert(&fInverse);
78 } 79 }
79 80
80 /////////////////////////////////////////////////////////////////////////////// 81 ///////////////////////////////////////////////////////////////////////////////
81 82
82 bool SkLine2DPathEffect::filterPath(SkPath* dst, const SkPath& src, 83 bool SkLine2DPathEffect::filterPath(SkPath* dst, const SkPath& src,
83 SkStrokeRec* rec, const SkRect* cullRect) const { 84 SkStrokeRec* rec, const SkRect* cullRect) const {
84 if (this->INHERITED::filterPath(dst, src, rec, cullRect)) { 85 if (this->INHERITED::filterPath(dst, src, rec, cullRect)) {
85 rec->setStrokeStyle(fWidth); 86 rec->setStrokeStyle(fWidth);
86 return true; 87 return true;
87 } 88 }
88 return false; 89 return false;
89 } 90 }
90 91
91 void SkLine2DPathEffect::nextSpan(int u, int v, int ucount, SkPath* dst) const { 92 void SkLine2DPathEffect::nextSpan(int u, int v, int ucount, SkPath* dst) const {
92 if (ucount > 1) { 93 if (ucount > 1) {
93 SkPoint src[2], dstP[2]; 94 SkPoint src[2], dstP[2];
94 95
95 src[0].set(SkIntToScalar(u) + SK_ScalarHalf, SkIntToScalar(v) + SK_Scala rHalf); 96 src[0].set(SkIntToScalar(u) + SK_ScalarHalf, SkIntToScalar(v) + SK_Scala rHalf);
96 src[1].set(SkIntToScalar(u+ucount) + SK_ScalarHalf, SkIntToScalar(v) + S K_ScalarHalf); 97 src[1].set(SkIntToScalar(u+ucount) + SK_ScalarHalf, SkIntToScalar(v) + S K_ScalarHalf);
97 this->getMatrix().mapPoints(dstP, src, 2); 98 this->getMatrix().mapPoints(dstP, src, 2);
98 99
99 dst->moveTo(dstP[0]); 100 dst->moveTo(dstP[0]);
100 dst->lineTo(dstP[1]); 101 dst->lineTo(dstP[1]);
101 } 102 }
102 } 103 }
103 104
104 SkLine2DPathEffect::SkLine2DPathEffect(SkFlattenableReadBuffer& buffer) : INHERI TED(buffer) { 105 SkLine2DPathEffect::SkLine2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {
105 fWidth = buffer.readScalar(); 106 fWidth = buffer.readScalar();
106 } 107 }
107 108
108 void SkLine2DPathEffect::flatten(SkFlattenableWriteBuffer &buffer) const { 109 void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const {
109 this->INHERITED::flatten(buffer); 110 this->INHERITED::flatten(buffer);
110 buffer.writeScalar(fWidth); 111 buffer.writeScalar(fWidth);
111 } 112 }
112 113
113 /////////////////////////////////////////////////////////////////////////////// 114 ///////////////////////////////////////////////////////////////////////////////
114 115
115 SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p) 116 SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p)
116 : INHERITED(m), fPath(p) { 117 : INHERITED(m), fPath(p) {
117 } 118 }
118 119
119 SkPath2DPathEffect::SkPath2DPathEffect(SkFlattenableReadBuffer& buffer) 120 SkPath2DPathEffect::SkPath2DPathEffect(SkReadBuffer& buffer)
120 : INHERITED(buffer) { 121 : INHERITED(buffer) {
121 buffer.readPath(&fPath); 122 buffer.readPath(&fPath);
122 } 123 }
123 124
124 void SkPath2DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { 125 void SkPath2DPathEffect::flatten(SkWriteBuffer& buffer) const {
125 this->INHERITED::flatten(buffer); 126 this->INHERITED::flatten(buffer);
126 buffer.writePath(fPath); 127 buffer.writePath(fPath);
127 } 128 }
128 129
129 void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v, 130 void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v,
130 SkPath* dst) const { 131 SkPath* dst) const {
131 dst->addPath(fPath, loc.fX, loc.fY); 132 dst->addPath(fPath, loc.fX, loc.fY);
132 } 133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698