mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Setup render command for solid fill.
This commit is contained in:
parent
1bc196e2f2
commit
37aa63cf06
@ -23,7 +23,7 @@ class PictureRenderer {
|
||||
bool IsValid() const;
|
||||
|
||||
[[nodiscard]] bool Render(const Surface& surface,
|
||||
const RenderPass& onscreen_pass,
|
||||
RenderPass& onscreen_pass,
|
||||
const Picture& picture);
|
||||
|
||||
private:
|
||||
|
||||
@ -23,7 +23,7 @@ bool PictureRenderer::IsValid() const {
|
||||
}
|
||||
|
||||
bool PictureRenderer::Render(const Surface& surface,
|
||||
const RenderPass& onscreen_pass,
|
||||
RenderPass& onscreen_pass,
|
||||
const Picture& picture) {
|
||||
if (!IsValid()) {
|
||||
return false;
|
||||
|
||||
@ -63,7 +63,7 @@ class PipelineT {
|
||||
context,
|
||||
Builder::MakeDefaultPipelineDescriptor(context))) {}
|
||||
|
||||
const Pipeline* WaitAndGet() { return pipeline_future_.get().get(); }
|
||||
std::shared_ptr<Pipeline> WaitAndGet() { return pipeline_future_.get(); }
|
||||
|
||||
private:
|
||||
PipelineFuture pipeline_future_;
|
||||
|
||||
@ -62,6 +62,10 @@ bool Entity::HasStroke() const {
|
||||
return stroke_size_ > 0.0 && !stroke_color_.IsTransparent();
|
||||
}
|
||||
|
||||
bool Entity::HasContents() const {
|
||||
return !background_color_.IsTransparent();
|
||||
}
|
||||
|
||||
bool Entity::HasRenderableContents() const {
|
||||
const bool has_empty_path = path_.GetBoundingBox().IsZero();
|
||||
|
||||
@ -77,7 +81,7 @@ bool Entity::HasRenderableContents() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!background_color_.IsTransparent()) {
|
||||
if (HasContents()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -44,6 +44,8 @@ class Entity {
|
||||
|
||||
bool HasStroke() const;
|
||||
|
||||
bool HasContents() const;
|
||||
|
||||
bool HasRenderableContents() const;
|
||||
|
||||
private:
|
||||
|
||||
@ -25,7 +25,7 @@ class EntityRenderer {
|
||||
bool IsValid() const;
|
||||
|
||||
[[nodiscard]] bool RenderEntities(const Surface& surface,
|
||||
const RenderPass& onscreen_pass,
|
||||
RenderPass& onscreen_pass,
|
||||
const std::vector<Entity>& entities) const;
|
||||
|
||||
private:
|
||||
|
||||
@ -24,7 +24,7 @@ bool EntityRenderer::IsValid() const {
|
||||
}
|
||||
|
||||
bool EntityRenderer::RenderEntities(const Surface& surface,
|
||||
const RenderPass& onscreen_pass,
|
||||
RenderPass& onscreen_pass,
|
||||
const std::vector<Entity>& entities) const {
|
||||
if (!IsValid()) {
|
||||
return false;
|
||||
|
||||
@ -30,7 +30,7 @@ class EntityRendererImpl {
|
||||
bool IsValid() const;
|
||||
|
||||
[[nodiscard]] bool RenderEntity(const Surface& surface,
|
||||
const RenderPass& onscreen_pass,
|
||||
RenderPass& onscreen_pass,
|
||||
const Entity& entities);
|
||||
|
||||
private:
|
||||
|
||||
@ -12,7 +12,7 @@ EntityRendererImpl::EntityRendererImpl(std::shared_ptr<Context> context)
|
||||
return;
|
||||
}
|
||||
|
||||
solid_fill_pipeline_ = std::make_unique<SolidFillPipeline>(*context);
|
||||
solid_fill_pipeline_ = std::make_unique<SolidFillPipeline>(*context_);
|
||||
|
||||
is_valid_ = true;
|
||||
}
|
||||
@ -24,12 +24,29 @@ bool EntityRendererImpl::IsValid() const {
|
||||
}
|
||||
|
||||
bool EntityRendererImpl::RenderEntity(const Surface& surface,
|
||||
const RenderPass& onscreen_pass,
|
||||
RenderPass& pass,
|
||||
const Entity& entity) {
|
||||
if (!entity.HasRenderableContents()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (entity.HasContents()) {
|
||||
using CurrentPipeline = decltype(solid_fill_pipeline_)::element_type;
|
||||
using VS = CurrentPipeline::VertexShader;
|
||||
|
||||
Command cmd;
|
||||
cmd.pipeline = solid_fill_pipeline_->WaitAndGet();
|
||||
if (cmd.pipeline == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
VS::FrameInfo frame_info;
|
||||
frame_info.mvp = Matrix::MakeOrthographic(surface.GetSize()) *
|
||||
entity.GetTransformation();
|
||||
VS::BindFrameInfo(cmd,
|
||||
pass.GetTransientsBuffer().EmplaceUniform(frame_info));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user