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