Add color filters to gpu path.
git-svn-id: http://skia.googlecode.com/svn/trunk@1297 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrDrawTarget.h b/gpu/include/GrDrawTarget.h
index 6c92071..e8f1793 100644
--- a/gpu/include/GrDrawTarget.h
+++ b/gpu/include/GrDrawTarget.h
@@ -26,6 +26,8 @@
#include "GrTexture.h"
#include "GrStencil.h"
+#include "SkXfermode.h"
+
class GrTexture;
class GrClipIterator;
class GrVertexBuffer;
@@ -131,6 +133,9 @@
// all DrState members should default to something
// valid by the memset
memset(this, 0, sizeof(DrState));
+ // This is an exception to our memset, since it will
+ // result in no change.
+ fColorFilterXfermode = SkXfermode::kDstIn_Mode;
GrAssert((intptr_t)(void*)NULL == 0LL);
GrAssert(fStencilSettings.isDisabled());
}
@@ -144,6 +149,8 @@
GrRenderTarget* fRenderTarget;
GrColor fColor;
DrawFace fDrawFace;
+ GrColor fColorFilterColor;
+ SkXfermode::Mode fColorFilterXfermode;
GrStencilSettings fStencilSettings;
GrMatrix fViewMatrix;
@@ -312,6 +319,11 @@
void setColor(GrColor);
/**
+ * Add a color filter that can be represented by a color and a mode.
+ */
+ void setColorFilter(GrColor, SkXfermode::Mode);
+
+ /**
* Sets the color to be used for the next draw to be
* (r,g,b,a) = (alpha, alpha, alpha, alpha).
*
diff --git a/gpu/include/GrPaint.h b/gpu/include/GrPaint.h
index 9402209..3035ca1 100644
--- a/gpu/include/GrPaint.h
+++ b/gpu/include/GrPaint.h
@@ -21,6 +21,8 @@
#include "GrColor.h"
#include "GrSamplerState.h"
+#include "SkXfermode.h"
+
/**
* The paint describes how pixels are colored when the context draws to
* them.
@@ -38,6 +40,9 @@
GrSamplerState fSampler;
+ GrColor fColorFilterColor;
+ SkXfermode::Mode fColorFilterXfermode;
+
void setTexture(GrTexture* texture) {
GrSafeRef(texture);
GrSafeUnref(fTexture);
@@ -59,6 +64,9 @@
fColor = paint.fColor;
+ fColorFilterColor = paint.fColorFilterColor;
+ fColorFilterXfermode = paint.fColorFilterXfermode;
+
fSampler = paint.fSampler;
fTexture = paint.fTexture;
GrSafeRef(fTexture);
@@ -74,6 +82,12 @@
resetOptions();
resetColor();
resetTexture();
+ resetColorFilter();
+ }
+
+ void resetColorFilter() {
+ fColorFilterXfermode = SkXfermode::kDst_Mode;
+ fColorFilterColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff);
}
private: