Flutter Engine
The Flutter Engine
Namespaces | Functions
SkWbmpCodec.cpp File Reference
#include "src/codec/SkWbmpCodec.h"
#include "include/codec/SkCodec.h"
#include "include/codec/SkEncodedImageFormat.h"
#include "include/codec/SkWbmpDecoder.h"
#include "include/core/SkColorType.h"
#include "include/core/SkData.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSize.h"
#include "include/core/SkStream.h"
#include "include/private/SkEncodedInfo.h"
#include "include/private/base/SkAlign.h"
#include "include/private/base/SkTo.h"
#include "modules/skcms/skcms.h"
#include "src/codec/SkCodecPriv.h"
#include <utility>

Go to the source code of this file.

Namespaces

namespace  SkWbmpDecoder
 

Functions

static size_t get_src_row_bytes (int width)
 
static bool valid_color_type (const SkImageInfo &dstInfo)
 
static bool read_byte (SkStream *stream, uint8_t *data)
 
static bool read_mbf (SkStream *stream, uint64_t *value)
 
static bool read_header (SkStream *stream, SkISize *size)
 
SK_API bool SkWbmpDecoder::IsWbmp (const void *, size_t)
 
SK_API std::unique_ptr< SkCodecSkWbmpDecoder::Decode (std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
 
SK_API std::unique_ptr< SkCodecSkWbmpDecoder::Decode (sk_sp< SkData >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
 

Function Documentation

◆ get_src_row_bytes()

static size_t get_src_row_bytes ( int  width)
inlinestatic

Definition at line 33 of file SkWbmpCodec.cpp.

33 {
34 return SkAlign8(width) >> 3;
35}
static constexpr T SkAlign8(T x)
Definition: SkAlign.h:17
int32_t width

◆ read_byte()

static bool read_byte ( SkStream stream,
uint8_t *  data 
)
static

Definition at line 51 of file SkWbmpCodec.cpp.

52{
53 return stream->read(data, 1) == 1;
54}
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ read_header()

static bool read_header ( SkStream stream,
SkISize size 
)
static

Definition at line 75 of file SkWbmpCodec.cpp.

75 {
76 {
77 uint8_t data;
78 if (!read_byte(stream, &data) || data != 0) { // unknown type
79 return false;
80 }
81 if (!read_byte(stream, &data) || (data & 0x9F)) { // skip fixed header
82 return false;
83 }
84 }
85
86 uint64_t width, height;
87 if (!read_mbf(stream, &width) || width > 0xFFFF || !width) {
88 return false;
89 }
90 if (!read_mbf(stream, &height) || height > 0xFFFF || !height) {
91 return false;
92 }
93 if (size) {
95 }
96 return true;
97}
constexpr int32_t SkToS32(S x)
Definition: SkTo.h:25
static bool read_mbf(SkStream *stream, uint64_t *value)
Definition: SkWbmpCodec.cpp:57
static bool read_byte(SkStream *stream, uint8_t *data)
Definition: SkWbmpCodec.cpp:51
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
int32_t height
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ read_mbf()

static bool read_mbf ( SkStream stream,
uint64_t *  value 
)
static

Definition at line 57 of file SkWbmpCodec.cpp.

57 {
58 uint64_t n = 0;
59 uint8_t data;
60 const uint64_t kLimit = 0xFE00000000000000;
61 SkASSERT(kLimit == ~((~static_cast<uint64_t>(0)) >> 7));
62 do {
63 if (n & kLimit) { // Will overflow on shift by 7.
64 return false;
65 }
66 if (stream->read(&data, 1) != 1) {
67 return false;
68 }
69 n = (n << 7) | (data & 0x7F);
70 } while (data & 0x80);
71 *value = n;
72 return true;
73}
#define SkASSERT(cond)
Definition: SkAssert.h:116
uint8_t value

◆ valid_color_type()

static bool valid_color_type ( const SkImageInfo dstInfo)
inlinestatic

Definition at line 37 of file SkWbmpCodec.cpp.

37 {
38 switch (dstInfo.colorType()) {
43 return true;
45 return dstInfo.colorSpace();
46 default:
47 return false;
48 }
49}
@ 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
SkColorSpace * colorSpace() const
SkColorType colorType() const
Definition: SkImageInfo.h:373