Flutter Engine
The Flutter Engine
SkIcoCodec.h
Go to the documentation of this file.
1/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#ifndef SkIcoCodec_DEFINED
8#define SkIcoCodec_DEFINED
9
12#include "include/core/SkSize.h"
15
16#include <cstddef>
17#include <memory>
18
19class SkSampler;
20class SkStream;
21struct SkEncodedInfo;
22struct SkImageInfo;
23
24/*
25 * This class implements the decoding for bmp images
26 */
27class SkIcoCodec : public SkCodec {
28public:
29 static bool IsIco(const void*, size_t);
30
31 /*
32 * Assumes IsIco was called and returned true
33 * Creates an Ico decoder
34 * Reads enough of the stream to determine the image format
35 */
36 static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result*);
37
38protected:
39
40 /*
41 * Chooses the best dimensions given the desired scale
42 */
43 SkISize onGetScaledDimensions(float desiredScale) const override;
44
45 bool onDimensionsSupported(const SkISize&) override;
46
47 /*
48 * Initiates the Ico decode
49 */
50 Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes, const Options&,
51 int*) override;
52
55 }
56
57 SkScanlineOrder onGetScanlineOrder() const override;
58
59 bool conversionSupported(const SkImageInfo&, bool, bool) override {
60 // This will be checked by the embedded codec.
61 return true;
62 }
63
64 // Handled by the embedded codec.
65 bool usesColorXform() const override { return false; }
66private:
67
68 Result onStartScanlineDecode(const SkImageInfo& dstInfo,
69 const SkCodec::Options& options) override;
70
71 int onGetScanlines(void* dst, int count, size_t rowBytes) override;
72
73 bool onSkipScanlines(int count) override;
74
75 Result onStartIncrementalDecode(const SkImageInfo& dstInfo, void* pixels, size_t rowBytes,
76 const SkCodec::Options&) override;
77
78 Result onIncrementalDecode(int* rowsDecoded) override;
79
80 SkSampler* getSampler(bool createIfNecessary) override;
81
82 /*
83 * Searches fEmbeddedCodecs for a codec that matches requestedSize.
84 * The search starts at startIndex and ends when an appropriate codec
85 * is found, or we have reached the end of the array.
86 *
87 * @return the index of the matching codec or -1 if there is no
88 * matching codec between startIndex and the end of
89 * the array.
90 */
91 int chooseCodec(const SkISize& requestedSize, int startIndex);
92
93 /*
94 * Constructor called by NewFromStream
95 * @param embeddedCodecs codecs for the embedded images, takes ownership
96 */
98 std::unique_ptr<SkStream>,
99 std::unique_ptr<skia_private::TArray<std::unique_ptr<SkCodec>>> embeddedCodecs);
100
101 std::unique_ptr<skia_private::TArray<std::unique_ptr<SkCodec>>> fEmbeddedCodecs;
102
103 // fCurrCodec is owned by this class, but should not be an
104 // std::unique_ptr. It will be deleted by the destructor of fEmbeddedCodecs.
105 SkCodec* fCurrCodec;
106
107 using INHERITED = SkCodec;
108};
109#endif // SkIcoCodec_DEFINED
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
int count
Definition: FontMgrTest.cpp:50
SkEncodedImageFormat
const SkImageInfo & dstInfo() const
Definition: SkCodec.h:878
SkCodec(SkEncodedInfo &&, XformFormat srcFormat, std::unique_ptr< SkStream >, SkEncodedOrigin=kTopLeft_SkEncodedOrigin)
Definition: SkCodec.cpp:250
SkScanlineOrder
Definition: SkCodec.h:575
friend class SkIcoCodec
Definition: SkCodec.h:1040
Result
Definition: SkCodec.h:76
const Options & options() const
Definition: SkCodec.h:880
bool conversionSupported(const SkImageInfo &, bool, bool) override
Definition: SkIcoCodec.h:59
SkISize onGetScaledDimensions(float desiredScale) const override
Definition: SkIcoCodec.cpp:228
Result onGetPixels(const SkImageInfo &dstInfo, void *dst, size_t dstRowBytes, const Options &, int *) override
Definition: SkIcoCodec.cpp:273
SkEncodedImageFormat onGetEncodedFormat() const override
Definition: SkIcoCodec.h:53
static bool IsIco(const void *, size_t)
Definition: SkIcoCodec.cpp:37
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, Result *)
Definition: SkIcoCodec.cpp:45
bool usesColorXform() const override
Definition: SkIcoCodec.h:65
SkScanlineOrder onGetScanlineOrder() const override
Definition: SkIcoCodec.cpp:394
bool onDimensionsSupported(const SkISize &) override
Definition: SkIcoCodec.cpp:266
dst
Definition: cp.py:12
Definition: SkSize.h:16