OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkColor.h" | 10 #include "SkColor.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 #include "SkGrPriv.h" | 115 #include "SkGrPriv.h" |
116 | 116 |
117 // This FP expects a premul'd color input for its diffuse color. Premul'ing of t
he paint's color is | 117 // This FP expects a premul'd color input for its diffuse color. Premul'ing of t
he paint's color is |
118 // handled by the asFragmentProcessor() factory, but shaders providing diffuse c
olor must output it | 118 // handled by the asFragmentProcessor() factory, but shaders providing diffuse c
olor must output it |
119 // premul'd. | 119 // premul'd. |
120 class LightingFP : public GrFragmentProcessor { | 120 class LightingFP : public GrFragmentProcessor { |
121 public: | 121 public: |
122 LightingFP(sk_sp<GrFragmentProcessor> normalFP, sk_sp<SkLights> lights) { | 122 LightingFP(sk_sp<GrFragmentProcessor> normalFP, sk_sp<SkLights> lights) { |
123 | 123 |
124 // fuse all ambient lights into a single one | 124 // fuse all ambient lights into a single one |
125 fAmbientColor = lights->ambientLightColor(); | 125 fAmbientColor.set(0.0f, 0.0f, 0.0f); |
126 for (int i = 0; i < lights->numLights(); ++i) { | 126 for (int i = 0; i < lights->numLights(); ++i) { |
127 if (SkLights::Light::kDirectional_LightType == lights->light(i).type
()) { | 127 if (SkLights::Light::kAmbient_LightType == lights->light(i).type())
{ |
| 128 fAmbientColor += lights->light(i).color(); |
| 129 } else if (SkLights::Light::kDirectional_LightType == lights->light(
i).type()) { |
128 fDirectionalLights.push_back(lights->light(i)); | 130 fDirectionalLights.push_back(lights->light(i)); |
129 // TODO get the handle to the shadow map if there is one | 131 // TODO get the handle to the shadow map if there is one |
130 } else { | 132 } else { |
131 SkDEBUGFAIL("Unimplemented Light Type passed to LightingFP"); | 133 SkDEBUGFAIL("Unimplemented Light Type passed to LightingFP"); |
132 } | 134 } |
133 } | 135 } |
134 | 136 |
135 this->registerChildProcessor(std::move(normalFP)); | 137 this->registerChildProcessor(std::move(normalFP)); |
136 this->initClassID<LightingFP>(); | 138 this->initClassID<LightingFP>(); |
137 } | 139 } |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 std::move(lights)); | 503 std::move(lights)); |
502 } | 504 } |
503 | 505 |
504 /////////////////////////////////////////////////////////////////////////////// | 506 /////////////////////////////////////////////////////////////////////////////// |
505 | 507 |
506 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) | 508 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) |
507 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) | 509 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) |
508 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 510 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
509 | 511 |
510 /////////////////////////////////////////////////////////////////////////////// | 512 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |