aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-07-05 18:54:12 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-07-05 18:54:12 +0000
commit37a201231b8f6381938282675eb9abb50ab3b389 (patch)
tree21788feb3881a72c82406a419f3c1674dd9478dc /src/core
parent1d6ee0bd4db7f3b676209341214641d9af5a965f (diff)
add SkEmptyShader, and return it from CreateBitmapShader if the bitmap is empty
(i.e. has no pixels at all) git-svn-id: http://skia.googlecode.com/svn/trunk@1792 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBitmapProcShader.cpp6
-rw-r--r--src/core/SkShader.cpp23
2 files changed, 28 insertions, 1 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index a16e96a03b..a3132c7c65 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -228,6 +228,7 @@ void SkBitmapProcShader::shadeSpan16(int x, int y, uint16_t dstC[], int count) {
#include "SkUnPreMultiply.h"
#include "SkColorShader.h"
+#include "SkEmptyShader.h"
// returns true and set color if the bitmap can be drawn as a single color
// (for efficiency)
@@ -264,7 +265,10 @@ SkShader* SkShader::CreateBitmapShader(const SkBitmap& src,
void* storage, size_t storageSize) {
SkShader* shader;
SkColor color;
- if (canUseColorShader(src, &color)) {
+ if (src.isNull()) {
+ SK_PLACEMENT_NEW(shader, SkEmptyShader, storage, storageSize);
+ }
+ else if (canUseColorShader(src, &color)) {
SK_PLACEMENT_NEW_ARGS(shader, SkColorShader, storage, storageSize,
(color));
} else {
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index b51705e6e6..48c9966896 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -344,3 +344,26 @@ SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const {
}
return kColor_GradientType;
}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#include "SkEmptyShader.h"
+
+SkEmptyShader::SkEmptyShader() {}
+SkEmptyShader::SkEmptyShader(SkFlattenableReadBuffer& b) : INHERITED(b) {}
+
+uint32_t SkEmptyShader::getFlags() { return 0; }
+uint8_t SkEmptyShader::getSpan16Alpha() const { return 0; }
+bool SkEmptyShader::setContext(const SkBitmap& device, const SkPaint& paint,
+ const SkMatrix& matrix) {
+ return false;
+}
+void SkEmptyShader::shadeSpan(int x, int y, SkPMColor span[], int count) {}
+void SkEmptyShader::shadeSpan16(int x, int y, uint16_t span[], int count) {}
+void SkEmptyShader::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) {}
+
+SkFlattenable::Factory SkEmptyShader::getFactory() { return NULL; }
+void SkEmptyShader::flatten(SkFlattenableWriteBuffer& buffer) {
+ this->INHERITED::flatten(buffer);
+}
+