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

Side by Side Diff: src/effects/SkEmbossMaskFilter.cpp

Issue 1855733002: change flattenable factory to return sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/SkImageSource.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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 SkPoint::Length(fLight.fDirection[0], fLight.fDirection[1])); 105 SkPoint::Length(fLight.fDirection[0], fLight.fDirection[1]));
106 106
107 SkEmbossMask::Emboss(dst, light); 107 SkEmbossMask::Emboss(dst, light);
108 108
109 // restore original alpha 109 // restore original alpha
110 memcpy(dst->fImage, src.fImage, src.computeImageSize()); 110 memcpy(dst->fImage, src.fImage, src.computeImageSize());
111 111
112 return true; 112 return true;
113 } 113 }
114 114
115 SkFlattenable* SkEmbossMaskFilter::CreateProc(SkReadBuffer& buffer) { 115 sk_sp<SkFlattenable> SkEmbossMaskFilter::CreateProc(SkReadBuffer& buffer) {
116 Light light; 116 Light light;
117 if (buffer.readByteArray(&light, sizeof(Light))) { 117 if (buffer.readByteArray(&light, sizeof(Light))) {
118 light.fPad = 0; // for the font-cache lookup to be clean 118 light.fPad = 0; // for the font-cache lookup to be clean
119 const SkScalar sigma = buffer.readScalar(); 119 const SkScalar sigma = buffer.readScalar();
120 return Create(sigma, light); 120 return sk_sp<SkFlattenable>(Create(sigma, light));
121 } 121 }
122 return nullptr; 122 return nullptr;
123 } 123 }
124 124
125 void SkEmbossMaskFilter::flatten(SkWriteBuffer& buffer) const { 125 void SkEmbossMaskFilter::flatten(SkWriteBuffer& buffer) const {
126 Light tmpLight = fLight; 126 Light tmpLight = fLight;
127 tmpLight.fPad = 0; // for the font-cache lookup to be clean 127 tmpLight.fPad = 0; // for the font-cache lookup to be clean
128 buffer.writeByteArray(&tmpLight, sizeof(tmpLight)); 128 buffer.writeByteArray(&tmpLight, sizeof(tmpLight));
129 buffer.writeScalar(fBlurSigma); 129 buffer.writeScalar(fBlurSigma);
130 } 130 }
(...skipping 11 matching lines...) Expand all
142 str->append(") "); 142 str->append(") ");
143 143
144 str->appendf("ambient: %d specular: %d ", 144 str->appendf("ambient: %d specular: %d ",
145 fLight.fAmbient, fLight.fSpecular); 145 fLight.fAmbient, fLight.fSpecular);
146 146
147 str->append("blurSigma: "); 147 str->append("blurSigma: ");
148 str->appendScalar(fBlurSigma); 148 str->appendScalar(fBlurSigma);
149 str->append(")"); 149 str->append(")");
150 } 150 }
151 #endif 151 #endif
OLDNEW
« no previous file with comments | « src/effects/SkDropShadowImageFilter.cpp ('k') | src/effects/SkImageSource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698