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

Unified Diff: src/core/SkLightingShader.cpp

Issue 1316513002: Change SkShader;asFragmentProcessor signature to no longer take skpaint\grcolor* (Closed) Base URL: https://skia.googlesource.com/skia.git@things
Patch Set: Address comments, fix roll(?) Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkColorShader.h ('k') | src/core/SkLocalMatrixShader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLightingShader.cpp
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index a8d346ab1eaa2facf41883d41b310142ec59f5f3..4ab233a82890c37ace8e9362a0976443a772d19d 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -72,9 +72,13 @@ public:
bool isOpaque() const override;
- bool asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix& viewM,
- const SkMatrix* localMatrix, GrColor* color,
- GrProcessorDataManager*, GrFragmentProcessor** fp) const override;
+#if SK_SUPPORT_GPU
+ const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ const SkMatrix& viewM,
+ const SkMatrix* localMatrix,
+ SkFilterQuality,
+ GrProcessorDataManager*) const override;
+#endif
size_t contextSize() const override;
@@ -127,6 +131,7 @@ private:
#include "GrCoordTransform.h"
#include "GrFragmentProcessor.h"
#include "GrTextureAccess.h"
+#include "effects/GrExtractAlphaFragmentProcessor.h"
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
@@ -341,10 +346,12 @@ static bool make_mat(const SkBitmap& bm,
return true;
}
-bool SkLightingShaderImpl::asFragmentProcessor(GrContext* context, const SkPaint& paint,
- const SkMatrix& viewM, const SkMatrix* localMatrix,
- GrColor* color, GrProcessorDataManager* pdm,
- GrFragmentProcessor** fp) const {
+const GrFragmentProcessor* SkLightingShaderImpl::asFragmentProcessor(
+ GrContext* context,
+ const SkMatrix& viewM,
+ const SkMatrix* localMatrix,
+ SkFilterQuality filterQuality,
+ GrProcessorDataManager* pdm) const {
// we assume diffuse and normal maps have same width and height
// TODO: support different sizes
SkASSERT(fDiffuseMap.width() == fNormalMap.width() &&
@@ -352,23 +359,23 @@ bool SkLightingShaderImpl::asFragmentProcessor(GrContext* context, const SkPaint
SkMatrix diffM, normM;
if (!make_mat(fDiffuseMap, this->getLocalMatrix(), localMatrix, &diffM)) {
- return false;
+ return nullptr;
}
if (!make_mat(fNormalMap, fNormLocalMatrix, localMatrix, &normM)) {
- return false;
+ return nullptr;
}
bool doBicubic;
GrTextureParams::FilterMode diffFilterMode = GrSkFilterQualityToGrFilterMode(
- SkTMin(paint.getFilterQuality(), kMedium_SkFilterQuality),
+ SkTMin(filterQuality, kMedium_SkFilterQuality),
viewM,
this->getLocalMatrix(),
&doBicubic);
SkASSERT(!doBicubic);
GrTextureParams::FilterMode normFilterMode = GrSkFilterQualityToGrFilterMode(
- SkTMin(paint.getFilterQuality(), kMedium_SkFilterQuality),
+ SkTMin(filterQuality, kMedium_SkFilterQuality),
viewM,
fNormLocalMatrix,
&doBicubic);
@@ -379,34 +386,22 @@ bool SkLightingShaderImpl::asFragmentProcessor(GrContext* context, const SkPaint
SkAutoTUnref<GrTexture> diffuseTexture(GrRefCachedBitmapTexture(context,
fDiffuseMap, &diffParams));
if (!diffuseTexture) {
- SkErrorInternals::SetError(kInternalError_SkError,
- "Couldn't convert bitmap to texture.");
- return false;
+ SkErrorInternals::SetError(kInternalError_SkError, "Couldn't convert bitmap to texture.");
+ return nullptr;
}
GrTextureParams normParams(kClamp_TileMode, normFilterMode);
SkAutoTUnref<GrTexture> normalTexture(GrRefCachedBitmapTexture(context,
fNormalMap, &normParams));
if (!normalTexture) {
- SkErrorInternals::SetError(kInternalError_SkError,
- "Couldn't convert bitmap to texture.");
- return false;
+ SkErrorInternals::SetError(kInternalError_SkError, "Couldn't convert bitmap to texture.");
+ return nullptr;
}
- *fp = new LightingFP(pdm, diffuseTexture, normalTexture, diffM, normM, diffParams, normParams,
- fLights, fInvNormRotation);
-
- *color = GrColorPackA4(paint.getAlpha());
- return true;
-}
-#else
-
-bool SkLightingShaderImpl::asFragmentProcessor(GrContext* context, const SkPaint& paint,
- const SkMatrix& viewM, const SkMatrix* localMatrix,
- GrColor* color, GrProcessorDataManager*,
- GrFragmentProcessor** fp) const {
- SkDEBUGFAIL("Should not call in GPU-less build");
- return false;
+ SkAutoTUnref<const GrFragmentProcessor> inner (
+ new LightingFP(pdm, diffuseTexture, normalTexture, diffM, normM, diffParams, normParams,
+ fLights, fInvNormRotation));
+ return GrExtractAlphaFragmentProcessor::Create(inner);
}
#endif
« no previous file with comments | « src/core/SkColorShader.h ('k') | src/core/SkLocalMatrixShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698