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

Side by Side Diff: src/effects/gradients/SkLinearGradient.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: simplify xfermodes, fix SkLayerDrawLooper 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
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 "SkLinearGradient.h" 8 #include "SkLinearGradient.h"
9 9
10 static inline int repeat_bits(int x, const int bits) { 10 static inline int repeat_bits(int x, const int bits) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 /////////////////////////////////////////////////////////////////////////////// 53 ///////////////////////////////////////////////////////////////////////////////
54 54
55 SkLinearGradient::SkLinearGradient(const SkPoint pts[2], const Descriptor& desc) 55 SkLinearGradient::SkLinearGradient(const SkPoint pts[2], const Descriptor& desc)
56 : SkGradientShaderBase(desc) 56 : SkGradientShaderBase(desc)
57 , fStart(pts[0]) 57 , fStart(pts[0])
58 , fEnd(pts[1]) 58 , fEnd(pts[1])
59 { 59 {
60 pts_to_unit_matrix(pts, &fPtsToUnit); 60 pts_to_unit_matrix(pts, &fPtsToUnit);
61 } 61 }
62 62
63 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
63 SkLinearGradient::SkLinearGradient(SkReadBuffer& buffer) 64 SkLinearGradient::SkLinearGradient(SkReadBuffer& buffer)
64 : INHERITED(buffer) 65 : INHERITED(buffer)
65 , fStart(buffer.readPoint()) 66 , fStart(buffer.readPoint())
66 , fEnd(buffer.readPoint()) { 67 , fEnd(buffer.readPoint()) {
67 } 68 }
69 #endif
70
71 SkFlattenable* SkLinearGradient::CreateProc(SkReadBuffer& buffer) {
72 DescriptorScope desc;
73 if (!desc.unflatten(buffer)) {
74 return NULL;
75 }
76 SkPoint pts[2];
77 pts[0] = buffer.readPoint();
78 pts[1] = buffer.readPoint();
79 return SkGradientShader::CreateLinear(pts, desc.fColors, desc.fPos, desc.fCo unt,
80 desc.fTileMode, desc.fGradFlags, desc. fLocalMatrix);
81 }
68 82
69 void SkLinearGradient::flatten(SkWriteBuffer& buffer) const { 83 void SkLinearGradient::flatten(SkWriteBuffer& buffer) const {
70 this->INHERITED::flatten(buffer); 84 this->INHERITED::flatten(buffer);
71 buffer.writePoint(fStart); 85 buffer.writePoint(fStart);
72 buffer.writePoint(fEnd); 86 buffer.writePoint(fEnd);
73 } 87 }
74 88
75 size_t SkLinearGradient::contextSize() const { 89 size_t SkLinearGradient::contextSize() const {
76 return sizeof(LinearGradientContext); 90 return sizeof(LinearGradientContext);
77 } 91 }
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 str->append("SkLinearGradient ("); 606 str->append("SkLinearGradient (");
593 607
594 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); 608 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY);
595 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); 609 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY);
596 610
597 this->INHERITED::toString(str); 611 this->INHERITED::toString(str);
598 612
599 str->append(")"); 613 str->append(")");
600 } 614 }
601 #endif 615 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698