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

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

Issue 2237493002: Added PointLights to SkLights::Light (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 4 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 422
423 for (int l = 0; l < numLights; ++l) { 423 for (int l = 0; l < numLights; ++l) {
424 bool isAmbient = buf.readBool(); 424 bool isAmbient = buf.readBool();
425 425
426 SkColor3f color; 426 SkColor3f color;
427 if (!buf.readScalarArray(&color.fX, 3)) { 427 if (!buf.readScalarArray(&color.fX, 3)) {
428 return nullptr; 428 return nullptr;
429 } 429 }
430 430
431 if (isAmbient) { 431 if (isAmbient) {
432 builder.add(SkLights::Light(color)); 432 builder.add(SkLights::Light::MakeAmbientLight(color));
433 } else { 433 } else {
434 SkVector3 dir; 434 SkVector3 dir;
435 if (!buf.readScalarArray(&dir.fX, 3)) { 435 if (!buf.readScalarArray(&dir.fX, 3)) {
436 return nullptr; 436 return nullptr;
437 } 437 }
438 builder.add(SkLights::Light(color, dir)); 438 builder.add(SkLights::Light::MakeDirectionalLight(color, dir));
439 } 439 }
440 } 440 }
441 441
442 sk_sp<SkLights> lights(builder.finish()); 442 sk_sp<SkLights> lights(builder.finish());
443 443
444 sk_sp<SkNormalSource> normalSource(buf.readFlattenable<SkNormalSource>()); 444 sk_sp<SkNormalSource> normalSource(buf.readFlattenable<SkNormalSource>());
445 445
446 bool hasDiffuse = buf.readBool(); 446 bool hasDiffuse = buf.readBool();
447 sk_sp<SkShader> diffuseShader = nullptr; 447 sk_sp<SkShader> diffuseShader = nullptr;
448 if (hasDiffuse) { 448 if (hasDiffuse) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 std::move(lights)); 524 std::move(lights));
525 } 525 }
526 526
527 /////////////////////////////////////////////////////////////////////////////// 527 ///////////////////////////////////////////////////////////////////////////////
528 528
529 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) 529 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader)
530 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) 530 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl)
531 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 531 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
532 532
533 /////////////////////////////////////////////////////////////////////////////// 533 ///////////////////////////////////////////////////////////////////////////////
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698