Setup render command for solid fill.

This commit is contained in:
Chinmay Garde 2021-08-18 01:02:21 -07:00 committed by Dan Field
parent 1bc196e2f2
commit 37aa63cf06
9 changed files with 32 additions and 9 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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_;

View File

@ -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;
}

View File

@ -44,6 +44,8 @@ class Entity {
bool HasStroke() const;
bool HasContents() const;
bool HasRenderableContents() const;
private:

View File

@ -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:

View File

@ -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;

View File

@ -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:

View File

@ -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;
}