Remove drawBitmap et al. from SkDevice

SkCanvas keeps its non-exotic drawBitmap calls for now but they
immediately wrap the bitmap in SkImage::MakeFromBitmap. This will
add a copy for mutable bitmaps, but this can be worked around by using
images directly (preferred), or marking the bitmap as immutable. In
practice, mutable bitmaps do not seem to be widely used so this is
deemed acceptable for now.

Several GMs are updated to mark the bitmaps as immutable in order to
avoid pixel churn in how CPU vs. GPU mipmaps are generated. As we move
towards explicit mipmap generation, this distinction will become less
critical, so I'm just avoiding it for now. See skbug.com/9337 for mipmap
proposal. The image diffs encountered in this CL directly related to
generating mipmaps for bitmaps already cached on the GPU vs. not on the
GPU yet.

It was decided to copy if mutable vs. never copying the bitmap because
it preserves the image guarantees the devices and canvas' rely on,
and imposing the need to inspect an image for mutability is undesired.

Bug: skia:10037, skia:9337
Change-Id: If152e6cae1e155ccf6bd2cd755895f3c7a0135a5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/276004
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
Michael Ludwig 2020-03-12 10:52:15 -04:00 committed by Skia Commit-Bot
parent 1fe50d3842
commit b0cee9bf9a
36 changed files with 81 additions and 570 deletions

View File

@ -7,9 +7,18 @@ This file includes a list of high level updates for each milestone release.
Milestone 82
<Insert new notes here- top is most recent.>
* Removed drawBitmap and related functions from SkDevice; all public drawBitmap functions on
SkCanvas automatically wrap the bitmap in an SkImage and call the equivalent drawImage function.
Drawing mutable SkBitmaps will now incur a mandatory copy. Switch to using SkImage directly or
mark the bitmap as immutable before drawing.
* Removed "volatile" flag from SkVertices. All SkVertices objects are assumed to be
volatile (the previous default behavior).
* Removed exotic legacy bitmap functions from SkCanvas (drawBitmapLattic, drawBitmapNine); the
exotic SkImage functions still exist.
* Make it possible to selectively turn on/off individual encoders/decoders,
using skia_use_(libpng/libjpeg_turbo/libwebp)(decode/encode).
@ -55,9 +64,9 @@ Milestone 82
* SkSurface::ReplaceBackendTexture takes ContentChangeMode as a parameter,
which allow callers to specify whether retain a copy of the current content.
* Enforce the existing documentation in SkCanvas::saveLayer that it ignores
any mask filter on the restore SkPaint. The 'coverage' of a layer is
* Enforce the existing documentation in SkCanvas::saveLayer that it ignores
any mask filter on the restore SkPaint. The 'coverage' of a layer is
ill-defined, and masking should be handled by pre-clipping or using the
auxiliary clip mask image of the SaveLayerRec.

View File

@ -52,6 +52,7 @@ struct DownsampleBitmapGM : public skiagm::GM {
if (!info.alphaType()) { info = info.makeAlphaType(kPremul_SkAlphaType); }
SkBitmap bm = fMakeBitmap(info);
bm.setImmutable();
int curY = 0;
int curHeight;

View File

@ -57,6 +57,7 @@ class FilterBitmapGM : public skiagm::GM {
this->setBGColor(0xFFDDDDDD);
this->makeBitmap();
fBM.setImmutable();
SkScalar cx = SkScalarHalf(fBM.width());
SkScalar cy = SkScalarHalf(fBM.height());

View File

@ -56,6 +56,7 @@ class FilterIndiaBoxGM : public skiagm::GM {
fBM.allocN32Pixels(1, 1);
fBM.eraseARGB(255, 255, 0 , 0); // red == bad
}
fBM.setImmutable();
SkScalar cx = SkScalarHalf(fBM.width());
SkScalar cy = SkScalarHalf(fBM.height());

View File

@ -58,6 +58,7 @@ protected:
void onOnceBeforeDraw() override {
fBitmap = ToolUtils::create_checkerboard_bitmap(
kCellSize, kCellSize, SK_ColorBLUE, SK_ColorYELLOW, kCellSize / 10);
fBitmap.setImmutable();
fBitmapShader = fBitmap.makeShader();
SkPoint pts1[] = {

View File

@ -2552,16 +2552,14 @@ protected:
virtual void onDrawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
const SkPaint* paint);
virtual void onDrawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy,
const SkPaint* paint);
virtual void onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint);
// REMOVE ME
virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect&,
const SkRect&, const SkPaint*) {}
// REMOVE ME
virtual void onDrawBitmapLattice(const SkBitmap&, const Lattice&,
const SkRect&, const SkPaint*) {}
// REMOVE ME - SkCanvasVirtualEnforcer no longer requires the on DrawBitmapX functions
// to be implemented and these will be removed from SkCanvas at a later date.
virtual void onDrawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint*) {}
virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
SkCanvas::SrcRectConstraint) {}
virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&, const SkPaint*) {}
virtual void onDrawBitmapLattice(const SkBitmap&, const SkCanvas::Lattice&, const SkRect&,
const SkPaint*) {}
virtual void onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect rect[],
const SkColor colors[], int count, SkBlendMode mode,
@ -2763,9 +2761,6 @@ private:
*/
SkIRect getTopLayerBounds() const;
void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
SrcRectConstraint);
void internalDrawPaint(const SkPaint& paint);
void internalSaveLayer(const SaveLayerRec&, SaveLayerStrategy);
void internalSaveBehind(const SkRect*);

