13 #include "impeller/entity/texture_fill.frag.h" 
   14 #include "impeller/entity/texture_fill.vert.h" 
   21     std::shared_ptr<Texture> texture,
 
   23     const Rect& destination,
 
   27     bool use_strict_src_rect)
 
   28     : texture_(
std::move(texture)),
 
   30       destination_(destination),
 
   32       blend_mode_(blend_mode),
 
   34       use_strict_src_rect_(use_strict_src_rect) {}
 
   48   using VS = TextureFillVertexShader;
 
   49   constexpr 
size_t indices[6] = {0, 1, 2, 1, 2, 3};
 
   52       sizeof(VS::PerVertexData) * 6, 
alignof(VS::PerVertexData),
 
   53       [&](uint8_t* raw_data) {
 
   54         VS::PerVertexData* 
data =
 
   55             reinterpret_cast<VS::PerVertexData*
>(raw_data);
 
   57         std::array<TPoint<float>, 4> destination_points =
 
   59         std::array<TPoint<float>, 4> texture_coords =
 
   61         for (
size_t j = 0; j < 6; j++) {
 
   62           data[offset].position = destination_points[indices[j]];
 
   63           data[offset].texture_coords = texture_coords[indices[j]];
 
   78   using VS = PorterDuffBlendVertexShader;
 
   79   constexpr 
size_t indices[6] = {0, 1, 2, 1, 2, 3};
 
   82       sizeof(VS::PerVertexData) * 6, 
alignof(VS::PerVertexData),
 
   83       [&](uint8_t* raw_data) {
 
   84         VS::PerVertexData* 
data =
 
   85             reinterpret_cast<VS::PerVertexData*
>(raw_data);
 
   87         std::array<TPoint<float>, 4> texture_coords =
 
   89         std::array<TPoint<float>, 4> destination_points =
 
   91         for (
size_t j = 0; j < 6; j++) {
 
   92           data[offset].vertices = destination_points[indices[j]];
 
   93           data[offset].texture_coords = texture_coords[indices[j]];
 
  129   if (use_strict_src_rect_) {
 
  149   geometry_ = geometry;
 
  159   if (geometry_->
ShouldSkip() || alpha_ <= 0.0) {
 
  166       renderer.
GetContext()->GetSamplerLibrary()->GetSampler(
 
  167           dst_sampler_descriptor);
 
  171     using VS = TextureFillVertexShader;
 
  172     using FS = TextureFillFragmentShader;
 
  175         renderer.
GetContext()->GetSamplerLibrary()->GetSampler(
 
  176             dst_sampler_descriptor);
 
  180     pipeline_options.depth_write_enabled =
 
  185 #ifdef IMPELLER_DEBUG 
  189     VS::FrameInfo frame_info;
 
  191     frame_info.texture_sampler_y_coord_scale =
 
  192         geometry_->
GetAtlas()->GetYCoordScale();
 
  194     VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
 
  196     FS::FragInfo frag_info;
 
  197     frag_info.alpha = alpha_;
 
  198     FS::BindFragInfo(pass, host_buffer.EmplaceUniform((frag_info)));
 
  199     FS::BindTextureSampler(pass, geometry_->
GetAtlas(), dst_sampler);
 
  200     return pass.
Draw().ok();
 
  209 #ifdef IMPELLER_DEBUG 
  220     FS::FragInfo frag_info;
 
  221     VS::FrameInfo frame_info;
 
  223     FS::BindTextureSamplerDst(pass, geometry_->
GetAtlas(), dst_sampler);
 
  224     frame_info.texture_sampler_y_coord_scale =
 
  225         geometry_->
GetAtlas()->GetYCoordScale();
 
  227     frag_info.input_alpha_output_alpha_tmx_tmy =
 
  231       Rect src_rect = rect.value();
 
  232       frag_info.source_rect =
 
  235       frag_info.use_strict_source_rect = 1.0;
 
  237       frag_info.use_strict_source_rect = 0.0;
 
  240     FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
 
  244     auto uniform_view = host_buffer.EmplaceUniform(frame_info);
 
  245     VS::BindFrameInfo(pass, uniform_view);
 
  247     return pass.
Draw().ok();
 
  253 #ifdef IMPELLER_DEBUG 
  260   FS::BindTextureSampler(pass, geometry_->
GetAtlas(), dst_sampler);
 
  262   VUS::FrameInfo frame_info;
 
  263   FS::FragInfo frag_info;
 
  265   frame_info.texture_sampler_y_coord_scale =
 
  266       geometry_->
GetAtlas()->GetYCoordScale();
 
  269   frag_info.alpha = alpha_;
 
  270   frag_info.blend_mode = 
static_cast<int>(blend_mode);
 
  276   FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
 
  277   VUS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
 
  279   return pass.
Draw().ok();
 
  289     const Entity& entity)
 const {
 
  297   geometry_ = geometry;
 
  311   if (geometry_->
ShouldSkip() || alpha_ <= 0.0) {
 
  319       renderer.
GetContext()->GetSamplerLibrary()->GetSampler(
 
  320           dst_sampler_descriptor);
 
  327 #ifdef IMPELLER_DEBUG 
  334   FS::FragInfo frag_info;
 
  335   VS::FrameInfo frame_info;
 
  337   FS::BindInputTexture(pass, geometry_->
GetAtlas(), dst_sampler);
 
  338   frame_info.texture_sampler_y_coord_scale =
 
  339       geometry_->
GetAtlas()->GetYCoordScale();
 
  341   frag_info.input_alpha = 1;
 
  342   frag_info.output_alpha = alpha_;
 
  343   const float* matrix = matrix_.
array;
 
  344   frag_info.color_v = 
Vector4(matrix[4], matrix[9], matrix[14], matrix[19]);
 
  345   frag_info.color_m = 
Matrix(matrix[0], matrix[5], matrix[10], matrix[15],  
 
  346                              matrix[1], matrix[6], matrix[11], matrix[16],  
 
  347                              matrix[2], matrix[7], matrix[12], matrix[17],  
 
  348                              matrix[3], matrix[8], matrix[13], matrix[18]   
 
  351   FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
 
  355   auto uniform_view = host_buffer.EmplaceUniform(frame_info);
 
  356   VS::BindFrameInfo(pass, uniform_view);
 
  358   return pass.
Draw().ok();
 
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
void SetGeometry(AtlasGeometry *geometry)
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.
void SetAlpha(Scalar alpha)
~AtlasContents() override
virtual std::optional< Rect > GetStrictSrcRect() const
The source rect of the draw if a strict source rect should be applied, or nullopt.
virtual VertexBuffer CreateSimpleVertexBuffer(HostBuffer &host_buffer) const =0
virtual Rect ComputeBoundingBox() const =0
virtual bool ShouldInvertBlendMode() const
virtual bool ShouldUseBlend() const =0
virtual const SamplerDescriptor & GetSamplerDescriptor() const =0
virtual bool ShouldSkip() const =0
virtual VertexBuffer CreateBlendVertexBuffer(HostBuffer &host_buffer) const =0
virtual BlendMode GetBlendMode() const =0
virtual const std::shared_ptr< Texture > & GetAtlas() const =0
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.
void SetGeometry(AtlasGeometry *geometry)
ColorFilterAtlasContents()
void SetAlpha(Scalar alpha)
~ColorFilterAtlasContents() override
void SetMatrix(ColorMatrix matrix)
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
PipelineRef GetPorterDuffPipeline(BlendMode mode, ContentContextOptions opts) const
PipelineRef GetTexturePipeline(ContentContextOptions opts) const
PipelineRef GetColorMatrixColorFilterPipeline(ContentContextOptions opts) const
std::shared_ptr< Context > GetContext() const
PipelineRef GetDrawVerticesUberPipeline(BlendMode blend_mode, ContentContextOptions opts) const
DrawImageRectAtlasGeometry(std::shared_ptr< Texture > texture, const Rect &source, const Rect &destination, const Color &color, BlendMode blend_mode, const SamplerDescriptor &desc, bool use_strict_src_rect=false)
Rect ComputeBoundingBox() const override
const SamplerDescriptor & GetSamplerDescriptor() const override
bool ShouldUseBlend() const override
std::optional< Rect > GetStrictSrcRect() const override
The source rect of the draw if a strict source rect should be applied, or nullopt.
BlendMode GetBlendMode() const override
bool ShouldInvertBlendMode() const override
VertexBuffer CreateBlendVertexBuffer(HostBuffer &host_buffer) const override
VertexBuffer CreateSimpleVertexBuffer(HostBuffer &host_buffer) const override
bool ShouldSkip() const override
~DrawImageRectAtlasGeometry()
const std::shared_ptr< Texture > & GetAtlas() const override
Matrix GetShaderTransform(const RenderPass &pass) const
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
BufferView Emplace(const BufferType &buffer, size_t alignment=0)
Emplace non-uniform data (like contiguous vertices) onto the host buffer.
Render passes encode render commands directed as one specific render target into an underlying comman...
virtual bool SetVertexBuffer(VertexBuffer buffer)
Specify the vertex and index buffer to use for this command.
virtual void SetPipeline(PipelineRef pipeline)
The pipeline to use for this command.
virtual fml::Status Draw()
Record the currently pending command.
virtual void SetCommandLabel(std::string_view label)
The debugging label to use for the command.
VertexShader_ VertexShader
FragmentShader_ FragmentShader
A wrapper around a raw ptr that adds additional unopt mode only checks.
std::optional< PipelineDescriptor > desc_
@ kNone
Does not use the index buffer.
LinePipeline::FragmentShader FS
std::optional< BlendMode > InvertPorterDuffBlend(BlendMode blend_mode)
LinePipeline::VertexShader VS
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
ContentContextOptions OptionsFromPass(const RenderPass &pass)
constexpr Color Premultiply() const
A 4x4 matrix using column-major storage.
constexpr auto GetBottom() const
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
constexpr TRect< T > Project(TRect< T > source) const
Returns a new rectangle that represents the projection of the source rectangle onto this rectangle....
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...
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
constexpr auto GetRight() const
constexpr static TRect MakeSize(const TSize< U > &size)
std::shared_ptr< const fml::Mapping > data