7#include "flutter/testing/testing.h"
29 return ISize(1024, 1024);
37 return std::make_shared<MockDeviceBuffer>(
desc);
45 return std::make_shared<MockTexture>(
desc);
52 auto render_target_cache =
55 render_target_cache.Start();
58 render_target_cache.CreateOffscreen(*
GetContext(), {100, 100}, 1);
59 render_target_cache.CreateOffscreen(*
GetContext(), {100, 100}, 1);
61 EXPECT_EQ(render_target_cache.CachedTextureCount(), 2u);
63 render_target_cache.End();
64 render_target_cache.Start();
68 render_target_cache.CreateOffscreen(*
GetContext(), {100, 100}, 1);
69 EXPECT_EQ(render_target_cache.CachedTextureCount(), 2u);
71 render_target_cache.End();
72 EXPECT_EQ(render_target_cache.CachedTextureCount(), 1u);
77 auto allocator = std::make_shared<TestAllocator>();
80 render_target_cache.Start();
81 allocator->should_fail =
true;
84 render_target_cache.CreateOffscreen(*
GetContext(), {100, 100}, 1);
86 EXPECT_FALSE(render_target.IsValid());
87 EXPECT_EQ(render_target_cache.CachedTextureCount(), 0u);
91 auto render_target_cache =
94 render_target_cache.Start();
97 RenderTarget target1 = render_target_cache.CreateOffscreen(
98 *
GetContext(), {100, 100}, 1,
"Offscreen1", color_attachment_config);
99 render_target_cache.End();
101 render_target_cache.Start();
103 RenderTarget target2 = render_target_cache.CreateOffscreen(
104 *
GetContext(), {100, 100}, 1,
"Offscreen2", color_attachment_config);
105 render_target_cache.End();
111 EXPECT_EQ(color2.texture, color1.texture);
116 auto render_target_cache =
119 render_target_cache.Start();
121 render_target_cache.CreateOffscreen(*
GetContext(), {100, 0}, 1);
123 render_target_cache.CreateOffscreenMSAA(*
GetContext(), {0, 0}, 1);
124 render_target_cache.End();
128 EXPECT_FALSE(empty_target.
IsValid());
129 EXPECT_FALSE(empty_target_msaa.
IsValid());
An object that allocates device memory.
An implementation of the [RenderTargetAllocator] that caches all allocated texture data for one frame...
static constexpr AttachmentConfig kDefaultColorAttachmentConfig
const std::map< size_t, ColorAttachment > & GetColorAttachments() const
ISize GetMaxTextureSizeSupported() const override
virtual std::shared_ptr< Texture > OnCreateTexture(const TextureDescriptor &desc) override
std::shared_ptr< DeviceBuffer > OnCreateBuffer(const DeviceBufferDescriptor &desc) override
SK_API GrDirectContext * GetContext(const SkImage *src)
INSTANTIATE_PLAYGROUND_SUITE(AiksTest)
TEST_P(AiksTest, CanRenderAdvancedBlendColorFilterWithSaveLayer)
static constexpr Color Red()
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...