Flutter Impeller
rect_geometry.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 
7 namespace impeller {
8 
9 RectGeometry::RectGeometry(Rect rect) : rect_(rect) {}
10 
12  const Entity& entity,
13  RenderPass& pass) const {
14  auto& host_buffer = renderer.GetTransientsBuffer();
15  return GeometryResult{
17  .vertex_buffer =
18  {
19  .vertex_buffer = host_buffer.Emplace(
20  rect_.GetPoints().data(), 8 * sizeof(float), alignof(float)),
21  .vertex_count = 4,
22  .index_type = IndexType::kNone,
23  },
24  .transform = entity.GetShaderTransform(pass),
25  };
26 }
27 
28 std::optional<Rect> RectGeometry::GetCoverage(const Matrix& transform) const {
29  return rect_.TransformBounds(transform);
30 }
31 
32 bool RectGeometry::CoversArea(const Matrix& transform, const Rect& rect) const {
33  if (!transform.IsTranslationScaleOnly()) {
34  return false;
35  }
36  Rect coverage = rect_.TransformBounds(transform);
37  return coverage.Contains(rect);
38 }
39 
41  return true;
42 }
43 
44 } // namespace impeller
impeller::Entity::GetShaderTransform
Matrix GetShaderTransform(const RenderPass &pass) const
Get the vertex shader transform used for drawing this Entity.
Definition: entity.cc:50
impeller::TRect::TransformBounds
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition: rect.h:463
rect_geometry.h
impeller::RectGeometry::IsAxisAlignedRect
bool IsAxisAlignedRect() const override
Definition: rect_geometry.cc:40
impeller::TRect::GetPoints
constexpr std::array< TPoint< T >, 4 > GetPoints() const
Get the points that represent the 4 corners of this rectangle in a Z order that is compatible with tr...
Definition: rect.h:405
impeller::Entity
Definition: entity.h:20
impeller::PrimitiveType::kTriangleStrip
@ kTriangleStrip
impeller::GeometryResult::type
PrimitiveType type
Definition: geometry.h:35
impeller::RectGeometry::RectGeometry
RectGeometry(Rect rect)
Definition: rect_geometry.cc:9
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:231
impeller::RectGeometry::GetPositionBuffer
GeometryResult GetPositionBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: rect_geometry.cc:11
impeller::GeometryResult
Definition: geometry.h:19
impeller::IndexType::kNone
@ kNone
Does not use the index buffer.
impeller::TRect::Contains
constexpr bool Contains(const TPoint< Type > &p) const
Returns true iff the provided point |p| is inside the half-open interior of this rectangle.
Definition: rect.h:221
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
impeller::RectGeometry::GetCoverage
std::optional< Rect > GetCoverage(const Matrix &transform) const override
Definition: rect_geometry.cc:28
impeller::RectGeometry::CoversArea
bool CoversArea(const Matrix &transform, const Rect &rect) const override
Determines if this geometry, transformed by the given transform, will completely cover all surface ar...
Definition: rect_geometry.cc:32
impeller
Definition: aiks_blend_unittests.cc:18
impeller::ContentContext
Definition: content_context.h:366
impeller::TRect< Scalar >
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::ContentContext::GetTransientsBuffer
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
Definition: content_context.h:752