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

Side by Side Diff: src/effects/SkBlurDrawLooper.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/effects/SkBitmapSource.cpp ('k') | src/effects/SkBlurImageFilter.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 2011 Google Inc. 2 * Copyright 2011 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 "SkBlurDrawLooper.h" 8 #include "SkBlurDrawLooper.h"
9 #include "SkBlurMask.h" // just for SkBlurMask::ConvertRadiusToSigma 9 #include "SkBlurMask.h" // just for SkBlurMask::ConvertRadiusToSigma
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 SkColor color, uint32_t flags) { 55 SkColor color, uint32_t flags) {
56 fSigma = sigma; 56 fSigma = sigma;
57 fDx = dx; 57 fDx = dx;
58 fDy = dy; 58 fDy = dy;
59 fBlurColor = color; 59 fBlurColor = color;
60 fBlurFlags = flags; 60 fBlurFlags = flags;
61 61
62 this->initEffects(); 62 this->initEffects();
63 } 63 }
64 64
65 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
65 SkBlurDrawLooper::SkBlurDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer) { 66 SkBlurDrawLooper::SkBlurDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer) {
66 67
67 fSigma = buffer.readScalar(); 68 fSigma = buffer.readScalar();
68 fDx = buffer.readScalar(); 69 fDx = buffer.readScalar();
69 fDy = buffer.readScalar(); 70 fDy = buffer.readScalar();
70 fBlurColor = buffer.readColor(); 71 fBlurColor = buffer.readColor();
71 fBlurFlags = buffer.readUInt() & kAll_BlurFlag; 72 fBlurFlags = buffer.readUInt() & kAll_BlurFlag;
72 73
73 this->initEffects(); 74 this->initEffects();
74 } 75 }
76 #endif
77
78 SkFlattenable* SkBlurDrawLooper::CreateProc(SkReadBuffer& buffer) {
79 const SkColor color = buffer.readColor();
80 const SkScalar sigma = buffer.readScalar();
81 const SkScalar dx = buffer.readScalar();
82 const SkScalar dy = buffer.readScalar();
83 const uint32_t flags = buffer.read32();
84 return Create(color, sigma, dx, dy, flags);
85 }
75 86
76 void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const { 87 void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const {
77 this->INHERITED::flatten(buffer); 88 buffer.writeColor(fBlurColor);
78 buffer.writeScalar(fSigma); 89 buffer.writeScalar(fSigma);
79 buffer.writeScalar(fDx); 90 buffer.writeScalar(fDx);
80 buffer.writeScalar(fDy); 91 buffer.writeScalar(fDy);
81 buffer.writeColor(fBlurColor);
82 buffer.write32(fBlurFlags); 92 buffer.write32(fBlurFlags);
83 } 93 }
84 94
85 SkBlurDrawLooper::~SkBlurDrawLooper() { 95 SkBlurDrawLooper::~SkBlurDrawLooper() {
86 SkSafeUnref(fBlur); 96 SkSafeUnref(fBlur);
87 SkSafeUnref(fColorFilter); 97 SkSafeUnref(fColorFilter);
88 } 98 }
89 99
90 bool SkBlurDrawLooper::asABlurShadow(BlurShadowRec* rec) const { 100 bool SkBlurDrawLooper::asABlurShadow(BlurShadowRec* rec) const {
91 if (fSigma <= 0 || (fBlurFlags & fBlurFlags & kIgnoreTransform_BlurFlag)) { 101 if (fSigma <= 0 || (fBlurFlags & fBlurFlags & kIgnoreTransform_BlurFlag)) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 &needsSeparator); 188 &needsSeparator);
179 SkAddFlagToString(str, SkToBool(kHighQuality_BlurFlag & fBlurFlags), "Hi ghQuality", 189 SkAddFlagToString(str, SkToBool(kHighQuality_BlurFlag & fBlurFlags), "Hi ghQuality",
180 &needsSeparator); 190 &needsSeparator);
181 } 191 }
182 str->append(")"); 192 str->append(")");
183 193
184 // TODO: add optional "fBlurFilter->toString(str);" when SkMaskFilter::toStr ing is added 194 // TODO: add optional "fBlurFilter->toString(str);" when SkMaskFilter::toStr ing is added
185 // alternatively we could cache the radius in SkBlurDrawLooper and just add it here 195 // alternatively we could cache the radius in SkBlurDrawLooper and just add it here
186 } 196 }
187 #endif 197 #endif
OLDNEW
« no previous file with comments | « src/effects/SkBitmapSource.cpp ('k') | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698