Implement drawImage in terms of drawImageRect
This will cause the raster backend to draw shadermask_image incorrectly since
drawImageRect implementation has the wrong semantics. bitmapshader's expected
behavior has changed: GPU will draw the new version correctly, but raster's
will not change from the old, incorrect behavior.
Bug: skia:8752
Change-Id: Iee89082e2fdf95c2ee42ca3b052e65556f327eff
Reviewed-on: https://skia-review.googlesource.com/c/190675
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/gm/bitmapshader.cpp b/gm/bitmapshader.cpp
index c6dba20..ce226f2 100644
--- a/gm/bitmapshader.cpp
+++ b/gm/bitmapshader.cpp
@@ -72,6 +72,7 @@
// draw the shader with a bitmap mask
canvas->drawBitmap(fMask, 0, 0, &paint);
+ // no blue circle expected (the bitmap shader's coordinates are aligned to CTM still)
canvas->drawBitmap(fMask, 30, 0, &paint);
canvas->translate(0, 25);
diff --git a/gm/shadermaskfilter.cpp b/gm/shadermaskfilter.cpp
index ed63a99..4499317 100644
--- a/gm/shadermaskfilter.cpp
+++ b/gm/shadermaskfilter.cpp
@@ -19,10 +19,13 @@
const SkImage* mask, sk_sp<SkMaskFilter> outer, SkBlendMode mode) {
SkMatrix matrix = SkMatrix::MakeScale(SkIntToScalar(image->width()) / mask->width(),
SkIntToScalar(image->height() / mask->height()));
+ // The geometry of the drawImage is also translated by (x,y) so make the mask filter's
+ // coordinate system align with the rendered rectangle.
+ matrix.postTranslate(x, y);
SkPaint paint;
auto mf = SkShaderMaskFilter::Make(mask->makeShader(&matrix));
if (outer) {
- mf = SkMaskFilter::MakeCompose(outer, mf);
+ mf = SkMaskFilter::MakeCompose(outer->makeWithMatrix(matrix), mf);
}
paint.setMaskFilter(mf);
paint.setAntiAlias(true);
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 4e1c737..4af58f0 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -1297,12 +1297,8 @@
/** Draws SkImage image, with its top-left corner at (left, top),
using clip, SkMatrix, and optional SkPaint paint.
- If paint is supplied, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode,
- and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader.
- If paint contains SkMaskFilter, generate mask from image bounds. If generated
- mask extends beyond image bounds, replicate image edge colors, just as SkShader
- made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the
- image edge color when it samples outside of its bounds.
+ This is equivalent to drawImageRect() using a dst rect at (x,y) with the
+ same width and height of the image.
@param image uncompressed rectangular map of pixels
@param left left side of image
@@ -1316,12 +1312,8 @@
/** Draws SkImage image, with its top-left corner at (left, top),
using clip, SkMatrix, and optional SkPaint paint.
- If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter,
- SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader.
- If paint contains SkMaskFilter, generate mask from image bounds. If generated
- mask extends beyond image bounds, replicate image edge colors, just as SkShader
- made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the
- image edge color when it samples outside of its bounds.
+ This is equivalent to drawImageRect() using a dst rect at (x,y) with the
+ same width and height of the image.
@param image uncompressed rectangular map of pixels
@param left left side of image
@@ -1360,6 +1352,10 @@
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.
+ When using a shader or shader mask filter, its coordinate system is based on the
+ current CTM, so will reflect the dst rect geometry and is equivalent to
+ drawRect(dst). The src rect is only used to access the provided image.
+
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to
sample within src; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.
@@ -1388,6 +1384,10 @@
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.
+ When using a shader or shader mask filter, its coordinate system is based on the
+ current CTM, so will reflect the dst rect geometry and is equivalent to
+ drawRect(dst). The src rect is only used to access the provided image.
+
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to
sample within isrc; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.
@@ -1414,6 +1414,10 @@
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.
+ When using a shader or shader mask filter, its coordinate system is based on the
+ current CTM, so will reflect the dst rect geometry and is equivalent to
+ drawRect(dst).
+
@param image SkImage containing pixels, dimensions, and format
@param dst destination SkRect of image to draw to
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
@@ -1432,6 +1436,10 @@
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.
+ When using a shader or shader mask filter, its coordinate system is based on the
+ current CTM, so will reflect the dst rect geometry and is equivalent to
+ drawRect(dst). The src rect is only used to access the provided image.
+
@param image SkImage containing pixels, dimensions, and format
@param src source SkRect of image to draw from
@param dst destination SkRect of image to draw to
@@ -1457,6 +1465,10 @@
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.
+ When using a shader or shader mask filter, its coordinate system is based on the
+ current CTM, so will reflect the dst rect geometry and is equivalent to
+ drawRect(dst). The src rect is only used to access the provided image.
+
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to
sample within image; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.
@@ -1485,6 +1497,10 @@
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.
+ When using a shader or shader mask filter, its coordinate system is based on the
+ current CTM, so will reflect the dst rect geometry and is equivalent to
+ drawRect(dst).
+
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to
sample within image; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 9fffbb5..c891854 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -399,13 +399,6 @@
}
}
-void SkBitmapDevice::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
- const SkPaint& paint) {
- SkMatrix matrix = SkMatrix::MakeTrans(x, y);
- LogDrawScaleFactor(SkMatrix::Concat(this->ctm(), matrix), paint.getFilterQuality());
- this->drawBitmap(bitmap, matrix, nullptr, paint);
-}
-
void SkBitmapDevice::drawBitmap(const SkBitmap& bitmap, const SkMatrix& matrix,
const SkRect* dstOrNull, const SkPaint& paint) {
const SkRect* bounds = dstOrNull;
@@ -704,7 +697,10 @@
SkAutoDeviceCTMRestore adctmr(this, maskMatrix);
paint.writable()->setShader(srcImage->makeShader(&shaderMatrix));
- this->drawImage(mask.get(), maskBounds.x(), maskBounds.y(), *paint);
+ this->drawImageRect(mask.get(), nullptr,
+ SkRect::MakeXYWH(maskBounds.x(), maskBounds.y(),
+ mask->width(), mask->height()),
+ *paint, SkCanvas::kFast_SrcRectConstraint);
}
sk_sp<SkSpecialImage> SkBitmapDevice::makeSpecial(const SkBitmap& bitmap) {
diff --git a/src/core/SkBitmapDevice.h b/src/core/SkBitmapDevice.h
index e6f64b6..2890edf 100644
--- a/src/core/SkBitmapDevice.h
+++ b/src/core/SkBitmapDevice.h
@@ -89,7 +89,6 @@
* path on the stack to hold the representation of the oval.
*/
void drawPath(const SkPath&, const SkPaint&, bool pathIsMutable) override;
- void drawBitmap(const SkBitmap&, SkScalar x, SkScalar y, const SkPaint&) override;
void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) override;
/**
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index bf9b690..225b9e5 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -2301,7 +2301,9 @@
SkScalarRoundToInt(pt.fY), pnt,
nullptr, SkMatrix::I());
} else {
- iter.fDevice->drawImage(image, x, y, pnt);
+ iter.fDevice->drawImageRect(
+ image, nullptr, SkRect::MakeXYWH(x, y, image->width(), image->height()), pnt,
+ kStrict_SrcRectConstraint);
}
}
@@ -2377,7 +2379,9 @@
SkScalarRoundToInt(pt.fY), pnt,
nullptr, SkMatrix::I());
} else {
- iter.fDevice->drawBitmap(bitmap, x, y, looper.paint());
+ SkRect fullImage = SkRect::MakeWH(bitmap.width(), bitmap.height());
+ iter.fDevice->drawBitmapRect(bitmap, &fullImage, fullImage.makeOffset(x, y), pnt,
+ kStrict_SrcRectConstraint);
}
}
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index e6cb9f0..ea1cd4b 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -148,14 +148,6 @@
}
}
-void SkBaseDevice::drawImage(const SkImage* image, SkScalar x, SkScalar y,
- const SkPaint& paint) {
- SkBitmap bm;
- if (as_IB(image)->getROPixels(&bm)) {
- this->drawBitmap(bm, x, y, paint);
- }
-}
-
void SkBaseDevice::drawImageRect(const SkImage* image, const SkRect* src,
const SkRect& dst, const SkPaint& paint,
SkCanvas::SrcRectConstraint constraint) {
diff --git a/src/core/SkDevice.h b/src/core/SkDevice.h
index 9f2d7fd..78d91e6 100644
--- a/src/core/SkDevice.h
+++ b/src/core/SkDevice.h
@@ -189,10 +189,6 @@
virtual void drawPath(const SkPath& path,
const SkPaint& paint,
bool pathIsMutable = false) = 0;
- virtual void drawBitmap(const SkBitmap& bitmap,
- SkScalar x,
- SkScalar y,
- const SkPaint& paint) = 0;
virtual void drawSprite(const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) = 0;
@@ -209,7 +205,6 @@
virtual void drawBitmapLattice(const SkBitmap&, const SkCanvas::Lattice&,
const SkRect& dst, const SkPaint&);
- virtual void drawImage(const SkImage*, SkScalar x, SkScalar y, const SkPaint&);
virtual void drawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
const SkPaint&, SkCanvas::SrcRectConstraint);
virtual void drawImageNine(const SkImage*, const SkIRect& center,
@@ -420,7 +415,6 @@
void drawOval(const SkRect&, const SkPaint&) override {}
void drawRRect(const SkRRect&, const SkPaint&) override {}
void drawPath(const SkPath&, const SkPaint&, bool) override {}
- void drawBitmap(const SkBitmap&, SkScalar x, SkScalar y, const SkPaint&) override {}
void drawSprite(const SkBitmap&, int, int, const SkPaint&) override {}
void drawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint&,
SkCanvas::SrcRectConstraint) override {}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 0a745ca..dc467e3 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -793,62 +793,6 @@
&outClippedSrcRect);
}
-void SkGpuDevice::drawBitmap(const SkBitmap& bitmap,
- SkScalar x,
- SkScalar y,
- const SkPaint& paint) {
- SkMatrix m = SkMatrix::MakeTrans(x, y);
- ASSERT_SINGLE_OWNER
- SkMatrix viewMatrix;
- viewMatrix.setConcat(this->ctm(), m);
-
- int maxTileSize = this->caps()->maxTileSize();
-
- // The tile code path doesn't currently support AA, so if the paint asked for aa and we could
- // draw untiled, then we bypass checking for tiling purely for optimization reasons.
- bool drawAA = GrFSAAType::kUnifiedMSAA != fRenderTargetContext->fsaaType() &&
- paint.isAntiAlias() && bitmap.width() <= maxTileSize &&
- bitmap.height() <= maxTileSize;
-
- bool skipTileCheck = drawAA || paint.getMaskFilter();
-
- if (!skipTileCheck) {
- SkRect srcRect = SkRect::MakeIWH(bitmap.width(), bitmap.height());
- int tileSize;
- SkIRect clippedSrcRect;
-
- GrSamplerState samplerState;
- bool doBicubic;
- GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
- paint.getFilterQuality(), viewMatrix, SkMatrix::I(),
- fContext->priv().options().fSharpenMipmappedTextures, &doBicubic);
-
- int tileFilterPad;
-
- if (doBicubic) {
- tileFilterPad = GrBicubicEffect::kFilterTexelPad;
- } else if (GrSamplerState::Filter::kNearest == textureFilterMode) {
- tileFilterPad = 0;
- } else {
- tileFilterPad = 1;
- }
- samplerState.setFilterMode(textureFilterMode);
-
- int maxTileSizeForFilter = this->caps()->maxTileSize() - 2 * tileFilterPad;
- if (this->shouldTileImageID(bitmap.getGenerationID(), bitmap.getSubset(), viewMatrix,
- SkMatrix::I(), samplerState, &srcRect, maxTileSizeForFilter,
- &tileSize, &clippedSrcRect)) {
- this->drawTiledBitmap(bitmap, viewMatrix, SkMatrix::I(), srcRect, clippedSrcRect,
- samplerState, paint, SkCanvas::kStrict_SrcRectConstraint,
- tileSize, doBicubic);
- return;
- }
- }
- GrBitmapTextureMaker maker(fContext.get(), bitmap);
- this->drawTextureProducer(&maker, nullptr, nullptr, SkCanvas::kStrict_SrcRectConstraint,
- viewMatrix, paint, true);
-}
-
// This method outsets 'iRect' by 'outset' all around and then clamps its extents to
// 'clamp'. 'offset' is adjusted to remain positioned over the top-left corner
// of 'iRect' for all possible outsets/clamps.
@@ -1332,46 +1276,6 @@
this->drawSpecial(srcImg.get(), left, top, paint, nullptr, SkMatrix::I());
}
-void SkGpuDevice::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- SkMatrix viewMatrix = this->ctm();
- viewMatrix.preTranslate(x, y);
- if (as_IB(image)->isYUVA()) {
- GrYUVAImageTextureMaker maker(fContext.get(), image);
- this->drawTextureProducer(&maker, nullptr, nullptr, SkCanvas::kFast_SrcRectConstraint,
- viewMatrix, paint, false);
- return;
- }
- uint32_t pinnedUniqueID;
- if (sk_sp<GrTextureProxy> proxy = as_IB(image)->refPinnedTextureProxy(&pinnedUniqueID)) {
- this->drawPinnedTextureProxy(std::move(proxy), pinnedUniqueID, as_IB(image)->colorSpace(),
- image->alphaType(), nullptr, nullptr,
- SkCanvas::kFast_SrcRectConstraint, viewMatrix, paint);
- return;
- }
- SkBitmap bm;
- if (this->shouldTileImage(image, nullptr, SkCanvas::kFast_SrcRectConstraint,
- paint.getFilterQuality(), viewMatrix, SkMatrix::I())) {
- // only support tiling as bitmap at the moment, so force raster-version
- if (!as_IB(image)->getROPixels(&bm)) {
- return;
- }
- this->drawBitmap(bm, x, y, paint);
- return;
- }
- if (image->isLazyGenerated()) {
- GrImageTextureMaker maker(fContext.get(), image, SkImage::kAllow_CachingHint);
- this->drawTextureProducer(&maker, nullptr, nullptr, SkCanvas::kFast_SrcRectConstraint,
- viewMatrix, paint, true);
- return;
- }
- if (as_IB(image)->getROPixels(&bm)) {
- GrBitmapTextureMaker maker(fContext.get(), bm);
- this->drawTextureProducer(&maker, nullptr, nullptr, SkCanvas::kFast_SrcRectConstraint,
- viewMatrix, paint, true);
- }
-}
-
void SkGpuDevice::drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint& paint, SkCanvas::SrcRectConstraint constraint) {
ASSERT_SINGLE_OWNER
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 3710707..16c0010 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -81,7 +81,6 @@
void drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
bool useCenter, const SkPaint& paint) override;
void drawPath(const SkPath& path, const SkPaint& paint, bool pathIsMutable) override;
- void drawBitmap(const SkBitmap&, SkScalar x, SkScalar y, const SkPaint&) override;
void drawBitmapRect(const SkBitmap&, const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint, SkCanvas::SrcRectConstraint) override;
void drawSprite(const SkBitmap& bitmap, int x, int y,
@@ -94,7 +93,6 @@
const SkColor[], int count, SkBlendMode, const SkPaint&) override;
void drawDevice(SkBaseDevice*, int x, int y, const SkPaint&) override;
- void drawImage(const SkImage*, SkScalar x, SkScalar y, const SkPaint&) override;
void drawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
const SkPaint&, SkCanvas::SrcRectConstraint) override;
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 39385e6..f1a0424 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -235,19 +235,21 @@
const SkMatrix& viewMatrix,
const SkMatrix& srcToDstMatrix,
const SkPaint& paint) {
- // Specifying the texture coords as local coordinates is an attempt to enable more GrDrawOp
- // combining by not baking anything about the srcRect, dstRect, or viewMatrix, into the texture
- // FP. In the future this should be an opaque optimization enabled by the combination of
- // GrDrawOp/GP and FP.
const SkMaskFilter* mf = paint.getMaskFilter();
- if (mf && as_MFB(mf)->hasFragmentProcessor()) {
- mf = nullptr;
- }
+
// The shader expects proper local coords, so we can't replace local coords with texture coords
// if the shader will be used. If we have a mask filter we will change the underlying geometry
// that is rendered.
bool canUseTextureCoordsAsLocalCoords = !use_shader(producer->isAlphaOnly(), paint) && !mf;
+ // Specifying the texture coords as local coordinates is an attempt to enable more GrDrawOp
+ // combining by not baking anything about the srcRect, dstRect, or viewMatrix, into the texture
+ // FP. In the future this should be an opaque optimization enabled by the combination of
+ // GrDrawOp/GP and FP.
+ if (mf && as_MFB(mf)->hasFragmentProcessor()) {
+ mf = nullptr;
+ }
+
bool doBicubic;
GrSamplerState::Filter fm = GrSkFilterQualityToGrFilterMode(
paint.getFilterQuality(), viewMatrix, srcToDstMatrix,
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 74c2ca6..b598eec 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -885,25 +885,12 @@
this->internalDrawImageRect(SkKeyedImage(bm), src, dst, paint, this->ctm());
}
-void SkPDFDevice::drawBitmap(const SkBitmap& bm, SkScalar x, SkScalar y, const SkPaint& paint) {
- SkASSERT(!bm.drawsNothing());
- auto r = SkRect::MakeXYWH(x, y, bm.width(), bm.height());
- this->internalDrawImageRect(SkKeyedImage(bm), nullptr, r, paint, this->ctm());
-}
-
void SkPDFDevice::drawSprite(const SkBitmap& bm, int x, int y, const SkPaint& paint) {
SkASSERT(!bm.drawsNothing());
auto r = SkRect::MakeXYWH(x, y, bm.width(), bm.height());
this->internalDrawImageRect(SkKeyedImage(bm), nullptr, r, paint, SkMatrix::I());
}
-void SkPDFDevice::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkPaint& paint) {
- SkASSERT(image);
- auto r = SkRect::MakeXYWH(x, y, image->width(), image->height());
- this->internalDrawImageRect(SkKeyedImage(sk_ref_sp(const_cast<SkImage*>(image))),
- nullptr, r, paint, this->ctm());
-}
-
////////////////////////////////////////////////////////////////////////////////
namespace {
diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h
index 8ba8d18..516088e 100644
--- a/src/pdf/SkPDFDevice.h
+++ b/src/pdf/SkPDFDevice.h
@@ -78,13 +78,9 @@
void drawPath(const SkPath& origpath, const SkPaint& paint, bool pathIsMutable) override;
void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint&, SkCanvas::SrcRectConstraint) override;
- void drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint&) override;
void drawSprite(const SkBitmap& bitmap, int x, int y,
const SkPaint& paint) override;
- void drawImage(const SkImage*,
- SkScalar x,
- SkScalar y,
- const SkPaint&) override;
+
void drawImageRect(const SkImage*,
const SkRect* src,
const SkRect& dst,
diff --git a/src/svg/SkSVGDevice.cpp b/src/svg/SkSVGDevice.cpp
index c93fc13..a924737 100644
--- a/src/svg/SkSVGDevice.cpp
+++ b/src/svg/SkSVGDevice.cpp
@@ -807,16 +807,6 @@
}
}
-void SkSVGDevice::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
- const SkPaint& paint) {
- MxCp mc(this);
- SkMatrix adjustedMatrix = *mc.fMatrix;
- adjustedMatrix.preTranslate(x, y);
- mc.fMatrix = &adjustedMatrix;
-
- drawBitmapCommon(mc, bitmap, paint);
-}
-
void SkSVGDevice::drawSprite(const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) {
MxCp mc(this);
diff --git a/src/svg/SkSVGDevice.h b/src/svg/SkSVGDevice.h
index b6c4d9d..803b971 100644
--- a/src/svg/SkSVGDevice.h
+++ b/src/svg/SkSVGDevice.h
@@ -29,7 +29,6 @@
const SkPaint& paint,
bool pathIsMutable = false) override;
- void drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint& paint) override;
void drawSprite(const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) override;
void drawBitmapRect(const SkBitmap&,
diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp
index 713b74b..b70476d 100644
--- a/src/xps/SkXPSDevice.cpp
+++ b/src/xps/SkXPSDevice.cpp
@@ -1731,80 +1731,6 @@
return S_OK;
}
-void SkXPSDevice::drawBitmap(const SkBitmap& bitmap,
- SkScalar x,
- SkScalar y,
- const SkPaint& paint) {
- if (this->cs().isEmpty(size(*this))) {
- return;
- }
-
- SkIRect srcRect;
- srcRect.set(0, 0, bitmap.width(), bitmap.height());
-
- //Create the new shaded path.
- SkTScopedComPtr<IXpsOMPath> shadedPath;
- HRVM(this->fXpsFactory->CreatePath(&shadedPath),
- "Could not create path for bitmap.");
-
- //Create the shaded geometry.
- SkTScopedComPtr<IXpsOMGeometry> shadedGeometry;
- HRVM(this->fXpsFactory->CreateGeometry(&shadedGeometry),
- "Could not create geometry for bitmap.");
-
- //Add the shaded geometry to the shaded path.
- HRVM(shadedPath->SetGeometryLocal(shadedGeometry.get()),
- "Could not set the geometry for bitmap.");
-
- //Get the shaded figures from the shaded geometry.
- SkTScopedComPtr<IXpsOMGeometryFigureCollection> shadedFigures;
- HRVM(shadedGeometry->GetFigures(&shadedFigures),
- "Could not get the figures for bitmap.");
-
- SkMatrix transform = SkMatrix::MakeTrans(x, y);
- transform.postConcat(this->ctm());
-
- SkTScopedComPtr<IXpsOMMatrixTransform> xpsTransform;
- HRV(this->createXpsTransform(transform, &xpsTransform));
- if (xpsTransform.get()) {
- HRVM(shadedGeometry->SetTransformLocal(xpsTransform.get()),
- "Could not set transform for bitmap.");
- } else {
- //TODO: perspective that bitmap!
- }
-
- SkTScopedComPtr<IXpsOMGeometryFigure> rectFigure;
- if (xpsTransform.get()) {
- const SkShader::TileMode xy[2] = {
- SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode,
- };
- SkTScopedComPtr<IXpsOMTileBrush> xpsImageBrush;
- HRV(this->createXpsImageBrush(bitmap,
- transform,
- xy,
- paint.getAlpha(),
- &xpsImageBrush));
- HRVM(shadedPath->SetFillBrushLocal(xpsImageBrush.get()),
- "Could not set bitmap brush.");
-
- const SkRect bitmapRect = SkRect::MakeLTRB(0, 0,
- SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
- HRV(this->createXpsRect(bitmapRect, FALSE, TRUE, &rectFigure));
- }
- HRVM(shadedFigures->Append(rectFigure.get()),
- "Could not add bitmap figure.");
-
- //Get the current visual collection and add the shaded path to it.
- SkTScopedComPtr<IXpsOMVisualCollection> currentVisuals;
- HRVM(this->fCurrentXpsCanvas->GetVisuals(¤tVisuals),
- "Could not get current visuals for bitmap");
- HRVM(currentVisuals->Append(shadedPath.get()),
- "Could not add bitmap to current visuals.");
-
- HRV(this->clip(shadedPath.get()));
-}
-
void SkXPSDevice::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& paint) {
//TODO: override this for XPS
SkDEBUGF("XPS drawSprite not yet implemented.");
diff --git a/src/xps/SkXPSDevice.h b/src/xps/SkXPSDevice.h
index 55558c0..2f51c2b 100644
--- a/src/xps/SkXPSDevice.h
+++ b/src/xps/SkXPSDevice.h
@@ -88,10 +88,6 @@
void drawPath(const SkPath& path,
const SkPaint& paint,
bool pathIsMutable = false) override;
- void drawBitmap(const SkBitmap& bitmap,
- SkScalar x,
- SkScalar y,
- const SkPaint& paint) override;
void drawSprite(const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) override;
void drawBitmapRect(const SkBitmap&,