aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkColorShader.h4
-rw-r--r--src/core/SkShader.cpp27
-rw-r--r--src/gpu/SkGpuDevice.cpp15
3 files changed, 18 insertions, 28 deletions
diff --git a/include/core/SkColorShader.h b/include/core/SkColorShader.h
index b7537e127b..63b8a5ef78 100644
--- a/include/core/SkColorShader.h
+++ b/include/core/SkColorShader.h
@@ -47,6 +47,7 @@ public:
virtual void shadeSpan16(int x, int y, uint16_t span[], int count);
virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count);
+ // we return false for this, use asAGradient
virtual BitmapType asABitmap(SkBitmap* outTexture,
SkMatrix* outMatrix,
TileMode xy[2],
@@ -68,9 +69,6 @@ private:
uint16_t fColor16; // cached after setContext()
SkBool8 fInheritColor;
- // deferred allocation, used for asABitmap()
- mutable SkPixelRef* fAsABitmapPixelRef;
-
typedef SkShader INHERITED;
};
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 48c9966896..6865fb7c19 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -219,23 +219,18 @@ SkShader* SkShader::CreateBitmapShader(const SkBitmap& src,
SkColorShader::SkColorShader() {
fFlags = 0;
fInheritColor = true;
- fAsABitmapPixelRef = NULL;
}
SkColorShader::SkColorShader(SkColor c) {
fFlags = 0;
fColor = c;
fInheritColor = false;
- fAsABitmapPixelRef = NULL;
}
-SkColorShader::~SkColorShader() {
- SkSafeUnref(fAsABitmapPixelRef);
-}
+SkColorShader::~SkColorShader() {}
SkColorShader::SkColorShader(SkFlattenableReadBuffer& b) : INHERITED(b) {
fFlags = 0; // computed in setContext
- fAsABitmapPixelRef = NULL;
fInheritColor = b.readU8();
if (fInheritColor) {
@@ -313,25 +308,7 @@ void SkColorShader::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) {
SkShader::BitmapType SkColorShader::asABitmap(SkBitmap* bitmap, SkMatrix* matrix,
TileMode modes[],
SkScalar* twoPointRadialParams) const {
- // we cache the pixelref, since its generateID is used in the texture cache
- if (NULL == fAsABitmapPixelRef) {
- SkPMColor* storage = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor));
- *storage = fPMColor;
- fAsABitmapPixelRef = new SkMallocPixelRef(storage, sizeof(SkPMColor),
- NULL);
- }
-
- if (bitmap) {
- bitmap->setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
- bitmap->setPixelRef(fAsABitmapPixelRef);
- }
- if (matrix) {
- matrix->reset();
- }
- if (modes) {
- modes[0] = modes[1] = SkShader::kRepeat_TileMode;
- }
- return kDefault_BitmapType;
+ return kNone_BitmapType;
}
SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const {
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 0f1872666a..b8cc2bb4ce 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -481,6 +481,21 @@ bool SkGpuDevice::skPaint2GrPaintShader(const SkPaint& skPaint,
GrSamplerState::SampleMode sampleMode = sk_bmp_type_to_sample_mode[bmptype];
if (-1 == sampleMode) {
+ SkShader::GradientInfo info;
+ SkColor color;
+
+ info.fColors = &color;
+ info.fColorOffsets = NULL;
+ info.fColorCount = 1;
+ if (SkShader::kColor_GradientType == shader->asAGradient(&info)) {
+ SkPaint copy(skPaint);
+ copy.setShader(NULL);
+ copy.setColor(SkColorSetA(color, copy.getAlpha()));
+ return this->skPaint2GrPaintNoShader(copy,
+ false,
+ grPaint,
+ constantColor);
+ }
return false;
}
GrSamplerState* sampler = grPaint->getTextureSampler(kShaderTextureIdx);