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

Side by Side Diff: src/core/SkShader.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 | « src/core/SkReadBuffer.h ('k') | src/core/SkXfermode.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkBitmapProcShader.h" 8 #include "SkBitmapProcShader.h"
9 #include "SkEmptyShader.h" 9 #include "SkEmptyShader.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 27 matching lines...) Expand all
38 38
39 SkShader::SkShader(const SkMatrix* localMatrix) { 39 SkShader::SkShader(const SkMatrix* localMatrix) {
40 inc_shader_counter(); 40 inc_shader_counter();
41 if (localMatrix) { 41 if (localMatrix) {
42 fLocalMatrix = *localMatrix; 42 fLocalMatrix = *localMatrix;
43 } else { 43 } else {
44 fLocalMatrix.reset(); 44 fLocalMatrix.reset();
45 } 45 }
46 } 46 }
47 47
48 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
48 SkShader::SkShader(SkReadBuffer& buffer) : INHERITED(buffer) { 49 SkShader::SkShader(SkReadBuffer& buffer) : INHERITED(buffer) {
49 inc_shader_counter(); 50 inc_shader_counter();
50 if (buffer.readBool()) { 51 if (buffer.readBool()) {
51 buffer.readMatrix(&fLocalMatrix); 52 buffer.readMatrix(&fLocalMatrix);
52 } else { 53 } else {
53 fLocalMatrix.reset(); 54 fLocalMatrix.reset();
54 } 55 }
55 } 56 }
57 #endif
56 58
57 SkShader::~SkShader() { 59 SkShader::~SkShader() {
58 dec_shader_counter(); 60 dec_shader_counter();
59 } 61 }
60 62
61 void SkShader::flatten(SkWriteBuffer& buffer) const { 63 void SkShader::flatten(SkWriteBuffer& buffer) const {
62 this->INHERITED::flatten(buffer); 64 this->INHERITED::flatten(buffer);
63 bool hasLocalM = !fLocalMatrix.isIdentity(); 65 bool hasLocalM = !fLocalMatrix.isIdentity();
64 buffer.writeBool(hasLocalM); 66 buffer.writeBool(hasLocalM);
65 if (hasLocalM) { 67 if (hasLocalM) {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 #include "SkUtils.h" 249 #include "SkUtils.h"
248 250
249 SkColorShader::SkColorShader(SkColor c) 251 SkColorShader::SkColorShader(SkColor c)
250 : fColor(c) { 252 : fColor(c) {
251 } 253 }
252 254
253 bool SkColorShader::isOpaque() const { 255 bool SkColorShader::isOpaque() const {
254 return SkColorGetA(fColor) == 255; 256 return SkColorGetA(fColor) == 255;
255 } 257 }
256 258
259 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
257 SkColorShader::SkColorShader(SkReadBuffer& b) : INHERITED(b) { 260 SkColorShader::SkColorShader(SkReadBuffer& b) : INHERITED(b) {
258 // V25_COMPATIBILITY_CODE We had a boolean to make the color shader inherit the paint's 261 // V25_COMPATIBILITY_CODE We had a boolean to make the color shader inherit the paint's
259 // color. We don't support that any more. 262 // color. We don't support that any more.
260 if (b.isVersionLT(SkReadBuffer::kColorShaderNoBool_Version)) { 263 if (b.isVersionLT(SkReadBuffer::kColorShaderNoBool_Version)) {
261 if (b.readBool()) { 264 if (b.readBool()) {
262 SkDEBUGFAIL("We shouldn't have pictures that recorded the inherited case."); 265 SkDEBUGFAIL("We shouldn't have pictures that recorded the inherited case.");
263 fColor = SK_ColorWHITE; 266 fColor = SK_ColorWHITE;
264 return; 267 return;
265 } 268 }
266 } 269 }
267 fColor = b.readColor(); 270 fColor = b.readColor();
268 } 271 }
272 #endif
273
274 SkFlattenable* SkColorShader::CreateProc(SkReadBuffer& buffer) {
275 return SkNEW_ARGS(SkColorShader, (buffer.readColor()));
276 }
269 277
270 void SkColorShader::flatten(SkWriteBuffer& buffer) const { 278 void SkColorShader::flatten(SkWriteBuffer& buffer) const {
271 this->INHERITED::flatten(buffer);
272 buffer.writeColor(fColor); 279 buffer.writeColor(fColor);
273 } 280 }
274 281
275 uint32_t SkColorShader::ColorShaderContext::getFlags() const { 282 uint32_t SkColorShader::ColorShaderContext::getFlags() const {
276 return fFlags; 283 return fFlags;
277 } 284 }
278 285
279 uint8_t SkColorShader::ColorShaderContext::getSpan16Alpha() const { 286 uint8_t SkColorShader::ColorShaderContext::getSpan16Alpha() const {
280 return SkGetPackedA32(fPMColor); 287 return SkGetPackedA32(fPMColor);
281 } 288 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 str->appendHex(fColor); 383 str->appendHex(fColor);
377 384
378 this->INHERITED::toString(str); 385 this->INHERITED::toString(str);
379 386
380 str->append(")"); 387 str->append(")");
381 } 388 }
382 #endif 389 #endif
383 390
384 /////////////////////////////////////////////////////////////////////////////// 391 ///////////////////////////////////////////////////////////////////////////////
385 392
393 SkFlattenable* SkEmptyShader::CreateProc(SkReadBuffer&) {
394 return SkShader::CreateEmptyShader();
395 }
396
386 #ifndef SK_IGNORE_TO_STRING 397 #ifndef SK_IGNORE_TO_STRING
387 #include "SkEmptyShader.h" 398 #include "SkEmptyShader.h"
388 399
389 void SkEmptyShader::toString(SkString* str) const { 400 void SkEmptyShader::toString(SkString* str) const {
390 str->append("SkEmptyShader: ("); 401 str->append("SkEmptyShader: (");
391 402
392 this->INHERITED::toString(str); 403 this->INHERITED::toString(str);
393 404
394 str->append(")"); 405 str->append(")");
395 } 406 }
396 #endif 407 #endif
OLDNEW
« no previous file with comments | « src/core/SkReadBuffer.h ('k') | src/core/SkXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698