Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
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
69 Mipmapped::kNo,
70 recorder->priv().isProtected(),
71 Renderable::kNo);
73 recorder->priv().resourceProvider(),
74 SkISize::Make((int32_t) width, (int32_t) height),
75 textureInfo,
77 if (!proxy) {
78 return nullptr;
79 }
80
81 fTexturePool[key] = proxy;
82 return proxy;
83}
84
86 fTexturePool.clear();
87}
88
90 if (!fTextAtlasManager->recordUploads(dc)) {
91 SKGPU_LOG_E("TextAtlasManager uploads have failed -- may see invalid results.");
92 }
93
94 if (fRasterPathAtlas) {
95 fRasterPathAtlas->recordUploads(dc);
96 }
97}
98
100 fTextAtlasManager->postFlush();
101 if (fRasterPathAtlas) {
102 fRasterPathAtlas->postFlush();
103 }
104}
105
106} // 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
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
const Caps * caps() const
ResourceProvider * resourceProvider()
static bool IsVelloRendererSupported(const Caps *)
static sk_sp< TextureProxy > Make(const Caps *, ResourceProvider *, SkISize dimensions, const TextureInfo &, 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