remove dead methods now that we use specials exclusively for imagefilters

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2164763003

Review-Url: https://codereview.chromium.org/2164763003
This commit is contained in:
reed 2016-07-20 12:28:40 -07:00 committed by Commit bot
parent e499adf328
commit cf5c846b41
8 changed files with 11 additions and 82 deletions

View File

@ -348,12 +348,6 @@ protected:
return NULL;
}
/**
* Calls through to drawSprite, processing the imagefilter.
*/
virtual void drawSpriteWithFilter(const SkDraw&, const SkBitmap&,
int x, int y, const SkPaint&);
// A helper function used by derived classes to log the scale factor of a bitmap or image draw.
static void LogDrawScaleFactor(const SkMatrix&, SkFilterQuality);

View File

@ -364,6 +364,7 @@ void SkBitmapDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode
void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
int x, int y, const SkPaint& paint) {
SkASSERT(!paint.getImageFilter());
draw.drawSprite(static_cast<SkBitmapDevice*>(device)->fBitmap, x, y, paint);
}

View File

@ -447,36 +447,6 @@ void SkBaseDevice::drawTextRSXform(const SkDraw& draw, const void* text, size_t
//////////////////////////////////////////////////////////////////////////////////////////
void SkBaseDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitmap,
int x, int y,
const SkPaint& paint) {
SkImageFilter* filter = paint.getImageFilter();
SkASSERT(filter);
SkIPoint offset = SkIPoint::Make(0, 0);
SkMatrix matrix = *draw.fMatrix;
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y);
SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(bitmap, &this->surfaceProps()));
if (!srcImg) {
return; // something disastrous happened
}
sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
if (resultImg) {
SkPaint tmpUnfiltered(paint);
tmpUnfiltered.setImageFilter(nullptr);
SkBitmap resultBM;
if (resultImg->internal_getBM(&resultBM)) {
// TODO: add drawSprite(SkSpecialImage) to SkDevice? (see skbug.com/5073)
this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(), tmpUnfiltered);
}
}
}
uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const {
uint32_t flags = paint.getFlags();

View File

@ -81,7 +81,11 @@ sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(GrContext* context) {
}
SkBitmap bmp;
if (!this->internal_getBM(&bmp)) {
// At this point, we are definitely not texture-backed, so we must be raster or generator
// backed. If we remove the special-wrapping-an-image subclass, we may be able to assert that
// we are strictly raster-backed (i.e. generator images become raster when they are specialized)
// in which case getROPixels could turn into peekPixels...
if (!this->getROPixels(&bmp)) {
return nullptr;
}
@ -161,28 +165,6 @@ sk_sp<SkImage> SkSpecialImage::makeTightSubset(const SkIRect& subset) const {
#include "SkGrPixelRef.h"
#endif
sk_sp<SkSpecialImage> SkSpecialImage::internal_fromBM(const SkBitmap& src,
const SkSurfaceProps* props) {
#if SK_SUPPORT_GPU
// Need to test offset case! (see skbug.com/4967)
if (src.getTexture()) {
return SkSpecialImage::MakeFromGpu(src.bounds(),
src.getGenerationID(),
sk_ref_sp(src.getTexture()),
props);
}
#endif
return SkSpecialImage::MakeFromRaster(src.bounds(), src, props);
}
bool SkSpecialImage::internal_getBM(SkBitmap* result) {
const SkSpecialImage_Base* ib = as_SIB(this);
// TODO: need to test offset case! (see skbug.com/4967)
return ib->getBitmapDeprecated(result);
}
///////////////////////////////////////////////////////////////////////////////
#include "SkImage.h"
#if SK_SUPPORT_GPU

View File

@ -105,10 +105,6 @@ public:
*/
sk_sp<SkImage> makeTightSubset(const SkIRect& subset) const;
// These three internal methods will go away (see skbug.com/4965)
bool internal_getBM(SkBitmap* result);
static sk_sp<SkSpecialImage> internal_fromBM(const SkBitmap&, const SkSurfaceProps*);
// TODO: hide this when GrLayerHoister uses SkSpecialImages more fully (see skbug.com/5063)
/**
* If the SpecialImage is backed by a gpu texture, return true.

View File

@ -250,17 +250,6 @@ sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(const SkDraw& draw,
return filter->filterImage(srcImg, ctx, offset);
}
void SkGpuDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitmap,
int left, int top, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
CHECK_SHOULD_DRAW(draw);
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawSpriteWithFilter", fContext);
SkASSERT(paint.getImageFilter());
this->drawSprite(draw, bitmap, left, top, paint);
}
///////////////////////////////////////////////////////////////////////////////
bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
@ -1468,6 +1457,8 @@ sk_sp<SkSpecialImage> SkGpuDevice::snapSpecial() {
void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
int left, int top, const SkPaint& paint) {
SkASSERT(!paint.getImageFilter());
ASSERT_SINGLE_OWNER
// clear of the source device must occur before CHECK_SHOULD_DRAW
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDevice", fContext);

View File

@ -269,9 +269,6 @@ private:
int sampleCount,
const SkSurfaceProps*);
void drawSpriteWithFilter(const SkDraw&, const SkBitmap&, int x, int y,
const SkPaint&) override;
friend class GrAtlasTextContext;
friend class SkSurface_Gpu; // for access to surfaceProps
typedef SkBaseDevice INHERITED;

View File

@ -1345,17 +1345,15 @@ void SkPDFDevice::drawVertices(const SkDraw& d, SkCanvas::VertexMode,
void SkPDFDevice::drawDevice(const SkDraw& d, SkBaseDevice* device,
int x, int y, const SkPaint& paint) {
SkASSERT(!paint.getImageFilter());
// Check if the source device is really a bitmapdevice (because that's what we returned
// from createDevice (likely due to an imagefilter)
SkPixmap pmap;
if (device->peekPixels(&pmap)) {
SkBitmap bitmap;
bitmap.installPixels(pmap);
if (paint.getImageFilter()) {
this->drawSpriteWithFilter(d, bitmap, x, y, paint);
} else {
this->drawSprite(d, bitmap, x, y, paint);
}
this->drawSprite(d, bitmap, x, y, paint);
return;
}