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

Unified Diff: include/core/SkShader.h

Issue 492963002: extend SkShader to report a luminance-color to be used for gamma correction (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase, add SkShader::CreateColorShader(c) Created 6 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
Index: include/core/SkShader.h
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index 1e71577bf15191ea65ae16f58f65f4309f1e7ba6..8530023671a442cbbd57c82e85d5865afc3d2e43 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -386,6 +386,16 @@ public:
const SkMatrix* localMatrixOrNull, GrColor* paintColor,
GrEffect** effect) const;
+ /**
+ * If the shader can represent its "average" luminance in a single color, return true and
+ * if color is not NULL, return that color. If it cannot, return false and ignore the color
+ * parameter.
+ *
+ * Note: if this returns true, the returned color will always be opaque, as only the RGB
+ * components are used to compute luminance.
+ */
+ bool asLuminanceColor(SkColor*) const;
+
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
/**
* If the shader is a custom shader which has data the caller might want, call this function
@@ -402,6 +412,12 @@ public:
*/
static SkShader* CreateEmptyShader();
+ /**
+ * Call this to create a new shader that just draws the specified color. This should always
+ * draw the same as a paint with this color (and no shader).
+ */
+ static SkShader* CreateColorShader(SkColor);
+
/** Call this to create a new shader that will draw with the specified bitmap.
*
* If the bitmap cannot be used (e.g. has no pixels, or its dimensions
@@ -474,6 +490,9 @@ protected:
*/
virtual Context* onCreateContext(const ContextRec&, void* storage) const;
+ virtual bool onAsLuminanceColor(SkColor*) const {
+ return false;
+ }
private:
// This is essentially const, but not officially so it can be modified in
// constructors.

Powered by Google App Engine
This is Rietveld 408576698