Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SkPngEncoderImpl Class Reference

#include <SkPngEncoderImpl.h>

Inheritance diagram for SkPngEncoderImpl:
SkEncoder SkNoncopyable

Public Member Functions

 SkPngEncoderImpl (std::unique_ptr< SkPngEncoderMgr >, const SkPixmap &src)
 
 ~SkPngEncoderImpl () override
 
- Public Member Functions inherited from SkEncoder
bool encodeRows (int numRows)
 
virtual ~SkEncoder ()
 

Protected Member Functions

bool onEncodeRows (int numRows) override
 
- Protected Member Functions inherited from SkEncoder
virtual bool onEncodeRows (int numRows)=0
 
 SkEncoder (const SkPixmap &src, size_t storageBytes)
 

Protected Attributes

std::unique_ptr< SkPngEncoderMgrfEncoderMgr
 
- Protected Attributes inherited from SkEncoder
const SkPixmapfSrc
 
int fCurrRow
 
skia_private::AutoTMalloc< uint8_t > fStorage
 

Detailed Description

Definition at line 18 of file SkPngEncoderImpl.h.

Constructor & Destructor Documentation

◆ SkPngEncoderImpl()

SkPngEncoderImpl::SkPngEncoderImpl ( std::unique_ptr< SkPngEncoderMgr encoderMgr,
const SkPixmap src 
)

Definition at line 447 of file SkPngEncoderImpl.cpp.

448 : SkEncoder(src, encoderMgr->pngBytesPerPixel() * src.width())
449 , fEncoderMgr(std::move(encoderMgr)) {}
SkEncoder(const SkPixmap &src, size_t storageBytes)
Definition: SkEncoder.h:52
std::unique_ptr< SkPngEncoderMgr > fEncoderMgr

◆ ~SkPngEncoderImpl()

SkPngEncoderImpl::~SkPngEncoderImpl ( )
override

Definition at line 451 of file SkPngEncoderImpl.cpp.

451{}

Member Function Documentation

◆ onEncodeRows()

bool SkPngEncoderImpl::onEncodeRows ( int  numRows)
overrideprotectedvirtual

Implements SkEncoder.

Definition at line 453 of file SkPngEncoderImpl.cpp.

453 {
454 if (setjmp(png_jmpbuf(fEncoderMgr->pngPtr()))) {
455 return false;
456 }
457
458 const void* srcRow = fSrc.addr(0, fCurrRow);
459 for (int y = 0; y < numRows; y++) {
461 (const uint8_t*)srcRow + (fSrc.width() << fSrc.shiftPerPixel()));
462 fEncoderMgr->proc()((char*)fStorage.get(),
463 (const char*)srcRow,
464 fSrc.width(),
466
467 png_bytep rowPtr = (png_bytep)fStorage.get();
468 png_write_rows(fEncoderMgr->pngPtr(), &rowPtr, 1);
469 srcRow = SkTAddOffset<const void>(srcRow, fSrc.rowBytes());
470 }
471
472 fCurrRow += numRows;
473 if (fCurrRow == fSrc.height()) {
474 png_write_end(fEncoderMgr->pngPtr(), fEncoderMgr->infoPtr());
475 }
476
477 return true;
478}
SK_API int SkColorTypeBytesPerPixel(SkColorType ct)
Definition: SkImageInfo.cpp:16
static void sk_msan_assert_initialized(const void *begin, const void *end)
Definition: SkMSAN.h:24
skia_private::AutoTMalloc< uint8_t > fStorage
Definition: SkEncoder.h:60
int fCurrRow
Definition: SkEncoder.h:59
const SkPixmap & fSrc
Definition: SkEncoder.h:58
size_t rowBytes() const
Definition: SkPixmap.h:145
int width() const
Definition: SkPixmap.h:160
SkColorType colorType() const
Definition: SkPixmap.h:173
const void * addr() const
Definition: SkPixmap.h:153
int shiftPerPixel() const
Definition: SkPixmap.h:221
int height() const
Definition: SkPixmap.h:166
double y

Member Data Documentation

◆ fEncoderMgr

std::unique_ptr<SkPngEncoderMgr> SkPngEncoderImpl::fEncoderMgr
protected

Definition at line 27 of file SkPngEncoderImpl.h.


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