Flutter Impeller
checkerboard_contents.h
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 
5 #ifndef FLUTTER_IMPELLER_ENTITY_CONTENTS_CHECKERBOARD_CONTENTS_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_CHECKERBOARD_CONTENTS_H_
7 
9 
10 namespace impeller {
11 
12 /// A special Contents that renders a translucent checkerboard pattern with a
13 /// random color over the entire pass texture. This is useful for visualizing
14 /// offscreen textures.
15 class CheckerboardContents final : public Contents {
16  public:
18 
19  // |Contents|
20  ~CheckerboardContents() override;
21 
22  // |Contents|
23  bool Render(const ContentContext& renderer,
24  const Entity& entity,
25  RenderPass& pass) const override;
26 
27  // |Contents|
28  std::optional<Rect> GetCoverage(const Entity& entity) const override;
29 
30  void SetColor(Color color);
31 
32  void SetSquareSize(Scalar square_size);
33 
34  private:
35  Color color_ = Color::Red().WithAlpha(0.25);
36  Scalar square_size_ = 12;
37 
39 
40  CheckerboardContents& operator=(const CheckerboardContents&) = delete;
41 };
42 
43 } // namespace impeller
44 
45 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_CHECKERBOARD_CONTENTS_H_
contents.h
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::CheckerboardContents::~CheckerboardContents
~CheckerboardContents() override
impeller::Color::Red
static constexpr Color Red()
Definition: color.h:264
impeller::Color
Definition: color.h:124
impeller::Entity
Definition: entity.h:21
impeller::CheckerboardContents::SetSquareSize
void SetSquareSize(Scalar square_size)
Definition: checkerboard_contents.cc:60
impeller::Color::WithAlpha
constexpr Color WithAlpha(Scalar new_alpha) const
Definition: color.h:270
impeller::CheckerboardContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: checkerboard_contents.cc:18
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
impeller::CheckerboardContents::SetColor
void SetColor(Color color)
Definition: checkerboard_contents.cc:56
impeller::CheckerboardContents
Definition: checkerboard_contents.h:15
impeller::CheckerboardContents::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the area of the render pass that will be affected when this contents is rendered.
Definition: checkerboard_contents.cc:51
impeller::Contents
Definition: contents.h:34
impeller
Definition: aiks_blur_unittests.cc:20
impeller::ContentContext
Definition: content_context.h:392
impeller::CheckerboardContents::CheckerboardContents
CheckerboardContents()