View File

@ -71,12 +71,6 @@ protected:
SkCanvas::SrcRectConstraint constraint) override = 0;
#endif
void onDrawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy,
const SkPaint* paint) override = 0;
void onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
const SkPaint* paint,
SkCanvas::SrcRectConstraint constraint) override = 0;
void onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect rect[],
const SkColor colors[], int count, SkBlendMode mode, const SkRect* cull,
const SkPaint* paint) override = 0;

View File

@ -47,9 +47,6 @@ public:
SrcRectConstraint) override;
void onDrawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*) override;
void onDrawImageLattice(const SkImage*, const Lattice&, const SkRect&, const SkPaint*) override;
void onDrawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
SrcRectConstraint) override;
void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;

View File

@ -44,9 +44,7 @@ protected:
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
void onDrawRRect(const SkRRect&, const SkPaint&) override;
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
SrcRectConstraint) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
const SkPaint*, SrcRectConstraint) override;

View File

@ -52,9 +52,6 @@ protected:
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
void onDrawRRect(const SkRRect&, const SkPaint&) override;
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
SrcRectConstraint) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
const SkPaint*, SrcRectConstraint) override;

View File

@ -54,9 +54,6 @@ protected:
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override {}
void onDrawRRect(const SkRRect&, const SkPaint&) override {}
void onDrawPath(const SkPath&, const SkPaint&) override {}
void onDrawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint*) override {}
void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
SrcRectConstraint) override {}
void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override {}
void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
SrcRectConstraint) override {}

View File

@ -60,9 +60,6 @@ protected:
void onDrawOval(const SkRect&, const SkPaint&) override;
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
SrcRectConstraint) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
const SkPaint*, SrcRectConstraint) override;

View File

@ -23,6 +23,7 @@
#include "src/core/SkSpecialImage.h"
#include "src/core/SkStrikeCache.h"
#include "src/core/SkTLazy.h"
#include "src/image/SkImage_Base.h"
struct Bounder {
SkRect fBounds;
@ -425,12 +426,17 @@ static inline bool CanApplyDstMatrixAsCTM(const SkMatrix& m, const SkPaint& pain
return m.getType() <= SkMatrix::kTranslate_Mask;
}
void SkBitmapDevice::drawBitmapRect(const SkBitmap& bitmap,
void SkBitmapDevice::drawImageRect(const SkImage* image,
const SkRect* src, const SkRect& dst,
const SkPaint& paint, SkCanvas::SrcRectConstraint constraint) {
SkASSERT(dst.isFinite());
SkASSERT(dst.isSorted());
SkBitmap bitmap;
if (!as_IB(image)->getROPixels(&bitmap)) {
return;
}
SkMatrix matrix;
SkRect bitmapBounds, tmpSrc, tmpDst;
SkBitmap tmpBitmap;
@ -542,10 +548,6 @@ void SkBitmapDevice::drawBitmapRect(const SkBitmap& bitmap,
this->drawRect(*dstPtr, paintWithShader);
}
void SkBitmapDevice::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& paint) {
BDDraw(this).drawSprite(bitmap, x, y, paint);
}
void SkBitmapDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
LOOP_TILER( drawGlyphRunList(glyphRunList, &fGlyphPainter), nullptr )
}
@ -573,7 +575,7 @@ void SkBitmapDevice::drawDevice(SkBaseDevice* device, int x, int y, const SkPain
draw.drawBitmap(*src->fCoverage.get(),
SkMatrix::MakeTrans(SkIntToScalar(x),SkIntToScalar(y)), nullptr, *paint);
} else {
this->drawSprite(src->fBitmap, x, y, *paint);
BDDraw(this).drawSprite(src->fBitmap, x, y, *paint);
}
}
@ -645,7 +647,7 @@ void SkBitmapDevice::drawSpecial(SkSpecialImage* src, int x, int y, const SkPain
if (!clipImage) {
SkBitmap resultBM;
if (src->getROPixels(&resultBM)) {
this->drawSprite(resultBM, x, y, *paint);
BDDraw(this).drawSprite(resultBM, x, y, *paint);
}
return;
}

View File

@ -89,14 +89,9 @@ protected:
* path on the stack to hold the representation of the oval.
*/
void drawPath(const SkPath&, const SkPaint&, bool pathIsMutable) override;
void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) override;
/**
* The default impl. will create a bitmap-shader from the bitmap,
* and call drawRect with it.
*/
void drawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&,
const SkPaint&, SkCanvas::SrcRectConstraint) override;
void drawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
const SkPaint&, SkCanvas::SrcRectConstraint) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
@ -135,8 +130,8 @@ protected:
ClipType onGetClipType() const override;
SkIRect onDevClipBounds() const override;
virtual void drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull,
const SkPaint&);
void drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull,
const SkPaint&);
private:
friend class SkCanvas;

View File

@ -2093,21 +2093,20 @@ void SkCanvas::drawImageLattice(const SkImage* image, const Lattice& lattice, co
}
}
void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, const SkPaint* paint) {
TRACE_EVENT0("skia", TRACE_FUNC);
static sk_sp<SkImage> bitmap_as_image(const SkBitmap& bitmap) {
if (bitmap.drawsNothing()) {
return;
return nullptr;
}
this->onDrawBitmap(bitmap, dx, dy, paint);
return SkImage::MakeFromBitmap(bitmap);
}
void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, const SkPaint* paint) {
this->drawImage(bitmap_as_image(bitmap), dx, dy, paint);
}
void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
TRACE_EVENT0("skia", TRACE_FUNC);
if (bitmap.drawsNothing() || dst.isEmpty() || src.isEmpty()) {
return;
}
this->onDrawBitmapRect(bitmap, &src, dst, paint, constraint);
this->drawImageRect(bitmap_as_image(bitmap), src, dst, paint, constraint);
}
void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst,
@ -2562,94 +2561,6 @@ void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk
DRAW_END
}
void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint* paint) {
SkDEBUGCODE(bitmap.validate();)
if (bitmap.drawsNothing()) {
return;
}
SkPaint realPaint;
init_image_paint(&realPaint, paint);
paint = &realPaint;
SkRect bounds;
bitmap.getBounds(&bounds);
bounds.offset(x, y);
bool canFastBounds = paint->canComputeFastBounds();
if (canFastBounds) {
SkRect storage;
if (this->quickReject(paint->computeFastBounds(bounds, &storage))) {
return;
}
}
sk_sp<SkSpecialImage> special;
bool drawAsSprite = canFastBounds && this->canDrawBitmapAsSprite(x, y, bitmap.width(),
bitmap.height(), *paint);
if (drawAsSprite && paint->getImageFilter()) {
special = this->getDevice()->makeSpecial(bitmap);
if (!special) {
drawAsSprite = false;
}
}
DRAW_BEGIN_DRAWBITMAP(*paint, drawAsSprite, &bounds)
while (iter.next()) {
const SkPaint& pnt = draw.paint();
if (special) {
SkPoint pt;
iter.fDevice->localToDevice().mapXY(x, y, &pt);
iter.fDevice->drawSpecial(special.get(),
SkScalarRoundToInt(pt.fX),
SkScalarRoundToInt(pt.fY), pnt,
nullptr, SkMatrix::I());
} else {
SkRect fullImage = SkRect::MakeWH(bitmap.width(), bitmap.height());
iter.fDevice->drawBitmapRect(bitmap, &fullImage, fullImage.makeOffset(x, y), pnt,
kStrict_SrcRectConstraint);
}
}
DRAW_END
}
// this one is non-virtual, so it can be called safely by other canvas apis
void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
SrcRectConstraint constraint) {
if (bitmap.drawsNothing() || dst.isEmpty()) {
return;
}
if (nullptr == paint || paint->canComputeFastBounds()) {
SkRect storage;
if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) : dst)) {
return;
}
}
SkLazyPaint lazy;
if (nullptr == paint) {
paint = lazy.init();
}
DRAW_BEGIN_CHECK_COMPLETE_OVERWRITE(*paint, &dst, bitmap.isOpaque())
while (iter.next()) {
iter.fDevice->drawBitmapRect(bitmap, src, dst, draw.paint(), constraint);
}
DRAW_END
}
void SkCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
SkDEBUGCODE(bitmap.validate();)
this->internalDrawBitmapRect(bitmap, src, dst, paint, constraint);
}
void SkCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
const SkPaint* paint) {
SkPaint realPaint;

View File

@ -159,15 +159,6 @@ void SkBaseDevice::drawPatch(const SkPoint cubics[12], const SkColor colors[4],
}
}
void SkBaseDevice::drawImageRect(const SkImage* image, const SkRect* src,
const SkRect& dst, const SkPaint& paint,
SkCanvas::SrcRectConstraint constraint) {
SkBitmap bm;
if (as_IB(image)->getROPixels(&bm)) {
this->drawBitmapRect(bm, src, dst, paint, constraint);
}
}
void SkBaseDevice::drawImageNine(const SkImage* image, const SkIRect& center,
const SkRect& dst, const SkPaint& paint) {
SkLatticeIter iter(image->width(), image->height(), center, dst);
@ -178,16 +169,6 @@ void SkBaseDevice::drawImageNine(const SkImage* image, const SkIRect& center,
}
}
void SkBaseDevice::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint& paint) {
SkLatticeIter iter(bitmap.width(), bitmap.height(), center, dst);
SkRect srcR, dstR;
while (iter.next(&srcR, &dstR)) {
this->drawBitmapRect(bitmap, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
}
}
void SkBaseDevice::drawImageLattice(const SkImage* image,
const SkCanvas::Lattice& lattice, const SkRect& dst,
const SkPaint& paint) {
@ -215,17 +196,6 @@ void SkBaseDevice::drawImageLattice(const SkImage* image,
}
}
void SkBaseDevice::drawBitmapLattice(const SkBitmap& bitmap,
const SkCanvas::Lattice& lattice, const SkRect& dst,
const SkPaint& paint) {
SkLatticeIter iter(lattice, dst);
SkRect srcR, dstR;
while (iter.next(&srcR, &dstR)) {
this->drawBitmapRect(bitmap, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
}
}
static SkPoint* quad_to_tris(SkPoint tris[6], const SkPoint quad[4]) {
tris[0] = quad[0];
tris[1] = quad[1];

View File

@ -242,24 +242,9 @@ protected:
virtual void drawPath(const SkPath& path,
const SkPaint& paint,
bool pathIsMutable = false) = 0;
virtual void drawSprite(const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) = 0;
/**
* The default impl. will create a bitmap-shader from the bitmap,
* and call drawRect with it.
*/
virtual void drawBitmapRect(const SkBitmap&,
const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint,
SkCanvas::SrcRectConstraint) = 0;
virtual void drawBitmapNine(const SkBitmap&, const SkIRect& center,
const SkRect& dst, const SkPaint&);
virtual void drawBitmapLattice(const SkBitmap&, const SkCanvas::Lattice&,
const SkRect& dst, const SkPaint&);
virtual void drawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
const SkPaint&, SkCanvas::SrcRectConstraint);
const SkPaint&, SkCanvas::SrcRectConstraint) = 0;
virtual void drawImageNine(const SkImage*, const SkIRect& center,
const SkRect& dst, const SkPaint&);
virtual void drawImageLattice(const SkImage*, const SkCanvas::Lattice&,
@ -494,13 +479,12 @@ protected:
void drawPaint(const SkPaint& paint) override {}
void drawPoints(SkCanvas::PointMode, size_t, const SkPoint[], const SkPaint&) override {}
void drawImageRect(const SkImage*, const SkRect*, const SkRect&,
const SkPaint&, SkCanvas::SrcRectConstraint) override {}
void drawRect(const SkRect&, const SkPaint&) override {}
void drawOval(const SkRect&, const SkPaint&) override {}
void drawRRect(const SkRRect&, const SkPaint&) override {}
void drawPath(const SkPath&, const SkPaint&, bool) override {}
void drawSprite(const SkBitmap&, int, int, const SkPaint&) override {}
void drawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint&,
SkCanvas::SrcRectConstraint) override {}
void drawDevice(SkBaseDevice*, int, int, const SkPaint&) override {}
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override {}
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override {}

View File

@ -202,16 +202,6 @@ void SkOverdrawCanvas::onDrawImageLattice(const SkImage* image, const Lattice& l
}
}
void SkOverdrawCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
const SkPaint*) {
fList[0]->onDrawRect(SkRect::MakeXYWH(x, y, bitmap.width(), bitmap.height()), fPaint);
}
void SkOverdrawCanvas::onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect& dst,
const SkPaint*, SrcRectConstraint) {
fList[0]->onDrawRect(dst, fPaint);
}
void SkOverdrawCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
drawable->draw(this, matrix);
}

View File

@ -235,15 +235,6 @@ protected:
void recordSaveLayer(const SaveLayerRec&);
void recordRestore(bool fillInSkips = true);
// SHOULD NEVER BE CALLED
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override {
SK_ABORT("not reached");
}
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
SrcRectConstraint) override {
SK_ABORT("not reached");
}
private:
SkTArray<SkPaint> fPaints;

View File

@ -193,27 +193,6 @@ void SkRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) {
this->append<SkRecords::DrawPath>(paint, path);
}
void SkRecorder::onDrawBitmap(const SkBitmap& bitmap,
SkScalar left,
SkScalar top,
const SkPaint* paint) {
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
if (image) {
this->onDrawImage(image.get(), left, top, paint);
}
}
void SkRecorder::onDrawBitmapRect(const SkBitmap& bitmap,
const SkRect* src,
const SkRect& dst,
const SkPaint* paint,
SrcRectConstraint constraint) {
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
if (image) {
this->onDrawImageRect(image.get(), src, dst, paint, constraint);
}
}
void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
const SkPaint* paint) {
this->append<SkRecords::DrawImage>(this->copy(paint), sk_ref_sp(image), left, top);

View File

@ -92,9 +92,6 @@ public:
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
void onDrawRRect(const SkRRect&, const SkPaint&) override;
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
SrcRectConstraint) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
const SkPaint*, SrcRectConstraint) override;

View File

