Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
DrawImageCommand Class Reference

#include <DrawCommand.h>

Inheritance diagram for DrawImageCommand:
DrawCommand

Public Member Functions

 DrawImageCommand (const SkImage *image, SkScalar left, SkScalar top, const SkSamplingOptions &, const SkPaint *paint)
 
void execute (SkCanvas *canvas) const override
 
bool render (SkCanvas *canvas) const override
 
void toJSON (SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
 
uint64_t imageId (UrlDataManager &udb) const
 
- Public Member Functions inherited from DrawCommand
 DrawCommand (OpType opType)
 
virtual ~DrawCommand ()
 
bool isVisible () const
 
void setVisible (bool toggle)
 
virtual void execute (SkCanvas *) const =0
 
virtual bool render (SkCanvas *canvas) const
 
virtual void toJSON (SkJSONWriter &writer, UrlDataManager &urlDataManager) const
 
OpType getOpType () const
 

Additional Inherited Members

- Public Types inherited from DrawCommand
enum  OpType {
  kBeginDrawPicture_OpType , kClear_OpType , kClipPath_OpType , kClipRegion_OpType ,
  kClipRect_OpType , kClipRRect_OpType , kClipShader_OpType , kResetClip_OpType ,
  kConcat_OpType , kConcat44_OpType , kDrawAnnotation_OpType , kDrawBitmap_OpType ,
  kDrawBitmapRect_OpType , kDrawDRRect_OpType , kDrawImage_OpType , kDrawImageLattice_OpType ,
  kDrawImageRect_OpType , kDrawImageRectLayer_OpType , kDrawOval_OpType , kDrawArc_OpType ,
  kDrawPaint_OpType , kDrawPatch_OpType , kDrawPath_OpType , kDrawPoints_OpType ,
  kDrawRect_OpType , kDrawRRect_OpType , kDrawRegion_OpType , kDrawShadow_OpType ,
  kDrawTextBlob_OpType , kDrawVertices_OpType , kDrawAtlas_OpType , kDrawDrawable_OpType ,
  kDrawEdgeAAQuad_OpType , kDrawEdgeAAImageSet_OpType , kEndDrawPicture_OpType , kRestore_OpType ,
  kSave_OpType , kSaveLayer_OpType , kSetMatrix_OpType , kSetM44_OpType ,
  kLast_OpType = kSetM44_OpType
}
 
- Static Public Member Functions inherited from DrawCommand
static void WritePNG (const SkBitmap &bitmap, SkWStream &out)
 
static const char * GetCommandString (OpType type)
 
static void MakeJsonColor (SkJSONWriter &, const SkColor color)
 
static void MakeJsonColor4f (SkJSONWriter &, const SkColor4f &color)
 
static void MakeJsonPoint (SkJSONWriter &, const SkPoint &point)
 
static void MakeJsonPoint (SkJSONWriter &, SkScalar x, SkScalar y)
 
static void MakeJsonPoint3 (SkJSONWriter &, const SkPoint3 &point)
 
static void MakeJsonRect (SkJSONWriter &, const SkRect &rect)
 
static void MakeJsonIRect (SkJSONWriter &, const SkIRect &)
 
static void MakeJsonMatrix (SkJSONWriter &, const SkMatrix &)
 
static void MakeJsonMatrix44 (SkJSONWriter &, const SkM44 &)
 
static void MakeJsonPath (SkJSONWriter &, const SkPath &path)
 
static void MakeJsonRegion (SkJSONWriter &, const SkRegion &region)
 
static void MakeJsonSampling (SkJSONWriter &, const SkSamplingOptions &sampling)
 
static void MakeJsonPaint (SkJSONWriter &, const SkPaint &paint, UrlDataManager &urlDataManager)
 
static void MakeJsonLattice (SkJSONWriter &, const SkCanvas::Lattice &lattice)
 
static void flatten (const SkFlattenable *flattenable, SkJSONWriter &writer, UrlDataManager &urlDataManager)
 
static bool flatten (const SkImage &image, SkJSONWriter &writer, UrlDataManager &urlDataManager)
 
static bool flatten (const SkBitmap &bitmap, SkJSONWriter &writer, UrlDataManager &urlDataManager)
 
- Static Public Attributes inherited from DrawCommand
static const int kOpTypeCount = kLast_OpType + 1
 

Detailed Description

Definition at line 289 of file DrawCommand.h.

Constructor & Destructor Documentation

◆ DrawImageCommand()

DrawImageCommand::DrawImageCommand ( const SkImage image,
SkScalar  left,
SkScalar  top,
const SkSamplingOptions sampling,
const SkPaint paint 
)

Definition at line 1193 of file DrawCommand.cpp.

1198 : INHERITED(kDrawImage_OpType)
1199 , fImage(SkRef(image))
1200 , fLeft(left)
1201 , fTop(top)
1202 , fSampling(sampling)
1203 , fPaint(paint) {}
static bool left(const SkPoint &p0, const SkPoint &p1)
static T * SkRef(T *obj)
Definition: SkRefCnt.h:132
@ kDrawImage_OpType
Definition: DrawCommand.h:70
const Paint & paint
Definition: color_source.cc:38
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SkSamplingOptions sampling
Definition: SkRecords.h:337

Member Function Documentation

◆ execute()

void DrawImageCommand::execute ( SkCanvas canvas) const
overridevirtual

Implements DrawCommand.

Definition at line 1205 of file DrawCommand.cpp.

1205 {
1206 canvas->drawImage(fImage.get(), fLeft, fTop, fSampling, fPaint.getMaybeNull());
1207}
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
const T * getMaybeNull() const
Definition: SkTLazy.h:108
T * get() const
Definition: SkRefCnt.h:303

◆ imageId()

uint64_t DrawImageCommand::imageId ( UrlDataManager udb) const

Definition at line 1221 of file DrawCommand.cpp.

1221 {
1222 return udm.lookupImage(fImage.get());
1223}

◆ render()

bool DrawImageCommand::render ( SkCanvas canvas) const
overridevirtual

Reimplemented from DrawCommand.

Definition at line 1209 of file DrawCommand.cpp.

1209 {
1210 SkAutoCanvasRestore acr(canvas, true);
1211 canvas->clear(0xFFFFFFFF);
1212
1213 xlate_and_scale_to_bounds(
1214 canvas,
1216 fLeft, fTop, SkIntToScalar(fImage->width()), SkIntToScalar(fImage->height())));
1217 this->execute(canvas);
1218 return true;
1219}
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void execute(SkCanvas *canvas) const override
void clear(SkColor color)
Definition: SkCanvas.h:1199
int width() const
Definition: SkImage.h:285
int height() const
Definition: SkImage.h:291
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ toJSON()

