Flutter Engine
The Flutter Engine
AtlasProvider.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
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
9
19
20namespace skgpu::graphite {
21
23 // The raster-backend path atlas is always supported.
27 }
28 return flags;
29}
30
32 : fTextAtlasManager(std::make_unique<TextAtlasManager>(recorder))
33 , fRasterPathAtlas(std::make_unique<RasterPathAtlas>(recorder))
34 , fPathAtlasFlags(QueryPathAtlasSupport(recorder->priv().caps())) {}
35
36std::unique_ptr<ComputePathAtlas> AtlasProvider::createComputePathAtlas(Recorder* recorder) const {
38 return ComputePathAtlas::CreateDefault(recorder);
39 }
40 return nullptr;
41}
42
44 return fRasterPathAtlas.get();
45}
46
48 uint16_t width,
49 uint16_t height,
51 uint16_t identifier,
52 bool requireStorageUsage) {
53 uint64_t key = static_cast<uint64_t>(width) << 48 |
54 static_cast<uint64_t>(height) << 32 |
55 static_cast<uint64_t>(colorType) << 16 |
56 static_cast<uint64_t>(identifier);
57 auto iter = fTexturePool.find(key);
58 if (iter != fTexturePool.end()) {
59 return iter->second;
60 }
61
62 // We currently only make the distinction between a storage texture (written by a
63 // compute pass) and a plain sampleable texture (written via upload) that won't be
64 // used as a render attachment.
65 const Caps* caps = recorder->priv().caps();
66 auto textureInfo = requireStorageUsage
70 recorder->priv().isProtected(),
73 recorder->priv().resourceProvider(),
74 SkISize::Make((int32_t) width, (int32_t) height),
75 textureInfo,
76 "AtlasProviderTexture",
78 if (!proxy) {
79 return nullptr;
80 }
81
82 fTexturePool[key] = proxy;
83 return proxy;
84}
85
87 fTexturePool.clear();
88}
89
91 if (!fTextAtlasManager->recordUploads(dc)) {
92 SKGPU_LOG_E("TextAtlasManager uploads have failed -- may see invalid results.");
93 }
94
95 if (fRasterPathAtlas) {
96 fRasterPathAtlas->recordUploads(dc);
97 }
98}
99
101 fTextAtlasManager->postFlush();
102 if (fRasterPathAtlas) {
103 fRasterPathAtlas->postFlush();
104 }
105}
106
107} // namespace skgpu::graphite
#define SKGPU_LOG_E(fmt,...)
Definition: Log.h:38
SkColorType
Definition: SkColorType.h:19
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
bool isAvailable(PathAtlasFlags atlasType) const
Definition: AtlasProvider.h:57
static PathAtlasFlagsBitMask QueryPathAtlasSupport(const Caps *)
sk_sp< TextureProxy > getAtlasTexture(Recorder *, uint16_t width, uint16_t height, SkColorType, uint16_t identifier, bool requireStorageUsage)
void recordUploads(DrawContext *)
std::unique_ptr< ComputePathAtlas > createComputePathAtlas(Recorder *recorder) const
RasterPathAtlas * getRasterPathAtlas() const
virtual TextureInfo getDefaultStorageTextureInfo(SkColorType) const =0
virtual TextureInfo getDefaultSampledTextureInfo(SkColorType, Mipmapped mipmapped, Protected, Renderable) const =0
static std::unique_ptr< ComputePathAtlas > CreateDefault(Recorder *)
Protected isProtected() const
Definition: RecorderPriv.h:52
const Caps * caps() const
Definition: RecorderPriv.h:31
ResourceProvider * resourceProvider()
Definition: RecorderPriv.h:33
static bool IsVelloRendererSupported(const Caps *)
static sk_sp< TextureProxy > Make(const Caps *, ResourceProvider *, SkISize dimensions, const TextureInfo &, std::string_view label, skgpu::Budgeted)
static SkString identifier(const FontFamilyDesc &family, const FontDesc &font)
FlutterSemanticsFlag flags
FlPixelBufferTexturePrivate * priv
Definition: ref_ptr.h:256
int32_t height
int32_t width
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20