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

Side by Side Diff: src/pipe/SkPipeReader.cpp

Issue 2396953002: Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints" (Closed)
Patch Set: add tmp virtual to unroll legacy arithmodes Created 4 years, 2 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 | « src/pipe/SkPipeFormat.h ('k') | src/utils/SkDumpCanvas.cpp » ('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 2016 Google Inc. 2 * Copyright 2016 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkDeduper.h" 9 #include "SkDeduper.h"
10 #include "SkPicture.h" 10 #include "SkPicture.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 }} while (0) 142 }} while (0)
143 143
144 /* 144 /*
145 * Header: 145 * Header:
146 * paint flags : 32 146 * paint flags : 32
147 * non_def bits : 16 147 * non_def bits : 16
148 * xfermode enum : 8 148 * xfermode enum : 8
149 * pad zeros : 8 149 * pad zeros : 8
150 */ 150 */
151 static SkPaint read_paint(SkReadBuffer& reader) { 151 static SkPaint read_paint(SkReadBuffer& reader) {
152 SkPaint paint;
153
152 uint32_t packedFlags = reader.read32(); 154 uint32_t packedFlags = reader.read32();
153 uint32_t extra = reader.read32(); 155 uint32_t extra = reader.read32();
154 unsigned nondef = extra >> 16; 156 unsigned nondef = extra >> 16;
155 SkXfermode::Mode mode = (SkXfermode::Mode)((extra >> 8) & 0xFF); 157 paint.setBlendMode(SkBlendMode((extra >> 8) & 0xFF));
156 SkASSERT((extra & 0xFF) == 0); 158 SkASSERT((extra & 0xFF) == 0); // zero pad byte
157
158 SkPaint paint;
159 159
160 packedFlags >>= 2; // currently unused 160 packedFlags >>= 2; // currently unused
161 paint.setTextEncoding((SkPaint::TextEncoding)(packedFlags & 3)); packedFl ags >>= 2; 161 paint.setTextEncoding((SkPaint::TextEncoding)(packedFlags & 3)); packedFl ags >>= 2;
162 paint.setTextAlign((SkPaint::Align)(packedFlags & 3)); packedFl ags >>= 2; 162 paint.setTextAlign((SkPaint::Align)(packedFlags & 3)); packedFl ags >>= 2;
163 paint.setHinting((SkPaint::Hinting)(packedFlags & 3)); packedFl ags >>= 2; 163 paint.setHinting((SkPaint::Hinting)(packedFlags & 3)); packedFl ags >>= 2;
164 paint.setStrokeJoin((SkPaint::Join)(packedFlags & 3)); packedFl ags >>= 2; 164 paint.setStrokeJoin((SkPaint::Join)(packedFlags & 3)); packedFl ags >>= 2;
165 paint.setStrokeCap((SkPaint::Cap)(packedFlags & 3)); packedFl ags >>= 2; 165 paint.setStrokeCap((SkPaint::Cap)(packedFlags & 3)); packedFl ags >>= 2;
166 paint.setStyle((SkPaint::Style)(packedFlags & 3)); packedFl ags >>= 2; 166 paint.setStyle((SkPaint::Style)(packedFlags & 3)); packedFl ags >>= 2;
167 paint.setFilterQuality((SkFilterQuality)(packedFlags & 3)); packedFl ags >>= 2; 167 paint.setFilterQuality((SkFilterQuality)(packedFlags & 3)); packedFl ags >>= 2;
168 paint.setFlags(packedFlags); 168 paint.setFlags(packedFlags);
169 169
170 CHECK_SET_SCALAR(TextSize); 170 CHECK_SET_SCALAR(TextSize);
171 CHECK_SET_SCALAR(TextScaleX); 171 CHECK_SET_SCALAR(TextScaleX);
172 CHECK_SET_SCALAR(TextSkewX); 172 CHECK_SET_SCALAR(TextSkewX);
173 CHECK_SET_SCALAR(StrokeWidth); 173 CHECK_SET_SCALAR(StrokeWidth);
174 CHECK_SET_SCALAR(StrokeMiter); 174 CHECK_SET_SCALAR(StrokeMiter);
175 175
176 if (nondef & kColor_NonDef) { 176 if (nondef & kColor_NonDef) {
177 paint.setColor(reader.read32()); 177 paint.setColor(reader.read32());
178 } 178 }
179 179
180 CHECK_SET_FLATTENABLE(Typeface); 180 CHECK_SET_FLATTENABLE(Typeface);
181 CHECK_SET_FLATTENABLE(PathEffect); 181 CHECK_SET_FLATTENABLE(PathEffect);
182 CHECK_SET_FLATTENABLE(Shader); 182 CHECK_SET_FLATTENABLE(Shader);
183 CHECK_SET_FLATTENABLE(Xfermode);
184 CHECK_SET_FLATTENABLE(MaskFilter); 183 CHECK_SET_FLATTENABLE(MaskFilter);
185 CHECK_SET_FLATTENABLE(ColorFilter); 184 CHECK_SET_FLATTENABLE(ColorFilter);
186 CHECK_SET_FLATTENABLE(Rasterizer); 185 CHECK_SET_FLATTENABLE(Rasterizer);
187 CHECK_SET_FLATTENABLE(ImageFilter); 186 CHECK_SET_FLATTENABLE(ImageFilter);
188 CHECK_SET_FLATTENABLE(DrawLooper); 187 CHECK_SET_FLATTENABLE(DrawLooper);
189 188
190 if (!(nondef & kXfermode_NonDef)) {
191 paint.setXfermodeMode(mode);
192 }
193
194 return paint; 189 return paint;
195 } 190 }
196 191
197 class SkPipeReader : public SkReadBuffer { 192 class SkPipeReader : public SkReadBuffer {
198 public: 193 public:
199 SkPipeReader(SkPipeDeserializer* sink, const void* data, size_t size) 194 SkPipeReader(SkPipeDeserializer* sink, const void* data, size_t size)
200 : SkReadBuffer(data, size) 195 : SkReadBuffer(data, size)
201 , fSink(sink) 196 , fSink(sink)
202 {} 197 {}
203 198
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 953
959 bool SkPipeDeserializer::playback(const void* data, size_t size, SkCanvas* canva s) { 954 bool SkPipeDeserializer::playback(const void* data, size_t size, SkCanvas* canva s) {
960 SkPipeInflator inflator(&fImpl->fImages, &fImpl->fPictures, 955 SkPipeInflator inflator(&fImpl->fImages, &fImpl->fPictures,
961 &fImpl->fTypefaces, &fImpl->fFactories, 956 &fImpl->fTypefaces, &fImpl->fFactories,
962 fImpl->fTFDeserializer); 957 fImpl->fTFDeserializer);
963 SkPipeReader reader(this, data, size); 958 SkPipeReader reader(this, data, size);
964 reader.setInflator(&inflator); 959 reader.setInflator(&inflator);
965 return do_playback(reader, canvas); 960 return do_playback(reader, canvas);
966 } 961 }
967 962
OLDNEW
« no previous file with comments | « src/pipe/SkPipeFormat.h ('k') | src/utils/SkDumpCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698