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

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

Issue 2064153002: Changed SkLightingShader API to take in a shader as color source (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-diffuse-factor-out
Patch Set: rebase Created 4 years, 5 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
« no previous file with comments | « src/core/SkLightingShader.h ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 sk_free(heapAllocated); 481 sk_free(heapAllocated);
482 return nullptr; 482 return nullptr;
483 } 483 }
484 484
485 return new (storage) LightingShaderContext(*this, rec, diffuseContext, norma lProvider, 485 return new (storage) LightingShaderContext(*this, rec, diffuseContext, norma lProvider,
486 heapAllocated); 486 heapAllocated);
487 } 487 }
488 488
489 /////////////////////////////////////////////////////////////////////////////// 489 ///////////////////////////////////////////////////////////////////////////////
490 490
491 sk_sp<SkShader> SkLightingShader::Make(const SkBitmap& diffuse, 491 sk_sp<SkShader> SkLightingShader::Make(sk_sp<SkShader> diffuseShader,
492 sk_sp<SkLights> lights, 492 sk_sp<SkNormalSource> normalSource,
493 const SkMatrix* diffLocalM, 493 sk_sp<SkLights> lights) {
494 sk_sp<SkNormalSource> normalSource) { 494 if (!diffuseShader || !normalSource) {
495 if (diffuse.isNull() || SkBitmapProcShader::BitmapIsTooBig(diffuse)) { 495 // TODO: Use paint's color in absence of a diffuseShader
496 return nullptr;
497 }
498
499 if (!normalSource) {
500 // TODO: Use a default implementation of normalSource instead 496 // TODO: Use a default implementation of normalSource instead
501 return nullptr; 497 return nullptr;
502 } 498 }
503 499
504 // TODO: support other tile modes
505 sk_sp<SkShader> diffuseShader = SkBitmapProcShader::MakeBitmapShader(diffuse ,
506 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, diffLocalM);
507
508 return sk_make_sp<SkLightingShaderImpl>(std::move(diffuseShader), std::move( normalSource), 500 return sk_make_sp<SkLightingShaderImpl>(std::move(diffuseShader), std::move( normalSource),
509 std::move(lights)); 501 std::move(lights));
510 } 502 }
511 503
512 /////////////////////////////////////////////////////////////////////////////// 504 ///////////////////////////////////////////////////////////////////////////////
513 505
514 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) 506 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader)
515 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) 507 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl)
516 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 508 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
517 509
518 /////////////////////////////////////////////////////////////////////////////// 510 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/core/SkLightingShader.h ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698