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

Side by Side Diff: src/core/SkLightingShader_NormalSource.cpp

Issue 2062703003: Abstracted diffuse color map out of SkLightingShaderImpl into a generic SkShader (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-normal-api-change
Patch Set: Rebased, now allocates LightingShaderContext deps on the heap Created 4 years, 6 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
« src/core/SkLightingShader.cpp ('K') | « src/core/SkLightingShader.cpp ('k') | no next file » | 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 2016 Google Inc. 2 * Copyright 2016 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 "SkBitmapProcShader.h" 8 #include "SkBitmapProcShader.h"
9 #include "SkBitmapProcState.h" 9 #include "SkBitmapProcState.h"
10 #include "SkError.h" 10 #include "SkError.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 SkVector fInvNormRotation; 162 SkVector fInvNormRotation;
163 }; 163 };
164 164
165 sk_sp<GrFragmentProcessor> NormalMapSourceImpl::asFragmentProcessor( 165 sk_sp<GrFragmentProcessor> NormalMapSourceImpl::asFragmentProcessor(
166 GrContext *context, 166 GrContext *context,
167 const SkMatrix &viewM, 167 const SkMatrix &viewM,
168 const SkMatrix *localMatrix , 168 const SkMatrix *localMatrix ,
169 SkFilterQuality filterQuali ty, 169 SkFilterQuality filterQuali ty,
170 SkSourceGammaTreatment gamm aTreatment) const { 170 SkSourceGammaTreatment gamm aTreatment) const {
171
172 sk_sp<GrFragmentProcessor> bitmapFP = fBitmapShader->asFragmentProcessor(con text, viewM, 171 sk_sp<GrFragmentProcessor> bitmapFP = fBitmapShader->asFragmentProcessor(con text, viewM,
173 localMatrix, filterQuality, gammaTreatment); 172 localMatrix, filterQuality, gammaTreatment);
174 173
175 return sk_make_sp<NormalMapFP>(std::move(bitmapFP), fInvNormRotation); 174 return sk_make_sp<NormalMapFP>(std::move(bitmapFP), fInvNormRotation);
176 } 175 }
177 176
178 #endif // SK_SUPPORT_GPU 177 #endif // SK_SUPPORT_GPU
179 178
180 //////////////////////////////////////////////////////////////////////////// 179 ////////////////////////////////////////////////////////////////////////////
181 180
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 this->INHERITED::flatten(buf); 270 this->INHERITED::flatten(buf);
272 271
273 buf.writeFlattenable(fBitmapShader.get()); 272 buf.writeFlattenable(fBitmapShader.get());
274 buf.writePoint(fInvNormRotation); 273 buf.writePoint(fInvNormRotation);
275 } 274 }
276 275
277 //////////////////////////////////////////////////////////////////////////// 276 ////////////////////////////////////////////////////////////////////////////
278 277
279 sk_sp<SkLightingShader::NormalSource> SkLightingShader::NormalSource::MakeMap( 278 sk_sp<SkLightingShader::NormalSource> SkLightingShader::NormalSource::MakeMap(
280 const SkBitmap &normal, const SkVector &invNormRotation, const SkMatrix *normLocalM) { 279 const SkBitmap &normal, const SkVector &invNormRotation, const SkMatrix *normLocalM) {
281
282 if (normal.isNull() || SkBitmapProcShader::BitmapIsTooBig(normal)) { 280 if (normal.isNull() || SkBitmapProcShader::BitmapIsTooBig(normal)) {
283 return nullptr; 281 return nullptr;
284 } 282 }
285 283
286 SkASSERT(SkScalarNearlyEqual(invNormRotation.lengthSqd(), SK_Scalar1)); 284 SkASSERT(SkScalarNearlyEqual(invNormRotation.lengthSqd(), SK_Scalar1));
287 285
288 // TODO: support other tile modes 286 // TODO: support other tile modes
289 sk_sp<SkShader> bitmapShader = SkMakeBitmapShader(normal, SkShader::kClamp_T ileMode, 287 sk_sp<SkShader> bitmapShader = SkMakeBitmapShader(normal, SkShader::kClamp_T ileMode,
290 SkShader::kClamp_TileMode, normLocalM, nullptr); 288 SkShader::kClamp_TileMode, normLocalM, nullptr);
291 289
292 return sk_make_sp<NormalMapSourceImpl>(std::move(bitmapShader), invNormRotat ion); 290 return sk_make_sp<NormalMapSourceImpl>(std::move(bitmapShader), invNormRotat ion);
293 } 291 }
294 292
295 //////////////////////////////////////////////////////////////////////////// 293 ////////////////////////////////////////////////////////////////////////////
296 294
297 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader::NormalSource) 295 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader::NormalSource)
298 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(NormalMapSourceImpl) 296 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(NormalMapSourceImpl)
299 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 297 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
300 298
301 //////////////////////////////////////////////////////////////////////////// 299 ////////////////////////////////////////////////////////////////////////////
OLDNEW
« src/core/SkLightingShader.cpp ('K') | « src/core/SkLightingShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698