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

Unified Diff: src/core/SkShader.cpp

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: src/core/SkShader.cpp
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 85707d77bce44a43e5efc89ee0d07253a88a1896..67fa122732240b7bb49bfe40b8c8403926f12535 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -6,6 +6,7 @@
*/
#include "SkBitmapProcShader.h"
+#include "SkColorShader.h"
#include "SkEmptyShader.h"
#include "SkReadBuffer.h"
#include "SkMallocPixelRef.h"
@@ -81,6 +82,18 @@ bool SkShader::computeTotalInverse(const ContextRec& rec, SkMatrix* totalInverse
return m->invert(totalInverse);
}
+bool SkShader::asLuminanceColor(SkColor* colorPtr) const {
+ SkColor storage;
+ if (NULL == colorPtr) {
+ colorPtr = &storage;
+ }
+ if (this->onAsLuminanceColor(colorPtr)) {
+ *colorPtr = SkColorSetA(*colorPtr, 0xFF); // we only return opaque
+ return true;
+ }
+ return false;
+}
+
SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage) const {
if (!this->computeTotalInverse(rec, NULL)) {
return NULL;
@@ -224,6 +237,10 @@ SkShader* SkShader::CreateEmptyShader() {
return SkNEW(SkEmptyShader);
}
+SkShader* SkShader::CreateColorShader(SkColor color) {
+ return SkNEW_ARGS(SkColorShader, (color));
+}
+
SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy,
const SkMatrix* localMatrix) {
return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL);
@@ -245,7 +262,6 @@ void SkShader::toString(SkString* str) const {
//////////////////////////////////////////////////////////////////////////////
-#include "SkColorShader.h"
#include "SkUtils.h"
SkColorShader::SkColorShader(SkColor c)

Powered by Google App Engine
This is Rietveld 408576698