Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSampledCodec.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 SkSampledCodec_DEFINED
8#define SkSampledCodec_DEFINED
9
12#include "include/core/SkSize.h"
13
14#include <cstddef>
15
16struct SkIRect;
17struct SkImageInfo;
18
19/**
20 * This class implements the functionality of SkAndroidCodec. Scaling will
21 * be provided by sampling if it cannot be provided by fCodec.
22 */
24public:
25 explicit SkSampledCodec(SkCodec*);
26
27 ~SkSampledCodec() override {}
28
29protected:
30
31 SkISize onGetSampledDimensions(int sampleSize) const override;
32
33 bool onGetSupportedSubset(SkIRect* desiredSubset) const override { return true; }
34
35 SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
36 const AndroidOptions& options) override;
37
38private:
39 /**
40 * Find the best way to account for native scaling.
41 *
42 * Return a size that fCodec can scale to, and adjust sampleSize to finish scaling.
43 *
44 * @param sampleSize As an input, the requested sample size.
45 * As an output, sampling needed after letting fCodec
46 * scale to the returned dimensions.
47 * @param nativeSampleSize Optional output parameter. Will be set to the
48 * effective sample size done by fCodec.
49 * @return SkISize The size that fCodec should scale to.
50 */
51 SkISize accountForNativeScaling(int* sampleSize, int* nativeSampleSize = nullptr) const;
52
53 /**
54 * This fulfills the same contract as onGetAndroidPixels().
55 *
56 * We call this function from onGetAndroidPixels() if we have determined
57 * that fCodec does not support the requested scale, and we need to
58 * provide the scale by sampling.
59 */
60 SkCodec::Result sampledDecode(const SkImageInfo& info, void* pixels, size_t rowBytes,
61 const AndroidOptions& options);
62
63 using INHERITED = SkAndroidCodec;
64};
65#endif // SkSampledCodec_DEFINED
const char * options
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
SkISize onGetSampledDimensions(int sampleSize) const override
~SkSampledCodec() override
bool onGetSupportedSubset(SkIRect *desiredSubset) const override
SkCodec::Result onGetAndroidPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, const AndroidOptions &options) override