Flutter Engine
 
Loading...
Searching...
No Matches
blend_filter_contents_unittests.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#include "gmock/gmock.h"
10
11namespace impeller {
12namespace testing {
13
15 public:
16 /// Create a texture that has been cleared to transparent black.
17 std::shared_ptr<Texture> MakeTexture(ISize size) {
18 std::shared_ptr<CommandBuffer> command_buffer =
19 GetContentContext()->GetContext()->CreateCommandBuffer();
20 if (!command_buffer) {
21 return nullptr;
22 }
23
24 auto render_target = GetContentContext()->MakeSubpass(
25 "Clear Subpass", size, command_buffer,
26 [](const ContentContext&, RenderPass&) { return true; });
27
29 ->GetContext()
30 ->GetCommandQueue()
31 ->Submit(/*buffers=*/{command_buffer})
32 .ok()) {
33 return nullptr;
34 }
35
36 if (render_target.ok()) {
37 return render_target.value().GetRenderTargetTexture();
38 }
39 return nullptr;
40 }
41};
43
44// https://github.com/flutter/flutter/issues/149216
45TEST_P(BlendFilterContentsTest, AdvancedBlendColorAlignsColorTo4) {
46 std::shared_ptr<Texture> texture = MakeTexture(ISize(100, 100));
47 BlendFilterContents filter_contents;
48 filter_contents.SetInputs({FilterInput::Make(texture)});
49 filter_contents.SetForegroundColor(Color(1.0, 0.0, 0.0, 1.0));
50 filter_contents.SetBlendMode(BlendMode::kColorDodge);
51
52 std::shared_ptr<ContentContext> renderer = GetContentContext();
53 // Add random byte to get the HostBuffer in a bad alignment.
54 uint8_t byte = 0xff;
55 BufferView buffer_view = renderer->GetTransientsDataBuffer().Emplace(
56 &byte, /*length=*/1, /*align=*/1);
57 EXPECT_EQ(buffer_view.GetRange().offset, 4u);
58 EXPECT_EQ(buffer_view.GetRange().length, 1u);
59 Entity entity;
60
61 std::optional<Entity> result = filter_contents.GetEntity(
62 *renderer, entity, /*coverage_hint=*/std::nullopt);
63
64 EXPECT_TRUE(result.has_value());
65}
66
67} // namespace testing
68} // namespace impeller
BufferView buffer_view
void SetBlendMode(BlendMode blend_mode)
void SetForegroundColor(std::optional< Color > color)
Sets a source color which is blended after all of the inputs have been blended.
std::shared_ptr< ContentContext > GetContentContext() const
std::optional< Entity > GetEntity(const ContentContext &renderer, const Entity &entity, const std::optional< Rect > &coverage_hint) const
Create an Entity that renders this filter's output.
void SetInputs(FilterInput::Vector inputs)
The input texture sources for this filter. Each input's emitted texture is expected to have premultip...
static FilterInput::Ref Make(Variant input, bool msaa_enabled=true)
std::shared_ptr< Context > GetContext() const
Definition playground.cc:91
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition render_pass.h:30
std::shared_ptr< Texture > MakeTexture(ISize size)
Create a texture that has been cleared to transparent black.
FlTexture * texture
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
TEST_P(AiksTest, DrawAtlasNoColor)
ISize64 ISize
Definition size.h:162
#define INSTANTIATE_PLAYGROUND_SUITE(playground)
Range GetRange() const
Definition buffer_view.h:27
size_t length
Definition range.h:15
size_t offset
Definition range.h:14