Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
SkDngImage Class Reference

Public Member Functions

dng_image * render (int width, int height)
 
int width () const
 
int height () const
 
bool isScalable () const
 
bool isXtransImage () const
 

Static Public Member Functions

static SkDngImageNewFromStream (SkRawStream *stream)
 
static bool IsTiffHeaderValid (SkRawStream *stream)
 

Detailed Description

Definition at line 456 of file SkRawCodec.cpp.

Member Function Documentation

◆ height()

int SkDngImage::height ( ) const
inline

Definition at line 539 of file SkRawCodec.cpp.

539 {
540 return fHeight;
541 }

◆ isScalable()

bool SkDngImage::isScalable ( ) const
inline

Definition at line 543 of file SkRawCodec.cpp.

543 {
544 return fIsScalable;
545 }

◆ IsTiffHeaderValid()

static bool SkDngImage::IsTiffHeaderValid ( SkRawStream stream)
inlinestatic

Definition at line 553 of file SkRawCodec.cpp.

553 {
554 const size_t kHeaderSize = 4;
555 unsigned char header[kHeaderSize];
556 if (!stream->read(header, 0 /* offset */, kHeaderSize)) {
557 return false;
558 }
559
560 // Check if the header is valid (endian info and magic number "42").
561 bool littleEndian;
562 if (!is_valid_endian_marker(header, &littleEndian)) {
563 return false;
564 }
565
566 return 0x2A == get_endian_short(header + 2, littleEndian);
567 }
static uint16_t get_endian_short(const uint8_t *data, bool littleEndian)
static bool is_valid_endian_marker(const uint8_t *data, bool *isLittleEndian)
static constexpr size_t kHeaderSize
static const char header[]
Definition skpbench.cpp:88

◆ isXtransImage()

bool SkDngImage::isXtransImage ( ) const
inline

Definition at line 547 of file SkRawCodec.cpp.

547 {
548 return fIsXtransImage;
549 }

◆ NewFromStream()

static SkDngImage * SkDngImage::NewFromStream ( SkRawStream stream)
inlinestatic

Definition at line 464 of file SkRawCodec.cpp.

464 {
465 std::unique_ptr<SkDngImage> dngImage(new SkDngImage(stream));
466#if defined(SK_BUILD_FOR_LIBFUZZER)
467 // Libfuzzer easily runs out of memory after here. To avoid that
468 // We just pretend all streams are invalid. Our AFL-fuzzer
469 // should still exercise this code; it's more resistant to OOM.
470 return nullptr;
471#else
472 if (!dngImage->initFromPiex() && !dngImage->readDng()) {
473 return nullptr;
474 }
475
476 return dngImage.release();
477#endif
478 }

◆ render()

dng_image * SkDngImage::render ( int  width,
int  height 
)
inline

Definition at line 488 of file SkRawCodec.cpp.

488 {
489 if (!fHost || !fInfo || !fNegative || !fDngStream) {
490 if (!this->readDng()) {
491 return nullptr;
492 }
493 }
494
495 // DNG SDK preserves the aspect ratio, so it only needs to know the longer dimension.
496 const int preferredSize = std::max(width, height);
497 try {
498 // render() takes ownership of fHost, fInfo, fNegative and fDngStream when available.
499 std::unique_ptr<dng_host> host(fHost.release());
500 std::unique_ptr<dng_info> info(fInfo.release());
501 std::unique_ptr<dng_negative> negative(fNegative.release());
502 std::unique_ptr<dng_stream> dngStream(fDngStream.release());
503
504 host->SetPreferredSize(preferredSize);
505 host->ValidateSizes();
506
507 negative->ReadStage1Image(*host, *dngStream, *info);
508
509 if (info->fMaskIndex != -1) {
510 negative->ReadTransparencyMask(*host, *dngStream, *info);
511 }
512
513 negative->ValidateRawImageDigest(*host);
514 if (negative->IsDamaged()) {
515 return nullptr;
516 }
517
518 const int32 kMosaicPlane = -1;
519 negative->BuildStage2Image(*host);
520 negative->BuildStage3Image(*host, kMosaicPlane);
521
522 dng_render render(*host, *negative);
523 render.SetFinalSpace(dng_space_sRGB::Get());
524 render.SetFinalPixelType(ttByte);
525
526 dng_point stage3_size = negative->Stage3Image()->Size();
527 render.SetMaximumSize(std::max(stage3_size.h, stage3_size.v));
528
529 return render.Render();
530 } catch (...) {
531 return nullptr;
532 }
533 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
dng_image * render(int width, int height)
int height() const
int width() const
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service host
Definition switches.h:74

◆ width()

int SkDngImage::width ( ) const
inline

Definition at line 535 of file SkRawCodec.cpp.

535 {
536 return fWidth;
537 }

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