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

#include <SkKeyedImage.h>

Public Member Functions

 SkKeyedImage ()
 
 SkKeyedImage (sk_sp< SkImage >)
 
 SkKeyedImage (const SkBitmap &)
 
 SkKeyedImage (SkKeyedImage &&)=default
 
 SkKeyedImage (const SkKeyedImage &)=default
 
SkKeyedImageoperator= (SkKeyedImage &&)=default
 
SkKeyedImageoperator= (const SkKeyedImage &)=default
 
 operator bool () const
 
const SkBitmapKeykey () const
 
const sk_sp< SkImage > & image () const
 
sk_sp< SkImagerelease ()
 
SkKeyedImage subset (SkIRect subset) const
 

Detailed Description

This class has all the advantages of SkBitmaps and SkImages.

The SkImage holds on to encoded data. The SkBitmapKey properly de-dups subsets.

Definition at line 22 of file SkKeyedImage.h.

Constructor & Destructor Documentation

◆ SkKeyedImage() [1/5]

SkKeyedImage::SkKeyedImage ( )
inline

Definition at line 24 of file SkKeyedImage.h.

24{}

◆ SkKeyedImage() [2/5]

SkKeyedImage::SkKeyedImage ( sk_sp< SkImage i)

Definition at line 29 of file SkKeyedImage.cpp.

29 : fImage(std::move(i)) {
30 fKey = SkBitmapKeyFromImage(fImage.get());
31}
SkBitmapKey SkBitmapKeyFromImage(const SkImage *image)
T * get() const
Definition: SkRefCnt.h:303

◆ SkKeyedImage() [3/5]

SkKeyedImage::SkKeyedImage ( const SkBitmap bm)

Definition at line 33 of file SkKeyedImage.cpp.

33 : fImage(bm.asImage()) {
34 if (fImage) {
35 fKey = {bm.getSubset(), bm.getGenerationID()};
36 }
37}
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
SkIRect getSubset() const
Definition: SkBitmap.h:394
uint32_t getGenerationID() const
Definition: SkBitmap.cpp:361

◆ SkKeyedImage() [4/5]

SkKeyedImage::SkKeyedImage ( SkKeyedImage &&  )
default

◆ SkKeyedImage() [5/5]

SkKeyedImage::SkKeyedImage ( const SkKeyedImage )
default

Member Function Documentation

◆ image()

const sk_sp< SkImage > & SkKeyedImage::image ( ) const
inline

Definition at line 35 of file SkKeyedImage.h.

35{ return fImage; }

◆ key()

const SkBitmapKey & SkKeyedImage::key ( ) const
inline

Definition at line 34 of file SkKeyedImage.h.

34{ return fKey; }

◆ operator bool()

SkKeyedImage::operator bool ( ) const
inlineexplicit

Definition at line 33 of file SkKeyedImage.h.

33{ return fImage != nullptr; }

◆ operator=() [1/2]

SkKeyedImage & SkKeyedImage::operator= ( const SkKeyedImage )
default

◆ operator=() [2/2]

SkKeyedImage & SkKeyedImage::operator= ( SkKeyedImage &&  )
default

◆ release()

sk_sp< SkImage > SkKeyedImage::release ( )

Definition at line 50 of file SkKeyedImage.cpp.

50 {
51 sk_sp<SkImage> image = std::move(fImage);
52 SkASSERT(nullptr == fImage);
53 fKey = {{0, 0, 0, 0}, 0};
54 return image;
55}
#define SkASSERT(cond)
Definition: SkAssert.h:116
const sk_sp< SkImage > & image() const
Definition: SkKeyedImage.h:35

◆ subset()

SkKeyedImage SkKeyedImage::subset ( SkIRect  subset) const

Definition at line 39 of file SkKeyedImage.cpp.

39 {
40 SkKeyedImage img;
41 if (fImage && subset.intersect(fImage->bounds())) {
42 img.fImage = fImage->makeSubset(nullptr, subset);
43 if (img.fImage) {
44 img.fKey = {subset.makeOffset(fKey.fSubset.topLeft()), fKey.fID};
45 }
46 }
47 return img;
48}
SkIRect bounds() const
Definition: SkImage.h:303
virtual sk_sp< SkImage > makeSubset(GrDirectContext *direct, const SkIRect &subset) const =0
SkKeyedImage subset(SkIRect subset) const
uint32_t fID
Definition: SkBitmapKey.h:16
SkIRect fSubset
Definition: SkBitmapKey.h:15
constexpr SkIPoint topLeft() const
Definition: SkRect.h:151

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