@ -632,23 +632,6 @@ void SkGpuDevice::drawPath(const SkPath& origSrcPath, const SkPaint& paint, bool
paint, this->localToDevice(), shape);
}
void SkGpuDevice::drawSprite(const SkBitmap& bitmap,
int left, int top, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawSprite", fContext.get());
if (fContext->priv().abandoned()) {
return;
}
sk_sp<SkSpecialImage> srcImg = this->makeSpecial(bitmap);
if (!srcImg) {
return;
}
this->drawSpecial(srcImg.get(), left, top, paint, nullptr, SkMatrix::I());
}
void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const SkPaint& paint,
SkImage* clipImage, const SkMatrix& clipMatrix) {
SkASSERT(!paint.getMaskFilter());
@ -759,13 +742,6 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const
GrAA(paint.isAntiAlias()), SkMatrix::I(), dstRect, srcRect);
}
void SkGpuDevice::drawBitmapRect(const SkBitmap& bitmap,
const SkRect* src, const SkRect& origDst,
const SkPaint& paint, SkCanvas::SrcRectConstraint constraint) {
sk_sp<SkImage> asImage = SkMakeImageFromRasterBitmap(bitmap, kNever_SkCopyPixelsMode);
this->drawImageRect(asImage.get(), src, origDst, paint, constraint);
}
sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) {
// TODO: this makes a tight copy of 'bitmap' but it doesn't have to be (given SkSpecialImage's
// semantics). Since this is cached we would have to bake the fit into the cache key though.
@ -913,14 +889,6 @@ void SkGpuDevice::drawImageNine(const SkImage* image,
}
}
void SkGpuDevice::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
auto iter = std::make_unique<SkLatticeIter>(bitmap.width(), bitmap.height(), center, dst);
GrBitmapTextureMaker maker(fContext.get(), bitmap, GrBitmapTextureMaker::Cached::kYes);
this->drawProducerLattice(&maker, std::move(iter), dst, paint);
}
void SkGpuDevice::drawProducerLattice(GrTextureProducer* producer,
std::unique_ptr<SkLatticeIter> iter, const SkRect& dst,
const SkPaint& origPaint) {
@ -972,15 +940,6 @@ void SkGpuDevice::drawImageLattice(const SkImage* image,
}
}
void SkGpuDevice::drawBitmapLattice(const SkBitmap& bitmap,
const SkCanvas::Lattice& lattice, const SkRect& dst,
const SkPaint& paint) {
ASSERT_SINGLE_OWNER
auto iter = std::make_unique<SkLatticeIter>(lattice, dst);
GrBitmapTextureMaker maker(fContext.get(), bitmap, GrBitmapTextureMaker::Cached::kYes);
this->drawProducerLattice(&maker, std::move(iter), dst, paint);
}
static bool init_vertices_paint(GrContext* context, const GrColorInfo& colorInfo,
const SkPaint& skPaint, const SkMatrix& matrix, SkBlendMode bmode,
bool hasTexs, bool hasColors, GrPaint* grPaint) {

View File

@ -82,32 +82,24 @@ public:
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 drawBitmapRect(const SkBitmap&, const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint, SkCanvas::SrcRectConstraint) override;
void drawSprite(const SkBitmap& bitmap, int x, int y,
const SkPaint& paint) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
void drawShadow(const SkPath&, const SkDrawShadowRec&) override;
void drawAtlas(const SkImage* atlas, const SkRSXform[], const SkRect[],
const SkColor[], int count, SkBlendMode, const SkPaint&) override;
void drawDevice(SkBaseDevice*, int x, int y, const SkPaint&) override;
void drawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
const SkPaint&, SkCanvas::SrcRectConstraint) override;
void drawImageNine(const SkImage* image, const SkIRect& center,
const SkRect& dst, const SkPaint& paint) override;
void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint& paint) override;
void drawImageLattice(const SkImage*, const SkCanvas::Lattice&,
const SkRect& dst, const SkPaint&) override;
void drawBitmapLattice(const SkBitmap&, const SkCanvas::Lattice&,
const SkRect& dst, const SkPaint&) override;
void drawDrawable(SkDrawable*, const SkMatrix*, SkCanvas* canvas) override;
void drawDevice(SkBaseDevice*, int x, int y, const SkPaint&) override;
void drawSpecial(SkSpecialImage*, int left, int top, const SkPaint& paint,
SkImage*, const SkMatrix&) override;

View File

@ -643,15 +643,6 @@ void SkPDFDevice::drawImageRect(const SkImage* image,
src, dst, paint, this->localToDevice());
}
void SkPDFDevice::drawBitmapRect(const SkBitmap& bm,
const SkRect* src,
const SkRect& dst,
const SkPaint& paint,
SkCanvas::SrcRectConstraint) {
SkASSERT(!bm.drawsNothing());
this->internalDrawImageRect(SkKeyedImage(bm), src, dst, paint, this->localToDevice());
}
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());

View File

