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

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

Issue 2287553002: Moved ambient lights out of SkLight's light array (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 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
OLDNEW
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
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.set(0.0f, 0.0f, 0.0f); 125 fAmbientColor = lights->ambientLightColor();
126 for (int i = 0; i < lights->numLights(); ++i) { 126 for (int i = 0; i < lights->numLights(); ++i) {
127 if (SkLights::Light::kAmbient_LightType == lights->light(i).type()) { 127 if (SkLights::Light::kDirectional_LightType == lights->light(i).type ()) {
128 fAmbientColor += lights->light(i).color();
129 } else if (SkLights::Light::kDirectional_LightType == lights->light( i).type()) {
130 fDirectionalLights.push_back(lights->light(i)); 128 fDirectionalLights.push_back(lights->light(i));
131 // TODO get the handle to the shadow map if there is one 129 // TODO get the handle to the shadow map if there is one
132 } else { 130 } else {
133 SkDEBUGFAIL("Unimplemented Light Type passed to LightingFP"); 131 SkDEBUGFAIL("Unimplemented Light Type passed to LightingFP");
134 } 132 }
135 } 133 }
136 134
137 this->registerChildProcessor(std::move(normalFP)); 135 this->registerChildProcessor(std::move(normalFP));
138 this->initClassID<LightingFP>(); 136 this->initClassID<LightingFP>();
139 } 137 }
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 std::move(lights)); 501 std::move(lights));
504 } 502 }
505 503
506 /////////////////////////////////////////////////////////////////////////////// 504 ///////////////////////////////////////////////////////////////////////////////
507 505
508 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) 506 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader)
509 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) 507 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl)
510 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 508 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
511 509
512 /////////////////////////////////////////////////////////////////////////////// 510 ///////////////////////////////////////////////////////////////////////////////
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698