OLD | NEW |
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 SkVector fInvNormRotation; | 163 SkVector fInvNormRotation; |
164 }; | 164 }; |
165 | 165 |
166 sk_sp<GrFragmentProcessor> NormalMapSourceImpl::asFragmentProcessor( | 166 sk_sp<GrFragmentProcessor> NormalMapSourceImpl::asFragmentProcessor( |
167 GrContext *context, | 167 GrContext *context, |
168 const SkMatrix &viewM, | 168 const SkMatrix &viewM, |
169 const SkMatrix *localMatrix
, | 169 const SkMatrix *localMatrix
, |
170 SkFilterQuality filterQuali
ty, | 170 SkFilterQuality filterQuali
ty, |
171 SkSourceGammaTreatment gamm
aTreatment) const { | 171 SkSourceGammaTreatment gamm
aTreatment) const { |
172 | |
173 sk_sp<GrFragmentProcessor> bitmapFP = fBitmapShader->asFragmentProcessor(con
text, viewM, | 172 sk_sp<GrFragmentProcessor> bitmapFP = fBitmapShader->asFragmentProcessor(con
text, viewM, |
174 localMatrix, filterQuality, gammaTreatment); | 173 localMatrix, filterQuality, gammaTreatment); |
175 | 174 |
176 return sk_make_sp<NormalMapFP>(std::move(bitmapFP), fInvNormRotation); | 175 return sk_make_sp<NormalMapFP>(std::move(bitmapFP), fInvNormRotation); |
177 } | 176 } |
178 | 177 |
179 #endif // SK_SUPPORT_GPU | 178 #endif // SK_SUPPORT_GPU |
180 | 179 |
181 //////////////////////////////////////////////////////////////////////////// | 180 //////////////////////////////////////////////////////////////////////////// |
182 | 181 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 this->INHERITED::flatten(buf); | 271 this->INHERITED::flatten(buf); |
273 | 272 |
274 buf.writeFlattenable(fBitmapShader.get()); | 273 buf.writeFlattenable(fBitmapShader.get()); |
275 buf.writePoint(fInvNormRotation); | 274 buf.writePoint(fInvNormRotation); |
276 } | 275 } |
277 | 276 |
278 //////////////////////////////////////////////////////////////////////////// | 277 //////////////////////////////////////////////////////////////////////////// |
279 | 278 |
280 sk_sp<SkNormalSource> SkNormalSource::MakeMap( | 279 sk_sp<SkNormalSource> SkNormalSource::MakeMap( |
281 const SkBitmap &normal, const SkVector &invNormRotation, const SkMatrix
*normLocalM) { | 280 const SkBitmap &normal, const SkVector &invNormRotation, const SkMatrix
*normLocalM) { |
282 | |
283 if (normal.isNull() || SkBitmapProcShader::BitmapIsTooBig(normal)) { | 281 if (normal.isNull() || SkBitmapProcShader::BitmapIsTooBig(normal)) { |
284 return nullptr; | 282 return nullptr; |
285 } | 283 } |
286 | 284 |
287 SkASSERT(SkScalarNearlyEqual(invNormRotation.lengthSqd(), SK_Scalar1)); | 285 SkASSERT(SkScalarNearlyEqual(invNormRotation.lengthSqd(), SK_Scalar1)); |
288 | 286 |
289 // TODO: support other tile modes | 287 // TODO: support other tile modes |
290 sk_sp<SkShader> bitmapShader = SkMakeBitmapShader(normal, SkShader::kClamp_T
ileMode, | 288 sk_sp<SkShader> bitmapShader = SkMakeBitmapShader(normal, SkShader::kClamp_T
ileMode, |
291 SkShader::kClamp_TileMode, normLocalM, nullptr); | 289 SkShader::kClamp_TileMode, normLocalM, nullptr); |
292 | 290 |
293 return sk_make_sp<NormalMapSourceImpl>(std::move(bitmapShader), invNormRotat
ion); | 291 return sk_make_sp<NormalMapSourceImpl>(std::move(bitmapShader), invNormRotat
ion); |
294 } | 292 } |
295 | 293 |
296 //////////////////////////////////////////////////////////////////////////// | 294 //////////////////////////////////////////////////////////////////////////// |
297 | 295 |
298 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkNormalSource) | 296 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkNormalSource) |
299 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(NormalMapSourceImpl) | 297 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(NormalMapSourceImpl) |
300 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 298 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
301 | 299 |
302 //////////////////////////////////////////////////////////////////////////// | 300 //////////////////////////////////////////////////////////////////////////// |
OLD | NEW |