@ -77,10 +77,6 @@ public:
void drawOval(const SkRect& oval, const SkPaint& paint) override;
void drawRRect(const SkRRect& rr, const SkPaint& paint) override;
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 drawSprite(const SkBitmap& bitmap, int x, int y,
const SkPaint& paint) override;
void drawImageRect(const SkImage*,
const SkRect* src,
@ -93,6 +89,8 @@ public:
const SkPaint&) override;
// PDF specific methods.
void drawSprite(const SkBitmap& bitmap, int x, int y,
const SkPaint& paint);
/** Create the resource dictionary for this device. Destructive. */
std::unique_ptr<SkPDFDict> makeResourceDict();

View File

@ -30,6 +30,7 @@
#include "src/core/SkDraw.h"
#include "src/core/SkFontPriv.h"
#include "src/core/SkUtils.h"
#include "src/image/SkImage_Base.h"
#include "src/shaders/SkShaderBase.h"
#include "src/xml/SkXMLWriter.h"
@ -917,28 +918,22 @@ void SkSVGDevice::drawBitmapCommon(const MxCp& mc, const SkBitmap& bm, const SkP
}
}
void SkSVGDevice::drawSprite(const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) {
MxCp mc(this);
SkMatrix adjustedMatrix = *mc.fMatrix;
adjustedMatrix.preTranslate(SkIntToScalar(x), SkIntToScalar(y));
mc.fMatrix = &adjustedMatrix;
void SkSVGDevice::drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint& paint, SkCanvas::SrcRectConstraint constraint) {
SkBitmap bm;
if (!as_IB(image)->getROPixels(&bm)) {
return;
}
drawBitmapCommon(mc, bitmap, paint);
}
void SkSVGDevice::drawBitmapRect(const SkBitmap& bm, const SkRect* srcOrNull,
const SkRect& dst, const SkPaint& paint,
SkCanvas::SrcRectConstraint) {
SkClipStack* cs = &this->cs();
SkClipStack::AutoRestore ar(cs, false);
if (srcOrNull && *srcOrNull != SkRect::Make(bm.bounds())) {
if (src && *src != SkRect::Make(bm.bounds())) {
cs->save();
cs->clipRect(dst, this->localToDevice(), kIntersect_SkClipOp, paint.isAntiAlias());
}
SkMatrix adjustedMatrix;
adjustedMatrix.setRectToRect(srcOrNull ? *srcOrNull : SkRect::Make(bm.bounds()),
adjustedMatrix.setRectToRect(src ? *src : SkRect::Make(bm.bounds()),
dst,
SkMatrix::kFill_ScaleToFit);
adjustedMatrix.postConcat(this->localToDevice());

View File

@ -24,6 +24,8 @@ protected:
void drawAnnotation(const SkRect& rect, const char key[], SkData* value) override;
void drawPoints(SkCanvas::PointMode mode, size_t count,
const SkPoint[], const SkPaint& paint) override;
void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint& paint, SkCanvas::SrcRectConstraint constraint) override;
void drawRect(const SkRect& r, const SkPaint& paint) override;
void drawOval(const SkRect& oval, const SkPaint& paint) override;
void drawRRect(const SkRRect& rr, const SkPaint& paint) override;
@ -31,11 +33,6 @@ protected:
const SkPaint& paint,
bool pathIsMutable = false) override;
void drawSprite(const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) override;
void drawBitmapRect(const SkBitmap&,
const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint, SkCanvas::SrcRectConstraint) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;

View File

@ -234,22 +234,6 @@ void SkLuaCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
lua.pushPaint(paint, "paint");
}
void SkLuaCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
const SkPaint* paint) {
AUTO_LUA("drawBitmap");
if (paint) {
lua.pushPaint(*paint, "paint");
}
}
void SkLuaCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint) {
AUTO_LUA("drawBitmapRect");
if (paint) {
lua.pushPaint(*paint, "paint");
}
}
void SkLuaCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const SkPaint* paint) {
AUTO_LUA("drawImage");
if (paint) {

View File

@ -240,22 +240,6 @@ void SkNWayCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
}
}
void SkNWayCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
const SkPaint* paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawBitmap(bitmap, x, y, paint);
}
}
void SkNWayCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
Iter iter(fList);
while (iter.next()) {
iter->legacy_drawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
}
}
void SkNWayCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
const SkPaint* paint) {
Iter iter(fList);

View File

@ -115,22 +115,6 @@ void SkPaintFilterCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
}
}
void SkPaintFilterCanvas::onDrawBitmap(const SkBitmap& bm, SkScalar left, SkScalar top,
const SkPaint* paint) {
AutoPaintFilter apf(this, paint);
if (apf.shouldDraw()) {
this->SkNWayCanvas::onDrawBitmap(bm, left, top, &apf.paint());
}
}
void SkPaintFilterCanvas::onDrawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
AutoPaintFilter apf(this, paint);
if (apf.shouldDraw()) {
this->SkNWayCanvas::onDrawBitmapRect(bm, src, dst, &apf.paint(), constraint);
}
}
void SkPaintFilterCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
const SkPaint* paint) {
AutoPaintFilter apf(this, paint);

View File

@ -46,6 +46,7 @@
#include "src/core/SkTLazy.h"
#include "src/core/SkTypefacePriv.h"
#include "src/core/SkUtils.h"
#include "src/image/SkImage_Base.h"
#include "src/sfnt/SkSFNTHeader.h"
#include "src/sfnt/SkTTCFHeader.h"
#include "src/shaders/SkShaderBase.h"
@ -1712,11 +1713,6 @@ HRESULT SkXPSDevice::clipToPath(IXpsOMVisual* xpsVisual,
return S_OK;
}
void SkXPSDevice::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& paint) {
//TODO: override this for XPS
SkDEBUGF("XPS drawSprite not yet implemented.");
}
HRESULT SkXPSDevice::CreateTypefaceUse(const SkFont& font,
TypefaceUse** typefaceUse) {
SkAutoResolveDefaultTypeface typeface(font.getTypeface());
@ -1988,11 +1984,16 @@ void SkXPSDevice::drawOval( const SkRect& o, const SkPaint& p) {
this->drawPath(path, p, true);
}
void SkXPSDevice::drawBitmapRect(const SkBitmap& bitmap,
const SkRect* src,
const SkRect& dst,
const SkPaint& paint,
SkCanvas::SrcRectConstraint constraint) {
void SkXPSDevice::drawImageRect(const SkImage* image,
const SkRect* src,
const SkRect& dst,
const SkPaint& paint,
SkCanvas::SrcRectConstraint constraint) {
SkBitmap bitmap;
if (!as_IB(image)->getROPixels(&bitmap)) {
return;
}
SkRect bitmapBounds = SkRect::Make(bitmap.bounds());
SkRect srcBounds = src ? *src : bitmapBounds;
SkMatrix matrix = SkMatrix::MakeRectToRect(srcBounds, dst, SkMatrix::kFill_ScaleToFit);
@ -2005,6 +2006,7 @@ void SkXPSDevice::drawBitmapRect(const SkBitmap& bitmap,
}
matrix.mapRect(&actualDst, srcBounds);
}
auto bitmapShader = SkMakeBitmapShaderForPaint(paint, bitmap, SkTileMode::kClamp,
SkTileMode::kClamp, &matrix,
kNever_SkCopyPixelsMode);

View File

@ -88,12 +88,10 @@ protected:
void drawPath(const SkPath& path,
const SkPaint& paint,
bool pathIsMutable = false) override;
void drawSprite(const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) override;
void drawBitmapRect(const SkBitmap&,
const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint,
SkCanvas::SrcRectConstraint) override;
void drawImageRect(const SkImage*,
const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint,
SkCanvas::SrcRectConstraint) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
void drawDevice(SkBaseDevice*, int x, int y,

View File

@ -367,22 +367,6 @@ void DebugCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData*
this->addDrawCommand(new DrawAnnotationCommand(rect, key, sk_ref_sp(value)));
}
void DebugCanvas::onDrawBitmap(const SkBitmap& bitmap,
SkScalar left,
SkScalar top,
const SkPaint* paint) {
this->addDrawCommand(new DrawBitmapCommand(bitmap, left, top, paint));
}
void DebugCanvas::onDrawBitmapRect(const SkBitmap& bitmap,
const SkRect* src,
const SkRect& dst,
const SkPaint* paint,
SrcRectConstraint constraint) {
this->addDrawCommand(
new DrawBitmapRectCommand(bitmap, src, dst, paint, (SrcRectConstraint)constraint));
}
void DebugCanvas::onDrawImage(const SkImage* image,
SkScalar left,
SkScalar top,

View File

@ -165,12 +165,6 @@ protected:
#endif
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawRegion(const SkRegion&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&,
const SkRect* src,
const SkRect& dst,
const SkPaint*,
SrcRectConstraint) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageLattice(const SkImage* image,
const Lattice& lattice,

View File

@ -315,53 +315,6 @@ void render_region(SkCanvas* canvas, const SkRegion& region) {
canvas->drawRegion(region, p);
}
void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRect = nullptr) {
const SkISize& size = canvas->getBaseLayerSize();
SkScalar xScale = SkIntToScalar(size.fWidth - 2) / input.width();
SkScalar yScale = SkIntToScalar(size.fHeight - 2) / input.height();
if (input.width() > input.height()) {
yScale *= input.height() / (float)input.width();
} else {
xScale *= input.width() / (float)input.height();
}
SkRect dst = SkRect::MakeXYWH(
SK_Scalar1, SK_Scalar1, xScale * input.width(), yScale * input.height());
static const int kNumBlocks = 8;
canvas->clear(0xFFFFFFFF);
SkISize block = {canvas->imageInfo().width() / kNumBlocks,
canvas->imageInfo().height() / kNumBlocks};
for (int y = 0; y < kNumBlocks; ++y) {
for (int x = 0; x < kNumBlocks; ++x) {
SkPaint paint;
paint.setColor((x + y) % 2 ? SK_ColorLTGRAY : SK_ColorDKGRAY);
SkRect r = SkRect::MakeXYWH(SkIntToScalar(x * block.width()),
SkIntToScalar(y * block.height()),
SkIntToScalar(block.width()),
SkIntToScalar(block.height()));
canvas->drawRect(r, paint);
}
}
canvas->drawBitmapRect(input, dst, nullptr);
if (srcRect) {
SkRect r = SkRect::MakeLTRB(srcRect->fLeft * xScale + SK_Scalar1,
srcRect->fTop * yScale + SK_Scalar1,
srcRect->fRight * xScale + SK_Scalar1,
srcRect->fBottom * yScale + SK_Scalar1);
SkPaint p;
p.setColor(SK_ColorRED);
p.setStyle(SkPaint::kStroke_Style);
canvas->drawRect(r, p);
}
}
void render_rrect(SkCanvas* canvas, const SkRRect& rrect) {
canvas->clear(0xFFFFFFFF);
canvas->save();
@ -1156,80 +1109,6 @@ void DrawAnnotationCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlData
////
DrawBitmapCommand::DrawBitmapCommand(const SkBitmap& bitmap,
SkScalar left,
SkScalar top,
const SkPaint* paint)
: INHERITED(kDrawBitmap_OpType), fBitmap(bitmap), fLeft(left), fTop(top), fPaint(paint) {}
void DrawBitmapCommand::execute(SkCanvas* canvas) const {
canvas->drawBitmap(fBitmap, fLeft, fTop, fPaint.getMaybeNull());
}
bool DrawBitmapCommand::render(SkCanvas* canvas) const {
render_bitmap(canvas, fBitmap);
return true;
}
void DrawBitmapCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
INHERITED::toJSON(writer, urlDataManager);
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_BITMAP);
flatten(fBitmap, writer, urlDataManager);
writer.endObject();
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
MakeJsonPoint(writer, fLeft, fTop);
if (fPaint.isValid()) {
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
MakeJsonPaint(writer, *fPaint, urlDataManager);
}
}
DrawBitmapRectCommand::DrawBitmapRectCommand(const SkBitmap& bitmap,
const SkRect* src,
const SkRect& dst,
const SkPaint* paint,
SkCanvas::SrcRectConstraint constraint)
: INHERITED(kDrawBitmapRect_OpType)
, fBitmap(bitmap)
, fSrc(src)
, fDst(dst)
, fPaint(paint)
, fConstraint(constraint) {}
void DrawBitmapRectCommand::execute(SkCanvas* canvas) const {
canvas->legacy_drawBitmapRect(
fBitmap, fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(), fConstraint);
}
bool DrawBitmapRectCommand::render(SkCanvas* canvas) const {
render_bitmap(canvas, fBitmap, fSrc.getMaybeNull());
return true;
}
void DrawBitmapRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
INHERITED::toJSON(writer, urlDataManager);
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_BITMAP);
flatten(fBitmap, writer, urlDataManager);
writer.endObject(); // bitmap
if (fSrc.isValid()) {
writer.appendName(DEBUGCANVAS_ATTRIBUTE_SRC);
MakeJsonRect(writer, *fSrc);
}
writer.appendName(DEBUGCANVAS_ATTRIBUTE_DST);
MakeJsonRect(writer, fDst);
if (fPaint.isValid()) {
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
MakeJsonPaint(writer, *fPaint, urlDataManager);
}
if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
writer.appendBool(DEBUGCANVAS_ATTRIBUTE_STRICT, true);
}
SkString desc;
writer.appendString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, str_append(&desc, fDst)->c_str());
}
DrawImageCommand::DrawImageCommand(const SkImage* image,
SkScalar left,
SkScalar top,

View File

@ -235,43 +235,6 @@ private:
typedef DrawCommand INHERITED;
};
class DrawBitmapCommand : public DrawCommand {
public:
DrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top, const SkPaint* paint);
void execute(SkCanvas* canvas) const override;
bool render(SkCanvas* canvas) const override;
void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
private:
SkBitmap fBitmap;
SkScalar fLeft;
SkScalar fTop;
SkTLazy<SkPaint> fPaint;
typedef DrawCommand INHERITED;
};
class DrawBitmapRectCommand : public DrawCommand {
public:
DrawBitmapRectCommand(const SkBitmap& bitmap,
const SkRect* src,
const SkRect& dst,
const SkPaint* paint,
SkCanvas::SrcRectConstraint);
void execute(SkCanvas* canvas) const override;
bool render(SkCanvas* canvas) const override;
void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
private:
SkBitmap fBitmap;
SkTLazy<SkRect> fSrc;
SkRect fDst;
SkTLazy<SkPaint> fPaint;
SkCanvas::SrcRectConstraint fConstraint;
typedef DrawCommand INHERITED;
};
class DrawImageCommand : public DrawCommand {
public:
DrawImageCommand(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint);