OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkBitmapProcState.h" | 9 #include "SkBitmapProcState.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 typedef SkShader INHERITED; | 124 typedef SkShader INHERITED; |
125 }; | 125 }; |
126 | 126 |
127 //////////////////////////////////////////////////////////////////////////// | 127 //////////////////////////////////////////////////////////////////////////// |
128 | 128 |
129 #if SK_SUPPORT_GPU | 129 #if SK_SUPPORT_GPU |
130 | 130 |
131 #include "GrCoordTransform.h" | 131 #include "GrCoordTransform.h" |
132 #include "GrFragmentProcessor.h" | 132 #include "GrFragmentProcessor.h" |
133 #include "GrTextureAccess.h" | 133 #include "GrTextureAccess.h" |
134 #include "effects/GrExtractAlphaFragmentProcessor.h" | |
135 #include "gl/GrGLProcessor.h" | 134 #include "gl/GrGLProcessor.h" |
136 #include "gl/builders/GrGLProgramBuilder.h" | 135 #include "gl/builders/GrGLProgramBuilder.h" |
137 #include "SkGr.h" | 136 #include "SkGr.h" |
138 | 137 |
139 class LightingFP : public GrFragmentProcessor { | 138 class LightingFP : public GrFragmentProcessor { |
140 public: | 139 public: |
141 LightingFP(GrProcessorDataManager* pdm, GrTexture* diffuse, GrTexture* norma
l, | 140 LightingFP(GrProcessorDataManager* pdm, GrTexture* diffuse, GrTexture* norma
l, |
142 const SkMatrix& diffMatrix, const SkMatrix& normMatrix, | 141 const SkMatrix& diffMatrix, const SkMatrix& normMatrix, |
143 const GrTextureParams& diffParams, const GrTextureParams& normPar
ams, | 142 const GrTextureParams& diffParams, const GrTextureParams& normPar
ams, |
144 const SkLightingShader::Lights* lights, const SkVector& invNormRo
tation) | 143 const SkLightingShader::Lights* lights, const SkVector& invNormRo
tation) |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 SkAutoTUnref<GrTexture> normalTexture(GrRefCachedBitmapTexture(context, | 393 SkAutoTUnref<GrTexture> normalTexture(GrRefCachedBitmapTexture(context, |
395 fNormalMap, &
normParams)); | 394 fNormalMap, &
normParams)); |
396 if (!normalTexture) { | 395 if (!normalTexture) { |
397 SkErrorInternals::SetError(kInternalError_SkError, "Couldn't convert bit
map to texture."); | 396 SkErrorInternals::SetError(kInternalError_SkError, "Couldn't convert bit
map to texture."); |
398 return nullptr; | 397 return nullptr; |
399 } | 398 } |
400 | 399 |
401 SkAutoTUnref<const GrFragmentProcessor> inner ( | 400 SkAutoTUnref<const GrFragmentProcessor> inner ( |
402 new LightingFP(pdm, diffuseTexture, normalTexture, diffM, normM, diffPar
ams, normParams, | 401 new LightingFP(pdm, diffuseTexture, normalTexture, diffM, normM, diffPar
ams, normParams, |
403 fLights, fInvNormRotation)); | 402 fLights, fInvNormRotation)); |
404 return GrExtractAlphaFragmentProcessor::Create(inner); | 403 return GrFragmentProcessor::MulOuputByInputAlpha(inner); |
405 } | 404 } |
406 | 405 |
407 #endif | 406 #endif |
408 | 407 |
409 //////////////////////////////////////////////////////////////////////////// | 408 //////////////////////////////////////////////////////////////////////////// |
410 | 409 |
411 bool SkLightingShaderImpl::isOpaque() const { | 410 bool SkLightingShaderImpl::isOpaque() const { |
412 return fDiffuseMap.isOpaque(); | 411 return fDiffuseMap.isOpaque(); |
413 } | 412 } |
414 | 413 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 normLocalM); | 713 normLocalM); |
715 } | 714 } |
716 | 715 |
717 /////////////////////////////////////////////////////////////////////////////// | 716 /////////////////////////////////////////////////////////////////////////////// |
718 | 717 |
719 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) | 718 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) |
720 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) | 719 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) |
721 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 720 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
722 | 721 |
723 /////////////////////////////////////////////////////////////////////////////// | 722 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |