Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkImage_GaneshYUVA.h
Go to the documentation of this file.
1/*
2 * Copyright 2018 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
8#ifndef SkImage_GaneshYUVA_DEFINED
9#define SkImage_GaneshYUVA_DEFINED
10
18
19#include <cstddef>
20#include <cstdint>
21#include <memory>
22#include <tuple>
23
24class GrDirectContext;
26class GrImageContext;
29class SkMatrix;
30enum SkColorType : int;
31enum class GrColorType;
32enum class GrImageTexGenPolicy : int;
33enum class GrSemaphoresSubmitted : bool;
34enum GrSurfaceOrigin : int;
35enum class SkTileMode;
36struct GrFlushInfo;
37struct SkRect;
38
39namespace skgpu {
40enum class Mipmapped : bool;
41}
42
43// Wraps the 1 to 4 planes of a YUVA image for consumption by the GPU.
44// Initially any direct rendering will be done by passing the individual planes to a shader.
45// Once any method requests a flattened image (e.g., onReadPixels), the flattened RGB
46// proxy will be stored and used for any future rendering.
48public:
50 uint32_t uniqueID,
53
54 // From SkImage.h
55 size_t textureSize() const override;
56
57 // From SkImage_Base.h
59 bool onHasMipmaps() const override;
60 bool onIsProtected() const override;
61
65 GrDirectContext*) const final;
66
68
69 // From SkImage_GaneshBase.h
71
72 std::tuple<GrSurfaceProxyView, GrColorType> asView(GrRecordingContext*,
74 GrImageTexGenPolicy) const override;
75
76 std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
78 const SkTileMode[2],
79 const SkMatrix&,
80 const SkRect*,
81 const SkRect*) const override;
82
84
85 GrSurfaceOrigin origin() const override { return fYUVAProxies.textureOrigin(); }
86
87private:
88 enum class ColorSpaceMode {
89 kConvert,
90 kReinterpret,
91 };
94 sk_sp<SkColorSpace> targetCS,
95 ColorSpaceMode csMode);
96
97 mutable GrYUVATextureProxies fYUVAProxies;
98
99 // If this is non-null then the planar data should be converted from fFromColorSpace to
100 // this->colorSpace(). Otherwise we assume the planar data (post YUV->RGB conversion) is already
101 // in this->colorSpace().
102 const sk_sp<SkColorSpace> fFromColorSpace;
103
104 // Repeated calls to onMakeColorSpace will result in a proliferation of unique IDs and
105 // SkImage_GaneshYUVA instances. Cache the result of the last successful onMakeColorSpace call.
106 mutable sk_sp<SkColorSpace> fOnMakeColorSpaceTarget;
107 mutable sk_sp<SkImage> fOnMakeColorSpaceResult;
108
109 using INHERITED = SkImage_GaneshBase;
110};
111
112#endif
GrColorType
GrSurfaceOrigin
Definition GrTypes.h:147
GrSemaphoresSubmitted
Definition GrTypes.h:229
SkColorType
Definition SkColorType.h:19
GrImageTexGenPolicy
Definition SkGr.h:141
SkTileMode
Definition SkTileMode.h:13
Type::kYUV Type::kRGBA() int(0.7 *637)
GrSurfaceOrigin textureOrigin() const
virtual sk_sp< SkImage > onMakeColorTypeAndColorSpace(SkColorType, sk_sp< SkColorSpace >, GrDirectContext *) const=0
std::unique_ptr< GrFragmentProcessor > asFragmentProcessor(GrRecordingContext *, SkSamplingOptions, const SkTileMode[2], const SkMatrix &, const SkRect *, const SkRect *) const override
bool onIsProtected() const override
sk_sp< SkImage > onReinterpretColorSpace(sk_sp< SkColorSpace >) const final
GrSemaphoresSubmitted flush(GrDirectContext *, const GrFlushInfo &) const override
size_t textureSize() const override
std::tuple< GrSurfaceProxyView, GrColorType > asView(GrRecordingContext *, skgpu::Mipmapped, GrImageTexGenPolicy) const override
sk_sp< SkImage > onMakeColorTypeAndColorSpace(SkColorType, sk_sp< SkColorSpace >, GrDirectContext *) const final
bool setupMipmapsForPlanes(GrRecordingContext *) const
SkImage_Base::Type type() const override
bool onHasMipmaps() const override
GrSurfaceOrigin origin() const override
uint32_t uniqueID() const
Definition SkImage.h:311
sk_sp< SkImage > image
Definition examples.cpp:29
Mipmapped
Definition GpuTypes.h:53