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

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
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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 sk_free(heapAllocated); 473 sk_free(heapAllocated);
474 return nullptr; 474 return nullptr;
475 } 475 }
476 476
477 return new (storage) LightingShaderContext(*this, rec, diffuseContext, norma lProvider, 477 return new (storage) LightingShaderContext(*this, rec, diffuseContext, norma lProvider,
478 heapAllocated); 478 heapAllocated);
479 } 479 }
480 480
481 /////////////////////////////////////////////////////////////////////////////// 481 ///////////////////////////////////////////////////////////////////////////////
482 482
483 sk_sp<SkShader> SkLightingShader::Make(const SkBitmap& diffuse, sk_sp<SkLights> lights, 483 sk_sp<SkShader> SkLightingShader::Make(sk_sp<SkShader> diffuseShader,
484 const SkMatrix* diffLocalM, sk_sp<SkNormalSource> normalSource) { 484 sk_sp<SkNormalSource> normalSource, sk_sp<SkLights> lights) {
485 if (diffuse.isNull() || SkBitmapProcShader::BitmapIsTooBig(diffuse)) { 485 if (!diffuseShader || !normalSource) {
486 return nullptr; 486 // TODO: Use paint's color in absence of a diffuseShader
487 }
488
489 if (!normalSource) {
490 // TODO: Use a default implementation of normalSource instead 487 // TODO: Use a default implementation of normalSource instead
491 return nullptr; 488 return nullptr;
492 } 489 }
493 490
494 // TODO: support other tile modes
495 sk_sp<SkShader> diffuseShader = SkBitmapProcShader::MakeBitmapShader(diffuse ,
496 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, diffLocalM);
497
498 return sk_make_sp<SkLightingShaderImpl>(std::move(diffuseShader), std::move( normalSource), 491 return sk_make_sp<SkLightingShaderImpl>(std::move(diffuseShader), std::move( normalSource),
499 std::move(lights)); 492 std::move(lights));
500 } 493 }
501 494
502 /////////////////////////////////////////////////////////////////////////////// 495 ///////////////////////////////////////////////////////////////////////////////
503 496
504 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) 497 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader)
505 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) 498 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl)
506 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 499 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
507 500
508 /////////////////////////////////////////////////////////////////////////////// 501 ///////////////////////////////////////////////////////////////////////////////
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698