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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/SkGpuBlurUtils.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 17 matching lines...) Expand all
28 28
29 SkMaskFilter* SkBlurMaskFilter::CreateEmboss(const SkScalar direction[3], 29 SkMaskFilter* SkBlurMaskFilter::CreateEmboss(const SkScalar direction[3],
30 SkScalar ambient, SkScalar specular , 30 SkScalar ambient, SkScalar specular ,
31 SkScalar blurRadius) { 31 SkScalar blurRadius) {
32 return SkBlurMaskFilter::CreateEmboss(SkBlurMask::ConvertRadiusToSigma(blurR adius), 32 return SkBlurMaskFilter::CreateEmboss(SkBlurMask::ConvertRadiusToSigma(blurR adius),
33 direction, ambient, specular); 33 direction, ambient, specular);
34 } 34 }
35 35
36 SkMaskFilter* SkBlurMaskFilter::CreateEmboss(SkScalar blurSigma, const SkScalar direction[3], 36 SkMaskFilter* SkBlurMaskFilter::CreateEmboss(SkScalar blurSigma, const SkScalar direction[3],
37 SkScalar ambient, SkScalar specular ) { 37 SkScalar ambient, SkScalar specular ) {
38 if (direction == NULL) { 38 if (direction == nullptr) {
39 return NULL; 39 return nullptr;
40 } 40 }
41 41
42 // ambient should be 0...1 as a scalar 42 // ambient should be 0...1 as a scalar
43 int am = pin2byte(SkScalarToFixed(ambient) >> 8); 43 int am = pin2byte(SkScalarToFixed(ambient) >> 8);
44 44
45 // specular should be 0..15.99 as a scalar 45 // specular should be 0..15.99 as a scalar
46 int sp = pin2byte(SkScalarToFixed(specular) >> 12); 46 int sp = pin2byte(SkScalarToFixed(specular) >> 12);
47 47
48 SkEmbossMaskFilter::Light light; 48 SkEmbossMaskFilter::Light light;
49 49
(...skipping 30 matching lines...) Expand all
80 80
81 if (!SkBlurMask::BoxBlur(dst, src, sigma, kInner_SkBlurStyle, kLow_SkBlurQua lity)) { 81 if (!SkBlurMask::BoxBlur(dst, src, sigma, kInner_SkBlurStyle, kLow_SkBlurQua lity)) {
82 return false; 82 return false;
83 } 83 }
84 84
85 dst->fFormat = SkMask::k3D_Format; 85 dst->fFormat = SkMask::k3D_Format;
86 if (margin) { 86 if (margin) {
87 margin->set(SkScalarCeilToInt(3*sigma), SkScalarCeilToInt(3*sigma)); 87 margin->set(SkScalarCeilToInt(3*sigma), SkScalarCeilToInt(3*sigma));
88 } 88 }
89 89
90 if (src.fImage == NULL) { 90 if (src.fImage == nullptr) {
91 return true; 91 return true;
92 } 92 }
93 93
94 // create a larger buffer for the other two channels (should force fBlur to do this for us) 94 // create a larger buffer for the other two channels (should force fBlur to do this for us)
95 95
96 { 96 {
97 uint8_t* alphaPlane = dst->fImage; 97 uint8_t* alphaPlane = dst->fImage;
98 size_t planeSize = dst->computeImageSize(); 98 size_t planeSize = dst->computeImageSize();
99 if (0 == planeSize) { 99 if (0 == planeSize) {
100 return false; // too big to allocate, abort 100 return false; // too big to allocate, abort
(...skipping 23 matching lines...) Expand all
124 return true; 124 return true;
125 } 125 }
126 126
127 SkFlattenable* SkEmbossMaskFilter::CreateProc(SkReadBuffer& buffer) { 127 SkFlattenable* SkEmbossMaskFilter::CreateProc(SkReadBuffer& buffer) {
128 Light light; 128 Light light;
129 if (buffer.readByteArray(&light, sizeof(Light))) { 129 if (buffer.readByteArray(&light, sizeof(Light))) {
130 light.fPad = 0; // for the font-cache lookup to be clean 130 light.fPad = 0; // for the font-cache lookup to be clean
131 const SkScalar sigma = buffer.readScalar(); 131 const SkScalar sigma = buffer.readScalar();
132 return Create(sigma, light); 132 return Create(sigma, light);
133 } 133 }
134 return NULL; 134 return nullptr;
135 } 135 }
136 136
137 void SkEmbossMaskFilter::flatten(SkWriteBuffer& buffer) const { 137 void SkEmbossMaskFilter::flatten(SkWriteBuffer& buffer) const {
138 Light tmpLight = fLight; 138 Light tmpLight = fLight;
139 tmpLight.fPad = 0; // for the font-cache lookup to be clean 139 tmpLight.fPad = 0; // for the font-cache lookup to be clean
140 buffer.writeByteArray(&tmpLight, sizeof(tmpLight)); 140 buffer.writeByteArray(&tmpLight, sizeof(tmpLight));
141 buffer.writeScalar(fBlurSigma); 141 buffer.writeScalar(fBlurSigma);
142 } 142 }
143 143
144 #ifndef SK_IGNORE_TO_STRING 144 #ifndef SK_IGNORE_TO_STRING
145 void SkEmbossMaskFilter::toString(SkString* str) const { 145 void SkEmbossMaskFilter::toString(SkString* str) const {
146 str->append("SkEmbossMaskFilter: ("); 146 str->append("SkEmbossMaskFilter: (");
147 147
148 str->append("direction: ("); 148 str->append("direction: (");
149 str->appendScalar(fLight.fDirection[0]); 149 str->appendScalar(fLight.fDirection[0]);
150 str->append(", "); 150 str->append(", ");
151 str->appendScalar(fLight.fDirection[1]); 151 str->appendScalar(fLight.fDirection[1]);
152 str->append(", "); 152 str->append(", ");
153 str->appendScalar(fLight.fDirection[2]); 153 str->appendScalar(fLight.fDirection[2]);
154 str->append(") "); 154 str->append(") ");
155 155
156 str->appendf("ambient: %d specular: %d ", 156 str->appendf("ambient: %d specular: %d ",
157 fLight.fAmbient, fLight.fSpecular); 157 fLight.fAmbient, fLight.fSpecular);
158 158
159 str->append("blurSigma: "); 159 str->append("blurSigma: ");
160 str->appendScalar(fBlurSigma); 160 str->appendScalar(fBlurSigma);
161 str->append(")"); 161 str->append(")");
162 } 162 }
163 #endif 163 #endif
OLDNEW
« no previous file with comments | « src/effects/SkDropShadowImageFilter.cpp ('k') | src/effects/SkGpuBlurUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698