Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
dl_image_impeller.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
9
10namespace impeller {
11
13 OwningContext owning_context) {
14 if (!texture) {
15 return nullptr;
16 }
18 new DlImageImpeller(std::move(texture), owning_context));
19}
20
22 AiksContext* aiks_context,
23 std::shared_ptr<Texture> y_texture,
24 std::shared_ptr<Texture> uv_texture,
25 YUVColorSpace yuv_color_space) {
26 if (!aiks_context || !y_texture || !uv_texture) {
27 return nullptr;
28 }
29 auto yuv_to_rgb_filter_contents = FilterContents::MakeYUVToRGBFilter(
30 std::move(y_texture), std::move(uv_texture), yuv_color_space);
31 impeller::Entity entity;
33 auto snapshot = yuv_to_rgb_filter_contents->RenderToSnapshot(
34 aiks_context->GetContentContext(), // renderer
35 entity, // entity
36 std::nullopt, // coverage_limit
37 std::nullopt, // sampler_descriptor
38 true, // msaa_enabled
39 /*mip_count=*/1,
40 "MakeYUVToRGBFilter Snapshot"); // label
41 if (!snapshot.has_value()) {
42 return nullptr;
43 }
44 return impeller::DlImageImpeller::Make(snapshot->texture);
45}
46
47DlImageImpeller::DlImageImpeller(std::shared_ptr<Texture> texture,
48 OwningContext owning_context)
49 : texture_(std::move(texture)), owning_context_(owning_context) {}
50
51// |DlImage|
53
54// |DlImage|
56 return nullptr;
57};
58
59// |DlImage|
60std::shared_ptr<impeller::Texture> DlImageImpeller::impeller_texture() const {
61 return texture_;
62}
63
64// |DlImage|
66 // Impeller doesn't currently implement opaque alpha types.
67 return false;
68}
69
70// |DlImage|
72 // Impeller textures are always ... textures :/
73 return true;
74}
75
76// |DlImage|
78 // Impeller textures are always thread-safe
79 return true;
80}
81
82// |DlImage|
84 const auto size = texture_ ? texture_->GetSize() : ISize{};
85 return SkISize::Make(size.width, size.height);
86}
87
88// |DlImage|
90 auto size = sizeof(*this);
91 if (texture_) {
92 size += texture_->GetTextureDescriptor().GetByteSizeOfBaseMipLevel();
93 }
94 return size;
95}
96
97} // namespace impeller
ContentContext & GetContentContext() const
size_t GetApproximateByteSize() const override
static sk_sp< DlImageImpeller > MakeFromYUVTextures(AiksContext *aiks_context, std::shared_ptr< Texture > y_texture, std::shared_ptr< Texture > uv_texture, YUVColorSpace yuv_color_space)
bool isTextureBacked() const override
std::shared_ptr< impeller::Texture > impeller_texture() const override
If this display list image is meant to be used by the Impeller backend, an Impeller texture instance....
SkISize dimensions() const override
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
sk_sp< SkImage > skia_image() const override
If this display list image is meant to be used by the Skia backend, an SkImage instance....
bool isUIThreadSafe() const override
If the underlying platform image held by this object has no threading requirements for the release of...
bool isOpaque() const override
If the pixel format of this image ignores alpha, this returns true. This method might conservatively ...
OwningContext owning_context() const override
void SetBlendMode(BlendMode blend_mode)
Definition entity.cc:115
static std::shared_ptr< FilterContents > MakeYUVToRGBFilter(std::shared_ptr< Texture > y_texture, std::shared_ptr< Texture > uv_texture, YUVColorSpace yuv_color_space)
FlTexture * texture
YUVColorSpace
Definition color.h:55
Definition ref_ptr.h:256
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20