Skip to content

Commit

Permalink
Rework the confusingly named renderer subsystem instances.
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaygarde authored and dnfield committed Apr 27, 2022
1 parent a404064 commit 57a0728
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 63 deletions.
5 changes: 4 additions & 1 deletion impeller/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
# found in the LICENSE file.

config("impeller_public_config") {
include_dirs = [ ".." ]
include_dirs = [
"..",
".",
]
}

is_host = is_mac || is_linux || is_win
Expand Down
4 changes: 2 additions & 2 deletions impeller/aiks/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import("../tools/impeller.gni")

impeller_component("aiks") {
sources = [
"aiks_renderer.cc",
"aiks_renderer.h",
"aiks_context.cc",
"aiks_context.h",
"canvas.cc",
"canvas.h",
"image.cc",
Expand Down
16 changes: 8 additions & 8 deletions impeller/aiks/aiks_renderer.cc → impeller/aiks/aiks_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "impeller/aiks/aiks_renderer.h"
#include "impeller/aiks/aiks_context.h"

#include "impeller/aiks/picture.h"

namespace impeller {

AiksRenderer::AiksRenderer(std::shared_ptr<Context> context)
AiksContext::AiksContext(std::shared_ptr<Context> context)
: context_(std::move(context)) {
if (!context_ || !context_->IsValid()) {
return;
}

content_renderer_ = std::make_unique<ContentRenderer>(context_);
if (!content_renderer_->IsValid()) {
content_context_ = std::make_unique<ContentContext>(context_);
if (!content_context_->IsValid()) {
return;
}

is_valid_ = true;
}

AiksRenderer::~AiksRenderer() = default;
AiksContext::~AiksContext() = default;

bool AiksRenderer::IsValid() const {
bool AiksContext::IsValid() const {
return is_valid_;
}

bool AiksRenderer::Render(const Picture& picture, RenderPass& parent_pass) {
bool AiksContext::Render(const Picture& picture, RenderPass& parent_pass) {
if (!IsValid()) {
return false;
}

if (picture.pass) {
return picture.pass->Render(*content_renderer_, parent_pass);
return picture.pass->Render(*content_context_, parent_pass);
}

return true;
Expand Down
12 changes: 6 additions & 6 deletions impeller/aiks/aiks_renderer.h → impeller/aiks/aiks_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@
#include <memory>

#include "flutter/fml/macros.h"
#include "impeller/entity/content_renderer.h"
#include "impeller/entity/content_context.h"
#include "impeller/renderer/context.h"

namespace impeller {

struct Picture;
class RenderPass;

class AiksRenderer {
class AiksContext {
public:
AiksRenderer(std::shared_ptr<Context> context);
AiksContext(std::shared_ptr<Context> context);

~AiksRenderer();
~AiksContext();

bool IsValid() const;

bool Render(const Picture& picture, RenderPass& parent_pass);

private:
std::shared_ptr<Context> context_;
std::unique_ptr<ContentRenderer> content_renderer_;
std::unique_ptr<ContentContext> content_context_;
bool is_valid_ = false;

FML_DISALLOW_COPY_AND_ASSIGN(AiksRenderer);
FML_DISALLOW_COPY_AND_ASSIGN(AiksContext);
};

} // namespace impeller
4 changes: 2 additions & 2 deletions impeller/aiks/aiks_playground.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "impeller/aiks/aiks_playground.h"

#include "impeller/aiks/aiks_renderer.h"
#include "impeller/aiks/aiks_context.h"

namespace impeller {

Expand All @@ -13,7 +13,7 @@ AiksPlayground::AiksPlayground() = default;
AiksPlayground::~AiksPlayground() = default;

bool AiksPlayground::OpenPlaygroundHere(const Picture& picture) {
AiksRenderer renderer(GetContext());
AiksContext renderer(GetContext());

if (!renderer.IsValid()) {
return false;
Expand Down
1 change: 1 addition & 0 deletions impeller/display_list/display_list_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include "flutter/display_list/display_list.h"
#include "flutter/display_list/display_list_dispatcher.h"
#include "flutter/fml/macros.h"
#include "impeller/aiks/canvas.h"
#include "impeller/aiks/paint.h"
Expand Down
4 changes: 2 additions & 2 deletions impeller/entity/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ impeller_shaders("entity_shaders") {

impeller_component("entity") {
sources = [
"content_renderer.cc",
"content_renderer.h",
"content_context.cc",
"content_context.h",
"contents.cc",
"contents.h",
"entity.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "impeller/entity/content_renderer.h"
#include "impeller/entity/content_context.h"

namespace impeller {

ContentRenderer::ContentRenderer(std::shared_ptr<Context> context)
ContentContext::ContentContext(std::shared_ptr<Context> context)
: context_(std::move(context)) {
if (!context_ || !context_->IsValid()) {
return;
Expand Down Expand Up @@ -46,13 +46,13 @@ ContentRenderer::ContentRenderer(std::shared_ptr<Context> context)
is_valid_ = true;
}

ContentRenderer::~ContentRenderer() = default;
ContentContext::~ContentContext() = default;

bool ContentRenderer::IsValid() const {
bool ContentContext::IsValid() const {
return is_valid_;
}

std::shared_ptr<Context> ContentRenderer::GetContext() const {
std::shared_ptr<Context> ContentContext::GetContext() const {
return context_;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using SolidStrokePipeline =
// to redirect writing to the stencil instead of color attachments.
using ClipPipeline = PipelineT<SolidFillVertexShader, SolidFillFragmentShader>;

class ContentRenderer {
class ContentContext {
public:
struct Options {
SampleCount sample_count = SampleCount::kCount1;
Expand All @@ -51,9 +51,9 @@ class ContentRenderer {
};
};

ContentRenderer(std::shared_ptr<Context> context);
ContentContext(std::shared_ptr<Context> context);

~ContentRenderer();
~ContentContext();

bool IsValid() const;

Expand Down Expand Up @@ -128,7 +128,7 @@ class ContentRenderer {

bool is_valid_ = false;

FML_DISALLOW_COPY_AND_ASSIGN(ContentRenderer);
FML_DISALLOW_COPY_AND_ASSIGN(ContentContext);
};

} // namespace impeller
16 changes: 8 additions & 8 deletions impeller/entity/contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <memory>

#include "flutter/fml/logging.h"
#include "impeller/entity/content_renderer.h"
#include "impeller/entity/content_context.h"
#include "impeller/entity/entity.h"
#include "impeller/geometry/path_builder.h"
#include "impeller/geometry/vector.h"
Expand All @@ -19,8 +19,8 @@

namespace impeller {

static ContentRenderer::Options OptionsFromPass(const RenderPass& pass) {
ContentRenderer::Options opts;
static ContentContext::Options OptionsFromPass(const RenderPass& pass) {
ContentContext::Options opts;
opts.sample_count = pass.GetRenderTarget().GetSampleCount();
return opts;
}
Expand Down Expand Up @@ -60,7 +60,7 @@ const std::vector<Color>& LinearGradientContents::GetColors() const {
return colors_;
}

bool LinearGradientContents::Render(const ContentRenderer& renderer,
bool LinearGradientContents::Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const {
using VS = GradientFillPipeline::VertexShader;
Expand Down Expand Up @@ -137,7 +137,7 @@ static VertexBuffer CreateSolidFillVertices(const Path& path,
return vtx_builder.CreateVertexBuffer(buffer);
}

bool SolidColorContents::Render(const ContentRenderer& renderer,
bool SolidColorContents::Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const {
if (color_.IsTransparent()) {
Expand Down Expand Up @@ -194,7 +194,7 @@ void TextureContents::SetOpacity(Scalar opacity) {
opacity_ = opacity;
}

bool TextureContents::Render(const ContentRenderer& renderer,
bool TextureContents::Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const {
if (texture_ == nullptr) {
Expand Down Expand Up @@ -328,7 +328,7 @@ static VertexBuffer CreateSolidStrokeVertices(const Path& path,
return vtx_builder.CreateVertexBuffer(buffer);
}

bool SolidStrokeContents::Render(const ContentRenderer& renderer,
bool SolidStrokeContents::Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const {
if (color_.IsTransparent() || stroke_size_ <= 0.0) {
Expand Down Expand Up @@ -377,7 +377,7 @@ ClipContents::ClipContents() = default;

ClipContents::~ClipContents() = default;

bool ClipContents::Render(const ContentRenderer& renderer,
bool ClipContents::Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const {
using VS = ClipPipeline::VertexShader;
Expand Down
14 changes: 7 additions & 7 deletions impeller/entity/contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace impeller {

class ContentRenderer;
class ContentContext;
class Entity;
class Surface;
class RenderPass;
Expand All @@ -26,7 +26,7 @@ class Contents {

virtual ~Contents();

virtual bool Render(const ContentRenderer& renderer,
virtual bool Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const = 0;

Expand All @@ -41,7 +41,7 @@ class LinearGradientContents final : public Contents {
~LinearGradientContents() override;

// |Contents|
bool Render(const ContentRenderer& renderer,
bool Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const override;

Expand Down Expand Up @@ -72,7 +72,7 @@ class SolidColorContents final : public Contents {
const Color& GetColor() const;

// |Contents|
bool Render(const ContentRenderer& renderer,
bool Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const override;

Expand All @@ -99,7 +99,7 @@ class TextureContents final : public Contents {
const IRect& GetSourceRect() const;

// |Contents|
bool Render(const ContentRenderer& renderer,
bool Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const override;

Expand All @@ -126,7 +126,7 @@ class SolidStrokeContents final : public Contents {
Scalar GetStrokeSize() const;

// |Contents|
bool Render(const ContentRenderer& renderer,
bool Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const override;

Expand All @@ -144,7 +144,7 @@ class ClipContents final : public Contents {
~ClipContents();

// |Contents|
bool Render(const ContentRenderer& renderer,
bool Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const override;

Expand Down
4 changes: 2 additions & 2 deletions impeller/entity/entity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "impeller/entity/entity.h"

#include "impeller/entity/content_renderer.h"
#include "impeller/entity/content_context.h"
#include "impeller/renderer/render_pass.h"

namespace impeller {
Expand Down Expand Up @@ -65,7 +65,7 @@ void Entity::IncrementStencilDepth(uint32_t increment) {
stencil_depth_ += increment;
}

bool Entity::Render(ContentRenderer& renderer, RenderPass& parent_pass) const {
bool Entity::Render(ContentContext& renderer, RenderPass& parent_pass) const {
if (!contents_) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion impeller/entity/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Entity {

uint32_t GetStencilDepth() const;

bool Render(ContentRenderer& renderer, RenderPass& parent_pass) const;
bool Render(ContentContext& renderer, RenderPass& parent_pass) const;

private:
Matrix transformation_;
Expand Down
4 changes: 2 additions & 2 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "impeller/entity/entity_pass.h"

#include "impeller/entity/content_renderer.h"
#include "impeller/entity/content_context.h"
#include "impeller/geometry/path_builder.h"
#include "impeller/renderer/command_buffer.h"
#include "impeller/renderer/render_pass.h"
Expand Down Expand Up @@ -97,7 +97,7 @@ EntityPass* EntityPass::AddSubpass(std::unique_ptr<EntityPass> pass) {
return subpasses_.emplace_back(std::move(pass)).get();
}

bool EntityPass::Render(ContentRenderer& renderer,
bool EntityPass::Render(ContentContext& renderer,
RenderPass& parent_pass) const {
for (const auto& entity : entities_) {
if (!entity.Render(renderer, parent_pass)) {
Expand Down
4 changes: 2 additions & 2 deletions impeller/entity/entity_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace impeller {

class ContentRenderer;
class ContentContext;

class EntityPass {
public:
Expand Down Expand Up @@ -45,7 +45,7 @@ class EntityPass {

EntityPass* GetSuperpass() const;

bool Render(ContentRenderer& renderer, RenderPass& parent_pass) const;
bool Render(ContentContext& renderer, RenderPass& parent_pass) const;

void IterateAllEntities(std::function<bool(Entity&)> iterator);

Expand Down
Loading

0 comments on commit 57a0728

Please sign in to comment.