void DrawImageCommand::toJSON ( SkJSONWriter writer,
UrlDataManager urlDataManager 
) const
overridevirtual

Reimplemented from DrawCommand.

Definition at line 1225 of file DrawCommand.cpp.

1225 {
1226 INHERITED::toJSON(writer, urlDataManager);
1227 flatten(*fImage, writer, urlDataManager);
1229 MakeJsonPoint(writer, fLeft, fTop);
1230 if (fPaint.isValid()) {
1232 MakeJsonPaint(writer, *fPaint, urlDataManager);
1233 }
1235 MakeJsonSampling(writer, fSampling);
1236
1238 writer.appendS32(DEBUGCANVAS_ATTRIBUTE_WIDTH, fImage->width());
1240 switch (fImage->alphaType()) {
1243 break;
1246 break;
1249 break;
1250 default:
1252 break;
1253 }
1254}
#define DEBUGCANVAS_ALPHATYPE_OPAQUE
#define DEBUGCANVAS_ATTRIBUTE_ALPHA
#define DEBUGCANVAS_ATTRIBUTE_WIDTH
#define DEBUGCANVAS_ATTRIBUTE_HEIGHT
#define DEBUGCANVAS_ALPHATYPE_UNPREMUL
#define DEBUGCANVAS_ATTRIBUTE_PAINT
Definition: DrawCommand.cpp:73
#define DEBUGCANVAS_ALPHATYPE_UNKNOWN
#define DEBUGCANVAS_ATTRIBUTE_UNIQUE_ID
#define DEBUGCANVAS_ALPHATYPE_PREMUL
#define DEBUGCANVAS_ATTRIBUTE_SAMPLING
Definition: DrawCommand.cpp:84
#define DEBUGCANVAS_ATTRIBUTE_COORDS
Definition: DrawCommand.cpp:69
kUnpremul_SkAlphaType
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
static void MakeJsonPoint(SkJSONWriter &, const SkPoint &point)
static void MakeJsonPaint(SkJSONWriter &, const SkPaint &paint, UrlDataManager &urlDataManager)
virtual void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const
static void flatten(const SkFlattenable *flattenable, SkJSONWriter &writer, UrlDataManager &urlDataManager)
static void MakeJsonSampling(SkJSONWriter &, const SkSamplingOptions &sampling)
uint32_t uniqueID() const
Definition: SkImage.h:311
SkAlphaType alphaType() const
Definition: SkImage.cpp:154
void appendS32(int32_t value)
Definition: SkJSONWriter.h:237
void appendNString(char const (&value)[N])
Definition: SkJSONWriter.h:220
void appendU32(uint32_t value)
Definition: SkJSONWriter.h:239
void appendName(const char *name)
Definition: SkJSONWriter.h:90
bool isValid() const
Definition: SkTLazy.h:77

The documentation for this class was generated from the following files: