delete (unused) TransparentShader

BUG=skia:
TBR=

Review URL: https://codereview.chromium.org/1153193014
This commit is contained in:
reed 2015-06-05 11:31:26 -07:00 committed by Commit bot
parent b500ffa1a2
commit 56263c78d8
12 changed files with 11 additions and 242 deletions

View File

@ -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',

View File

@ -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',
],
}

View File

@ -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

View File

@ -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

View File

@ -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));

View File

@ -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);
}

View File

@ -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;

View File

@ -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();
}

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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