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

Side by Side Diff: src/effects/SkEmbossMaskFilter.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/SkDropShadowImageFilter.cpp ('k') | src/effects/SkLayerDrawLooper.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 "SkEmbossMaskFilter.h" 8 #include "SkEmbossMaskFilter.h"
9 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkBlurMask.h" 10 #include "SkBlurMask.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 SkPoint::Length(fLight.fDirection[0], fLight.fDirection[1])); 117 SkPoint::Length(fLight.fDirection[0], fLight.fDirection[1]));
118 118
119 SkEmbossMask::Emboss(dst, light); 119 SkEmbossMask::Emboss(dst, light);
120 120
121 // restore original alpha 121 // restore original alpha
122 memcpy(dst->fImage, src.fImage, src.computeImageSize()); 122 memcpy(dst->fImage, src.fImage, src.computeImageSize());
123 123
124 return true; 124 return true;
125 } 125 }
126 126
127 SkEmbossMaskFilter::SkEmbossMaskFilter(SkReadBuffer& buffer) 127 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
128 : SkMaskFilter(buffer) { 128 SkEmbossMaskFilter::SkEmbossMaskFilter(SkReadBuffer& buffer) : SkMaskFilter(buff er) {
129 SkASSERT(buffer.getArrayCount() == sizeof(Light)); 129 SkASSERT(buffer.getArrayCount() == sizeof(Light));
130 buffer.readByteArray(&fLight, sizeof(Light)); 130 buffer.readByteArray(&fLight, sizeof(Light));
131 SkASSERT(fLight.fPad == 0); // for the font-cache lookup to be clean 131 SkASSERT(fLight.fPad == 0); // for the font-cache lookup to be clean
132 fBlurSigma = buffer.readScalar(); 132 fBlurSigma = buffer.readScalar();
133 } 133 }
134 #endif
135
136 SkFlattenable* SkEmbossMaskFilter::CreateProc(SkReadBuffer& buffer) {
137 Light light;
138 if (buffer.readByteArray(&light, sizeof(Light))) {
139 light.fPad = 0; // for the font-cache lookup to be clean
140 const SkScalar sigma = buffer.readScalar();
141 return Create(sigma, light);
142 }
143 return NULL;
144 }
134 145
135 void SkEmbossMaskFilter::flatten(SkWriteBuffer& buffer) const { 146 void SkEmbossMaskFilter::flatten(SkWriteBuffer& buffer) const {
136 this->INHERITED::flatten(buffer);
137
138 Light tmpLight = fLight; 147 Light tmpLight = fLight;
139 tmpLight.fPad = 0; // for the font-cache lookup to be clean 148 tmpLight.fPad = 0; // for the font-cache lookup to be clean
140 buffer.writeByteArray(&tmpLight, sizeof(tmpLight)); 149 buffer.writeByteArray(&tmpLight, sizeof(tmpLight));
141 buffer.writeScalar(fBlurSigma); 150 buffer.writeScalar(fBlurSigma);
142 } 151 }
143 152
144 #ifndef SK_IGNORE_TO_STRING 153 #ifndef SK_IGNORE_TO_STRING
145 void SkEmbossMaskFilter::toString(SkString* str) const { 154 void SkEmbossMaskFilter::toString(SkString* str) const {
146 str->append("SkEmbossMaskFilter: ("); 155 str->append("SkEmbossMaskFilter: (");
147 156
148 str->append("direction: ("); 157 str->append("direction: (");
149 str->appendScalar(fLight.fDirection[0]); 158 str->appendScalar(fLight.fDirection[0]);
150 str->append(", "); 159 str->append(", ");
151 str->appendScalar(fLight.fDirection[1]); 160 str->appendScalar(fLight.fDirection[1]);
152 str->append(", "); 161 str->append(", ");
153 str->appendScalar(fLight.fDirection[2]); 162 str->appendScalar(fLight.fDirection[2]);
154 str->append(") "); 163 str->append(") ");
155 164
156 str->appendf("ambient: %d specular: %d ", 165 str->appendf("ambient: %d specular: %d ",
157 fLight.fAmbient, fLight.fSpecular); 166 fLight.fAmbient, fLight.fSpecular);
158 167
159 str->append("blurSigma: "); 168 str->append("blurSigma: ");
160 str->appendScalar(fBlurSigma); 169 str->appendScalar(fBlurSigma);
161 str->append(")"); 170 str->append(")");
162 } 171 }
163 #endif 172 #endif
OLDNEW
« no previous file with comments | « src/effects/SkDropShadowImageFilter.cpp ('k') | src/effects/SkLayerDrawLooper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698