| Flutter Impeller |

cover_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
5 #include "impeller/entity/geometry/cover_geometry.h"
6
7 #include "impeller/renderer/render_pass.h"
8
9 namespace impeller {
10
11 CoverGeometry::CoverGeometry() = default;
12
13 CoverGeometry::~CoverGeometry() = default;
14
15 GeometryResult CoverGeometry::GetPositionBuffer(const ContentContext& renderer,
16 const Entity& entity,
17 RenderPass& pass) {
18 auto rect = Rect(Size(pass.GetRenderTargetSize()));
19 constexpr uint16_t kRectIndicies[4] = {0, 1, 2, 3};
20 auto& host_buffer = pass.GetTransientsBuffer();
21 return GeometryResult{
22 .type = PrimitiveType::kTriangleStrip,
23 .vertex_buffer =
24 {
25 .vertex_buffer = host_buffer.Emplace(
26 rect.GetTransformedPoints(entity.GetTransformation().Invert())
27 .data(),
28 8 * sizeof(float), alignof(float)),
29 .index_buffer = host_buffer.Emplace(
30 kRectIndicies, 4 * sizeof(uint16_t), alignof(uint16_t)),
31 .vertex_count = 4,
32 .index_type = IndexType::k16bit,
33 },
34 .transform = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
35 entity.GetTransformation(),
36 .prevent_overdraw = false,
37 };
38 }
39
40 // |Geometry|
41 GeometryResult CoverGeometry::GetPositionUVBuffer(
42 Rect texture_coverage,
43 Matrix effect_transform,
44 const ContentContext& renderer,
45 const Entity& entity,
46 RenderPass& pass) {
47 auto rect = Rect(Size(pass.GetRenderTargetSize()));
48 return ComputeUVGeometryForRect(rect, texture_coverage, effect_transform,
49 renderer, entity, pass);
50 }
51
52 GeometryVertexType CoverGeometry::GetVertexType() const {
53 return GeometryVertexType::kPosition;
54 }
55
56 std::optional<Rect> CoverGeometry::GetCoverage(const Matrix& transform) const {
57 return Rect::MakeMaximum();
58 }
59
60 bool CoverGeometry::CoversArea(const Matrix& transform,
61 const Rect& rect) const {
62 return true;
63 }
64
65 } // namespace impeller
impeller::IndexType::k16bit
@ k16bit
cover_geometry.h
impeller::CoverGeometry::~CoverGeometry
~CoverGeometry()
impeller::Size
TSize< Scalar > Size
Definition: size.h:135
impeller::GeometryVertexType
GeometryVertexType
Definition: geometry.h:25
impeller::PrimitiveType::kTriangleStrip
@ kTriangleStrip
impeller::CoverGeometry::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: cover_geometry.cc:60
render_pass.h
impeller::CoverGeometry::CoverGeometry
CoverGeometry()
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:306
impeller::TRect< Scalar >::MakeMaximum
constexpr static TRect MakeMaximum()
Definition: rect.h:75
impeller::Matrix::MakeOrthographic
static constexpr Matrix MakeOrthographic(TSize< T > size)
Definition: matrix.h:448
impeller::ComputeUVGeometryForRect
GeometryResult ComputeUVGeometryForRect(Rect source_rect, Rect texture_coverage, Matrix effect_transform, const ContentContext &renderer, const Entity &entity, RenderPass &pass)
Definition: geometry.cc:70
impeller
Definition: aiks_context.cc:10
impeller::kPosition
@ kPosition
Definition: geometry.h:26
impeller::TRect< Scalar >
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:36