aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-06-05 11:31:26 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-05 11:31:26 -0700
commit56263c78d86cb536d463b8d46f00ac44cad3defb (patch)
treec43997464263ed75c154419ee403a54fc0ad0163
parentb500ffa1a253dca35a7ff846ebece9fe570e3565 (diff)
delete (unused) TransparentShader
BUG=skia: TBR= Review URL: https://codereview.chromium.org/1153193014
-rw-r--r--gyp/animator.gyp2
-rw-r--r--gyp/effects.gypi2
-rw-r--r--include/core/SkShader.h10
-rw-r--r--include/effects/SkTransparentShader.h47
-rw-r--r--samplecode/SampleAll.cpp4
-rw-r--r--samplecode/SampleShaders.cpp7
-rw-r--r--src/animator/SkDisplayType.cpp5
-rw-r--r--src/animator/SkDrawTransparentShader.cpp15
-rw-r--r--src/animator/SkDrawTransparentShader.h18
-rw-r--r--src/core/SkBlitter.cpp10
-rw-r--r--src/core/SkDraw.cpp3
-rw-r--r--src/effects/SkTransparentShader.cpp130
12 files changed, 11 insertions, 242 deletions
diff --git a/gyp/animator.gyp b/gyp/animator.gyp
index 8c682bdbec..e267756724 100644
--- a/gyp/animator.gyp
+++ b/gyp/animator.gyp
@@ -132,8 +132,6 @@
'../src/animator/SkDrawTextBox.h',
'../src/animator/SkDrawTo.cpp',
'../src/animator/SkDrawTo.h',
- '../src/animator/SkDrawTransparentShader.cpp',
- '../src/animator/SkDrawTransparentShader.h',
'../src/animator/SkDump.cpp',
'../src/animator/SkDump.h',
'../src/animator/SkExtras.h',
diff --git a/gyp/effects.gypi b/gyp/effects.gypi
index 8b90a45137..edba3c726c 100644
--- a/gyp/effects.gypi
+++ b/gyp/effects.gypi
@@ -60,7 +60,6 @@
'<(skia_src_path)/effects/SkTableMaskFilter.cpp',
'<(skia_src_path)/effects/SkTestImageFilters.cpp',
'<(skia_src_path)/effects/SkTileImageFilter.cpp',
- '<(skia_src_path)/effects/SkTransparentShader.cpp',
'<(skia_src_path)/effects/SkXfermodeImageFilter.cpp',
'<(skia_src_path)/effects/gradients/SkClampRange.cpp',
@@ -116,7 +115,6 @@
'<(skia_include_path)/effects/SkTableColorFilter.h',
'<(skia_include_path)/effects/SkTableMaskFilter.h',
'<(skia_include_path)/effects/SkTileImageFilter.h',
- '<(skia_include_path)/effects/SkTransparentShader.h',
'<(skia_include_path)/effects/SkMagnifierImageFilter.h',
],
}
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index 4c4dba3e32..3739c9c73c 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -5,7 +5,6 @@
* found in the LICENSE file.
*/
-
#ifndef SkShader_DEFINED
#define SkShader_DEFINED
@@ -114,14 +113,11 @@ public:
* ContextRec acts as a parameter bundle for creating Contexts.
*/
struct ContextRec {
- ContextRec() : fDevice(NULL), fPaint(NULL), fMatrix(NULL), fLocalMatrix(NULL) {}
- ContextRec(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix)
- : fDevice(&device)
- , fPaint(&paint)
+ ContextRec(const SkPaint& paint, const SkMatrix& matrix, const SkMatrix* localM)
+ : fPaint(&paint)
, fMatrix(&matrix)
- , fLocalMatrix(NULL) {}
+ , fLocalMatrix(localM) {}
- const SkBitmap* fDevice; // the bitmap we are drawing into
const SkPaint* fPaint; // the current paint associated with the draw
const SkMatrix* fMatrix; // the current matrix in the canvas
const SkMatrix* fLocalMatrix; // optional local matrix
diff --git a/include/effects/SkTransparentShader.h b/include/effects/SkTransparentShader.h
deleted file mode 100644
index 11aa086fa4..0000000000
--- a/include/effects/SkTransparentShader.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2006 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkTransparentShader_DEFINED
-#define SkTransparentShader_DEFINED
-
-#include "SkShader.h"
-
-class SK_API SkTransparentShader : public SkShader {
-public:
- SkTransparentShader() {}
-
- size_t contextSize() const override;
-
- class TransparentShaderContext : public SkShader::Context {
- public:
- TransparentShaderContext(const SkTransparentShader& shader, const ContextRec&);
- virtual ~TransparentShaderContext();
-
- uint32_t getFlags() const override;
- void shadeSpan(int x, int y, SkPMColor[], int count) override;
- void shadeSpan16(int x, int y, uint16_t span[], int count) override;
-
- private:
- const SkBitmap* fDevice;
-
- typedef SkShader::Context INHERITED;
- };
-
- SK_TO_STRING_OVERRIDE()
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTransparentShader)
-
-protected:
- Context* onCreateContext(const ContextRec&, void* storage) const override;
-
- // we don't need to flatten anything at all
- void flatten(SkWriteBuffer&) const override {}
-
-private:
- typedef SkShader INHERITED;
-};
-
-#endif
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp
index 9a39ef9d76..667bcc3054 100644
--- a/samplecode/SampleAll.cpp
+++ b/samplecode/SampleAll.cpp
@@ -33,7 +33,6 @@
#include "SkPathMeasure.h"
#include "SkPicture.h"
#include "SkRandom.h"
-#include "SkTransparentShader.h"
#include "SkTypeface.h"
#include "SkUtils.h"
#include "SkXfermode.h"
@@ -376,7 +375,6 @@ protected:
radialRadius, radialColors, radialPos, radialCount,
radialMode);
- SkTransparentShader* transparentShader = new SkTransparentShader();
SkEmbossMaskFilter::Light light;
light.fDirection[0] = SK_Scalar1/2;
light.fDirection[1] = SK_Scalar1/2;
@@ -428,7 +426,7 @@ protected:
paint.setMaskFilter(embossFilter)->unref();
canvas->drawOval(rect, paint);
canvas->translate(SkIntToScalar(10), SkIntToScalar(10));
- paint.setShader(transparentShader)->unref();
+// paint.setShader(transparentShader)->unref();
canvas->drawOval(rect, paint);
canvas->translate(0, SkIntToScalar(-10));
diff --git a/samplecode/SampleShaders.cpp b/samplecode/SampleShaders.cpp
index 093e14f4eb..a9a8cf9c17 100644
--- a/samplecode/SampleShaders.cpp
+++ b/samplecode/SampleShaders.cpp
@@ -20,7 +20,6 @@
#include "SkColorPriv.h"
#include "SkColorFilter.h"
#include "SkTime.h"
-#include "SkTransparentShader.h"
#include "SkTypeface.h"
static SkShader* make_bitmapfade(const SkBitmap& bm)
@@ -116,13 +115,9 @@ protected:
canvas->drawRect(r, paint);
paint.setShader(make_bitmapfade(fBitmap))->unref();
canvas->drawRect(r, paint);
-
- paint.setShader(new SkTransparentShader)->unref();
- canvas->drawRect(r, paint);
}
- virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y,
- unsigned modi) override {
+ SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
this->inval(NULL);
return this->INHERITED::onFindClickHandler(x, y, modi);
}
diff --git a/src/animator/SkDisplayType.cpp b/src/animator/SkDisplayType.cpp
index 4461a4b77b..87ea560d80 100644
--- a/src/animator/SkDisplayType.cpp
+++ b/src/animator/SkDisplayType.cpp
@@ -42,7 +42,6 @@
#include "SkDrawText.h"
#include "SkDrawTextBox.h"
#include "SkDrawTo.h"
-#include "SkDrawTransparentShader.h"
#include "SkDump.h"
#include "SkExtras.h"
#include "SkHitClear.h"
@@ -196,7 +195,6 @@ SkDisplayable* SkDisplayType::CreateInstance(SkAnimateMaker* maker, SkDisplayTyp
CASE_NEW(TextToPath);
CASE_DEBUG_RETURN_NIL(TileMode);
CASE_NEW(Translate);
- CASE_DRAW_NEW(TransparentShader);
CASE_DRAW_NEW(Typeface);
CASE_DEBUG_RETURN_NIL(Xfermode);
default:
@@ -351,7 +349,6 @@ const SkMemberInfo* SkDisplayType::GetMembers(SkAnimateMaker* maker,
CASE_GET_INFO(TextToPath);
// tilemode
CASE_GET_INFO(Translate);
- // transparentshader
CASE_GET_DRAW_INFO(Typeface);
// xfermode
// knumberoftypes
@@ -518,7 +515,6 @@ const TypeNames gTypeNames[] = {
{ "textToPath", SkType_TextToPath INIT_BOOL_FIELDS },
// tilemode
{ "translate", SkType_Translate INIT_BOOL_FIELDS },
- DRAW_NAME("transparentShader", SkType_TransparentShader),
{ "typeface", SkType_Typeface INIT_BOOL_FIELDS }
// xfermode
// knumberoftypes
@@ -679,7 +675,6 @@ bool SkDisplayType::IsDisplayable(SkAnimateMaker* , SkDisplayTypes type) {
case SkType_TextOnPath:
case SkType_TextToPath:
case SkType_Translate:
- case SkType_TransparentShader:
return true;
default: // to avoid warnings
break;
diff --git a/src/animator/SkDrawTransparentShader.cpp b/src/animator/SkDrawTransparentShader.cpp
deleted file mode 100644
index 2f286f4bea..0000000000
--- a/src/animator/SkDrawTransparentShader.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-
-/*
- * Copyright 2006 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#include "SkDrawTransparentShader.h"
-#include "SkTransparentShader.h"
-
-SkShader* SkDrawTransparentShader::getShader() {
- return new SkTransparentShader();
-}
diff --git a/src/animator/SkDrawTransparentShader.h b/src/animator/SkDrawTransparentShader.h
deleted file mode 100644
index 5b5b15660b..0000000000
--- a/src/animator/SkDrawTransparentShader.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright 2006 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkDrawTransparentShader_DEFINED
-#define SkDrawTransparentShader_DEFINED
-
-#include "SkPaintPart.h"
-
-class SkDrawTransparentShader : public SkDrawShader {
- DECLARE_EMPTY_MEMBER_INFO(TransparentShader);
- SkShader* getShader() override;
-};
-
-#endif // SkDrawTransparentShader_DEFINED
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp
index 5276356206..2ac7b51180 100644
--- a/src/core/SkBlitter.cpp
+++ b/src/core/SkBlitter.cpp
@@ -864,7 +864,7 @@ SkBlitter* SkBlitter::Choose(const SkBitmap& device,
*/
SkShader::Context* shaderContext = NULL;
if (shader) {
- SkShader::ContextRec rec(device, *paint, matrix);
+ SkShader::ContextRec rec(*paint, matrix, NULL);
size_t contextSize = shader->contextSize();
if (contextSize) {
// Try to create the ShaderContext
@@ -930,11 +930,11 @@ SkBlitter* SkBlitter::Choose(const SkBitmap& device,
///////////////////////////////////////////////////////////////////////////////
-class SkTransparentShaderContext : public SkShader::Context {
+class SkZeroShaderContext : public SkShader::Context {
public:
- SkTransparentShaderContext(const SkShader& shader, const SkShader::ContextRec& rec)
+ SkZeroShaderContext(const SkShader& shader, const SkShader::ContextRec& rec)
// Override rec with the identity matrix, so it is guaranteed to be invertible.
- : INHERITED(shader, SkShader::ContextRec(*rec.fDevice, *rec.fPaint, SkMatrix::I())) {}
+ : INHERITED(shader, SkShader::ContextRec(*rec.fPaint, SkMatrix::I(), NULL)) {}
void shadeSpan(int x, int y, SkPMColor colors[], int count) override {
sk_bzero(colors, count * sizeof(SkPMColor));
@@ -971,7 +971,7 @@ bool SkShaderBlitter::resetShaderContext(const SkShader::ContextRec& rec) {
if (NULL == ctx) {
// Need a valid context in fShaderContext's storage, so we can later (or our caller) call
// the in-place destructor.
- SkNEW_PLACEMENT_ARGS(fShaderContext, SkTransparentShaderContext, (*fShader, rec));
+ SkNEW_PLACEMENT_ARGS(fShaderContext, SkZeroShaderContext, (*fShader, rec));
return false;
}
return true;
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 0ecc27d491..ac69680811 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -2110,8 +2110,7 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
if (textures) {
SkMatrix tempM;
if (texture_to_matrix(state, vertices, textures, &tempM)) {
- SkShader::ContextRec rec(*fBitmap, p, *fMatrix);
- rec.fLocalMatrix = &tempM;
+ SkShader::ContextRec rec(p, *fMatrix, &tempM);
if (!blitter->resetShaderContext(rec)) {
continue;
}
diff --git a/src/effects/SkTransparentShader.cpp b/src/effects/SkTransparentShader.cpp
deleted file mode 100644
index aab5a3d85c..0000000000
--- a/src/effects/SkTransparentShader.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-
-/*
- * Copyright 2006 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#include "SkTransparentShader.h"
-#include "SkColorPriv.h"
-#include "SkString.h"
-
-SkShader::Context* SkTransparentShader::onCreateContext(const ContextRec& rec,
- void* storage) const {
- return SkNEW_PLACEMENT_ARGS(storage, TransparentShaderContext, (*this, rec));
-}
-
-size_t SkTransparentShader::contextSize() const {
- return sizeof(TransparentShaderContext);
-}
-
-SkTransparentShader::TransparentShaderContext::TransparentShaderContext(
- const SkTransparentShader& shader, const ContextRec& rec)
- : INHERITED(shader, rec)
- , fDevice(rec.fDevice) {}
-
-SkTransparentShader::TransparentShaderContext::~TransparentShaderContext() {}
-
-uint32_t SkTransparentShader::TransparentShaderContext::getFlags() const {
- uint32_t flags = this->INHERITED::getFlags();
-
- switch (fDevice->colorType()) {
- case kRGB_565_SkColorType:
- flags |= kHasSpan16_Flag;
- if (this->getPaintAlpha() == 255)
- flags |= kOpaqueAlpha_Flag;
- break;
- case kN32_SkColorType:
- if (this->getPaintAlpha() == 255 && fDevice->isOpaque())
- flags |= kOpaqueAlpha_Flag;
- break;
- default:
- break;
- }
- return flags;
-}
-
-void SkTransparentShader::TransparentShaderContext::shadeSpan(int x, int y, SkPMColor span[],
- int count) {
- unsigned scale = SkAlpha255To256(this->getPaintAlpha());
-
- switch (fDevice->colorType()) {
- case kN32_SkColorType:
- if (scale == 256) {
- SkPMColor* src = fDevice->getAddr32(x, y);
- if (src != span) {
- memcpy(span, src, count * sizeof(SkPMColor));
- }
- } else {
- const SkPMColor* src = fDevice->getAddr32(x, y);
- for (int i = count - 1; i >= 0; --i) {
- span[i] = SkAlphaMulQ(src[i], scale);
- }
- }
- break;
- case kRGB_565_SkColorType: {
- const uint16_t* src = fDevice->getAddr16(x, y);
- if (scale == 256) {
- for (int i = count - 1; i >= 0; --i) {
- span[i] = SkPixel16ToPixel32(src[i]);
- }
- } else {
- unsigned alpha = this->getPaintAlpha();
- for (int i = count - 1; i >= 0; --i) {
- uint16_t c = src[i];
- unsigned r = SkPacked16ToR32(c);
- unsigned g = SkPacked16ToG32(c);
- unsigned b = SkPacked16ToB32(c);
-
- span[i] = SkPackARGB32( alpha,
- SkAlphaMul(r, scale),
- SkAlphaMul(g, scale),
- SkAlphaMul(b, scale));
- }
- }
- break;
- }
- case kAlpha_8_SkColorType: {
- const uint8_t* src = fDevice->getAddr8(x, y);
- if (scale == 256) {
- for (int i = count - 1; i >= 0; --i) {
- span[i] = SkPackARGB32(src[i], 0, 0, 0);
- }
- } else {
- for (int i = count - 1; i >= 0; --i) {
- span[i] = SkPackARGB32(SkAlphaMul(src[i], scale), 0, 0, 0);
- }
- }
- break;
- }
- default:
- SkDEBUGFAIL("colorType not supported as a destination device");
- break;
- }
-}
-
-void SkTransparentShader::TransparentShaderContext::shadeSpan16(int x, int y, uint16_t span[],
- int count) {
- SkASSERT(fDevice->colorType() == kRGB_565_SkColorType);
-
- uint16_t* src = fDevice->getAddr16(x, y);
- if (src != span) {
- memcpy(span, src, count << 1);
- }
-}
-
-SkFlattenable* SkTransparentShader::CreateProc(SkReadBuffer& buffer) {
- return SkNEW(SkTransparentShader);
-}
-
-#ifndef SK_IGNORE_TO_STRING
-void SkTransparentShader::toString(SkString* str) const {
- str->append("SkTransparentShader: (");
-
- this->INHERITED::toString(str);
-
- str->append(")");
-}
-#endif