54 constexpr int kKTXIdentifierSize = 12;
55 constexpr int kKTXHeaderSize = kKTXIdentifierSize + 13 *
sizeof(uint32_t);
56 uint8_t
header[kKTXHeaderSize];
58 if (input.
read(
header, kKTXHeaderSize) != kKTXHeaderSize) {
62 static const uint8_t kExpectedIdentifier[kKTXIdentifierSize] = {
63 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
66 if (0 != memcmp(
header, kExpectedIdentifier, kKTXIdentifierSize)) {
71 if (endianness != 0x04030201) {
90 if (glType != 0 || glFormat != 0) {
96 switch (glInternalFormat) {
114 if (pixelDepth != 0) {
118 if (numberOfFaces != 1) {
122 if (numberOfMipmapLevels == 1) {
126 if (numberOfMipmapLevels != numRequiredMipLevels) {
132 if (bytesOfKeyValueData != 0) {
139 {(int)pixelWidth, (int)pixelHeight},
140 &individualMipOffsets,
142 SkASSERT(individualMipOffsets.
size() == numberOfMipmapLevels);
146 uint8_t*
dest = (uint8_t*)
data->writable_data();
149 for (
int i = 0;
i < numberOfMipmapLevels; ++
i) {
152 if (input.
read(&imageSize, 4) != 4) {
223 constexpr uint32_t
kMagic = 0x20534444;
234 constexpr size_t kDDSHeaderSize =
sizeof(
DDS_HEADER);
235 static_assert(kDDSHeaderSize == 124);
237 static_assert(kDDSPixelFormatSize == 32);
241 if (input.
read(&
header, kDDSHeaderSize) != kDDSHeaderSize) {
245 if (
header.dwSize != kDDSHeaderSize ||
246 header.ddspf.dwSize != kDDSPixelFormatSize) {
261 int numberOfMipmapLevels = 1;
263 if (
header.dwMipMapCount == 1) {
267 if (
header.dwMipMapCount != (
unsigned) numRequiredLevels) {
271 numberOfMipmapLevels = numRequiredLevels;
282 switch (
header.ddspf.dwFourCC) {
293 {(int)header.dwWidth, (int)header.dwHeight},
294 &individualMipOffsets,
296 SkASSERT(individualMipOffsets.
size() == numberOfMipmapLevels);
300 uint8_t*
dest = (uint8_t*)
data->writable_data();
302 size_t amountRead = input.
read(
dest, dataSize);
303 if (amountRead != dataSize) {
318 info.fCompressionType,
322 std::move(
data),
info.fDim.fWidth,
info.fDim.fHeight,
info.fCompressionType);
340 return SkISize::Make(2*kImgWidthHeight + 3 * kPad, kImgWidthHeight + 2 * kPad);
344 SkASSERT(!fETC1Image && !fBC1Image);
350 SkASSERT(
info.fDim.equals(kImgWidthHeight, kImgWidthHeight));
356 SkDebugf(
"failed to load flower-etc1.ktx\n");
365 SkASSERT(
info.fDim.equals(kImgWidthHeight, kImgWidthHeight));
371 SkDebugf(
"failed to load flower-bc1.dds\n");
384 bool isCompressed =
false;
400 paint.setStrokeWidth(2.0f);
407 if (dContext && dContext->abandoned()) {
414 *errorMsg =
"Failed to create images.";
422 fETC1Image =
nullptr;
430 this->
drawImage(canvas, fBC1Image.
get(), kImgWidthHeight + 2 * kPad, kPad);
434 static const int kImgWidthHeight = 128;
435 static const int kPad = 4;
440 using INHERITED =
GM;
445DEF_GM(
return new ExoticFormatsGM;)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
#define GR_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
#define GR_GL_COMPRESSED_ETC1_RGB8
#define GR_GL_COMPRESSED_RGB8_ETC2
#define GR_GL_COMPRESSED_RGB_S3TC_DXT1_EXT
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
SkString GetResourcePath(const char *resource)
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorBLACK
size_t SkCompressedDataSize(SkTextureCompressionType type, SkISize dimensions, TArray< size_t > *individualMipOffsets, bool mipmapped)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static SkImage_Base * as_IB(SkImage *image)
static const char kMagic[]
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
const GrCaps * caps() const
bool isFormatCompressed(const GrBackendFormat &format) const
GrImageContextPriv priv()
const GrBackendFormat & backendFormat() const
void drawRect(const SkRect &rect, const SkPaint &paint)
virtual GrRecordingContext * recordingContext() const
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
static sk_sp< SkData > MakeUninitialized(size_t length)
size_t read(void *buffer, size_t size) override
virtual GrImageContext * context() const
virtual bool isTextureBacked() const =0
static int ComputeLevelCount(int baseWidth, int baseHeight)
@ kStroke_Style
set to stroke geometry
GM(SkColor backgroundColor=SK_ColorWHITE)
SK_API sk_sp< SkImage > TextureFromCompressedTextureData(GrDirectContext *direct, sk_sp< SkData > data, int width, int height, SkTextureCompressionType type, skgpu::Mipmapped mipmapped=skgpu::Mipmapped::kNo, GrProtected isProtected=GrProtected::kNo)
SK_API sk_sp< SkImage > RasterFromCompressedTextureData(sk_sp< SkData > data, int width, int height, SkTextureCompressionType type)
sk_sp< const SkImage > image
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 The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
GrTextureProxy * GetTextureImageProxy(SkImage *image, GrRecordingContext *rContext)
DEF_GM(return F(C(clipbox), 0.0f, 0.0f, {})) DEF_GM(return F(C(clipbox)
static const char header[]
SkTextureCompressionType fCompressionType
skgpu::Mipmapped fMipmapped
static constexpr SkISize Make(int32_t w, int32_t h)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
std::shared_ptr< const fml::Mapping > data