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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
Index: src/core/SkLightingShader.cpp
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index 59f8564a49d3fb0461b7416fb2b2583a21d0c16b..1be023dd5b26769e8d8e43594a1128798a6275cc 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -465,8 +465,8 @@ SkShader::Context* SkLightingShaderImpl::onCreateContext(const ContextRec& rec,
SkShader::Context* diffuseContext = fDiffuseShader->createContext(rec, diffuseContextStorage);
void* normalProviderStorage = (char*)heapAllocated + fDiffuseShader->contextSize(rec);
- SkNormalSource::Provider* normalProvider =
- fNormalSource->asProvider(rec, normalProviderStorage);
+ SkNormalSource::Provider* normalProvider = fNormalSource->asProvider(rec,
+ normalProviderStorage);
if (!normalProvider) {
diffuseContext->~Context();
free(heapAllocated);
@@ -479,21 +479,14 @@ SkShader::Context* SkLightingShaderImpl::onCreateContext(const ContextRec& rec,
///////////////////////////////////////////////////////////////////////////////
-sk_sp<SkShader> SkLightingShader::Make(const SkBitmap& diffuse, sk_sp<SkLights> lights,
- const SkMatrix* diffLocalM, sk_sp<SkNormalSource> normalSource) {
- if (diffuse.isNull() || SkBitmapProcShader::BitmapIsTooBig(diffuse)) {
- return nullptr;
- }
-
- if (!normalSource) {
+sk_sp<SkShader> SkLightingShader::Make(sk_sp<SkShader> diffuseShader,
+ sk_sp<SkNormalSource> normalSource, sk_sp<SkLights> lights) {
+ if (!diffuseShader || !normalSource) {
+ // TODO: Use paint's color in absence of a diffuseShader
// TODO: Use a default implementation of normalSource instead
return nullptr;
}
- // TODO: support other tile modes
- sk_sp<SkShader> diffuseShader = SkBitmapProcShader::MakeBitmapShader(diffuse,
- SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, diffLocalM);
-
return sk_make_sp<SkLightingShaderImpl>(std::move(diffuseShader), std::move(normalSource),
std::move(lights));
}

Powered by Google App Engine
This is Rietveld 408576698