diff options
author | junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-12-09 15:48:03 +0000 |
---|---|---|
committer | junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-12-09 15:48:03 +0000 |
commit | b6e161937bc890f0aa12ac5e27415d4d260ea6e0 (patch) | |
tree | 20eb36fe7eb473f2ba4e1d6a1dd3b399ebf26fdb /src/core | |
parent | e23f194bf9747267b9dd42e238dfe217ed585c03 (diff) |
Adding isOpaque method to skia shader classes
REVIEW=http://codereview.appspot.com/5451102/
TEST=unit test ShaderOpacity
git-svn-id: http://skia.googlecode.com/svn/trunk@2840 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBitmapProcShader.cpp | 4 | ||||
-rw-r--r-- | src/core/SkBitmapProcShader.h | 1 | ||||
-rw-r--r-- | src/core/SkShader.cpp | 7 |
3 files changed, 12 insertions, 0 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp index 85f964528f..65387e41b4 100644 --- a/src/core/SkBitmapProcShader.cpp +++ b/src/core/SkBitmapProcShader.cpp @@ -81,6 +81,10 @@ static bool only_scale_and_translate(const SkMatrix& matrix) { return (matrix.getType() & ~mask) == 0; } +bool SkBitmapProcShader::isOpaque() const { + return fRawBitmap.isOpaque(); +} + bool SkBitmapProcShader::setContext(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix) { diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h index 9af9d2e897..cd702793d1 100644 --- a/src/core/SkBitmapProcShader.h +++ b/src/core/SkBitmapProcShader.h @@ -18,6 +18,7 @@ public: SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty); // overrides from SkShader + virtual bool isOpaque() const SK_OVERRIDE; virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&); virtual uint32_t getFlags() { return fFlags; } virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count); diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index b832f9519a..44ec62dcd9 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -221,6 +221,13 @@ SkColorShader::SkColorShader(SkColor c) { SkColorShader::~SkColorShader() {} +bool SkColorShader::isOpaque() const { + if (fInheritColor) { + return true; // using paint's alpha + } + return SkColorGetA(fColor) == 255; +} + SkColorShader::SkColorShader(SkFlattenableReadBuffer& b) : INHERITED(b) { fFlags = 0; // computed in setContext |