Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Namespaces | Functions
SkCodec.cpp File Reference
#include "include/codec/SkCodec.h"
#include "include/codec/SkCodecAnimation.h"
#include "include/codec/SkPixmapUtils.h"
#include "include/core/SkAlphaType.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkColorPriv.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkColorType.h"
#include "include/core/SkData.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkStream.h"
#include "include/private/base/SkTemplates.h"
#include "modules/skcms/skcms.h"
#include "src/base/SkNoDestructor.h"
#include "src/codec/SkCodecPriv.h"
#include "src/codec/SkFrameHolder.h"
#include "src/codec/SkPixmapUtilsPriv.h"
#include "src/codec/SkSampler.h"
#include <string>
#include <string_view>
#include <utility>
#include "include/private/base/SkOnce.h"

Go to the source code of this file.

Namespaces

namespace  SkCodecs
 

Functions

static std::vector< Decoder > * SkCodecs::get_decoders_for_editing ()
 
const std::vector< Decoder > & SkCodecs::get_decoders ()
 
bool SkCodecs::HasDecoder (std::string_view id)
 
static SkIRect frame_rect_on_screen (SkIRect frameRect, const SkIRect &screenRect)
 
bool zero_rect (const SkImageInfo &dstInfo, void *pixels, size_t rowBytes, SkISize srcDimensions, SkIRect prevRect)
 
bool sk_select_xform_format (SkColorType colorType, bool forColorTable, skcms_PixelFormat *outFormat)
 
static bool independent (const SkFrame &frame)
 
static bool restore_bg (const SkFrame &frame)
 

Function Documentation

◆ frame_rect_on_screen()

static SkIRect frame_rect_on_screen ( SkIRect  frameRect,
const SkIRect screenRect 
)
static

Definition at line 334 of file SkCodec.cpp.

335 {
336 if (!frameRect.intersect(screenRect)) {
337 return SkIRect::MakeEmpty();
338 }
339
340 return frameRect;
341}
bool intersect(const SkIRect &r)
Definition SkRect.h:513
static constexpr SkIRect MakeEmpty()
Definition SkRect.h:45

◆ independent()

static bool independent ( const SkFrame frame)
static

Definition at line 922 of file SkCodec.cpp.

922 {
923 return frame.getRequiredFrame() == SkCodec::kNoFrame;
924}
static constexpr int kNoFrame
Definition SkCodec.h:650
double frame
Definition examples.cpp:31

◆ restore_bg()

static bool restore_bg ( const SkFrame frame)
static

Definition at line 926 of file SkCodec.cpp.

◆ sk_select_xform_format()

bool sk_select_xform_format ( SkColorType  colorType,
bool  forColorTable,
skcms_PixelFormat outFormat 
)

Definition at line 767 of file SkCodec.cpp.

768 {
769 SkASSERT(outFormat);
770
771 switch (colorType) {
773 *outFormat = skcms_PixelFormat_RGBA_8888;
774 break;
776 *outFormat = skcms_PixelFormat_BGRA_8888;
777 break;
779 if (forColorTable) {
780#if defined(SK_PMCOLOR_IS_RGBA)
781 *outFormat = skcms_PixelFormat_RGBA_8888;
782#else
783 *outFormat = skcms_PixelFormat_BGRA_8888;
784#endif
785 break;
786 }
787 *outFormat = skcms_PixelFormat_BGR_565;
788 break;
790 *outFormat = skcms_PixelFormat_RGBA_hhhh;
791 break;
794 break;
796 *outFormat = skcms_PixelFormat_G_8;
797 break;
798 default:
799 return false;
800 }
801 return true;
802}
#define SkASSERT(cond)
Definition SkAssert.h:116
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition SkColorType.h:26
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition SkColorType.h:38
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition SkColorType.h:35
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition SkColorType.h:22
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
Definition SkColorType.h:31
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
@ skcms_PixelFormat_BGR_101010x_XR
@ skcms_PixelFormat_BGRA_8888
@ skcms_PixelFormat_RGBA_hhhh
@ skcms_PixelFormat_RGBA_8888
@ skcms_PixelFormat_G_8
@ skcms_PixelFormat_BGR_565

◆ zero_rect()

bool zero_rect ( const SkImageInfo dstInfo,
void *  pixels,
size_t  rowBytes,
SkISize  srcDimensions,
SkIRect  prevRect 
)

Definition at line 343 of file SkCodec.cpp.

344 {
345 const auto dimensions = dstInfo.dimensions();
346 if (dimensions != srcDimensions) {
347 SkRect src = SkRect::Make(srcDimensions);
348 SkRect dst = SkRect::Make(dimensions);
350 SkRect asRect = SkRect::Make(prevRect);
351 if (!map.mapRect(&asRect)) {
352 return false;
353 }
354 asRect.roundOut(&prevRect);
355 }
356
357 if (!prevRect.intersect(SkIRect::MakeSize(dimensions))) {
358 // Nothing to zero, due to scaling or bad frame rect.
359 return true;
360 }
361
362 const SkImageInfo info = dstInfo.makeDimensions(prevRect.size());
363 const size_t bpp = dstInfo.bytesPerPixel();
364 const size_t offset = prevRect.x() * bpp + prevRect.y() * rowBytes;
365 void* eraseDst = SkTAddOffset<void>(pixels, offset);
367 return true;
368}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
@ kNo_ZeroInitialized
Definition SkCodec.h:315
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
Definition SkMatrix.h:157
static void Fill(const SkImageInfo &info, void *dst, size_t rowBytes, SkCodec::ZeroInitialized zeroInit)
Definition SkSampler.cpp:20
dst
Definition cp.py:12
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition SkVx.h:680
Point offset
constexpr int32_t x() const
Definition SkRect.h:141
constexpr int32_t y() const
Definition SkRect.h:148
constexpr SkISize size() const
Definition SkRect.h:172
static constexpr SkIRect MakeSize(const SkISize &size)
Definition SkRect.h:66
SkImageInfo makeDimensions(SkISize newSize) const
int bytesPerPixel() const
SkISize dimensions() const
static SkRect Make(const SkISize &size)
Definition SkRect.h:669
void roundOut(SkIRect *dst) const
Definition SkRect.h:1241