forked from firka/flutter
Finish wiring up render passes.
This commit is contained in:
@@ -4,10 +4,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/compositor/formats.h"
|
||||
#include "impeller/compositor/texture.h"
|
||||
#include "impeller/entity/color.h"
|
||||
#include "impeller/geometry/color.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
@@ -15,6 +17,8 @@ struct RenderPassAttachment {
|
||||
std::shared_ptr<Texture> texture;
|
||||
LoadAction load_action = LoadAction::kDontCare;
|
||||
StoreAction store_action = StoreAction::kDontCare;
|
||||
|
||||
constexpr operator bool() const { return static_cast<bool>(texture); }
|
||||
};
|
||||
|
||||
struct ColorRenderPassAttachment : public RenderPassAttachment {
|
||||
@@ -31,17 +35,34 @@ struct StencilRenderPassAttachment : public RenderPassAttachment {
|
||||
|
||||
class RenderPassDescriptor {
|
||||
public:
|
||||
RenderPassDescriptor();
|
||||
|
||||
~RenderPassDescriptor();
|
||||
|
||||
RenderPassDescriptor& SetColorAttachment(ColorRenderPassAttachment attachment,
|
||||
size_t index);
|
||||
|
||||
RenderPassDescriptor& SetDepthAttachment(
|
||||
DepthRenderPassAttachment attachment);
|
||||
|
||||
RenderPassDescriptor& SetStencilAttachment(
|
||||
StencilRenderPassAttachment attachment);
|
||||
|
||||
private:
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(RenderPassDescriptor);
|
||||
std::map<size_t, ColorRenderPassAttachment> color_;
|
||||
std::optional<DepthRenderPassAttachment> depth_;
|
||||
std::optional<StencilRenderPassAttachment> stencil_;
|
||||
};
|
||||
|
||||
class RenderPass {
|
||||
public:
|
||||
RenderPass();
|
||||
RenderPass(RenderPassDescriptor desc);
|
||||
|
||||
~RenderPass();
|
||||
|
||||
private:
|
||||
RenderPassDescriptor desc_;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(RenderPass);
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,36 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
RenderPass::RenderPass() = default;
|
||||
RenderPassDescriptor::RenderPassDescriptor() = default;
|
||||
|
||||
RenderPassDescriptor::~RenderPassDescriptor() = default;
|
||||
|
||||
RenderPassDescriptor& RenderPassDescriptor::SetColorAttachment(
|
||||
ColorRenderPassAttachment attachment,
|
||||
size_t index) {
|
||||
if (attachment) {
|
||||
color_[index] = attachment;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
RenderPassDescriptor& RenderPassDescriptor::SetDepthAttachment(
|
||||
DepthRenderPassAttachment attachment) {
|
||||
if (attachment) {
|
||||
depth_ = std::move(attachment);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
RenderPassDescriptor& RenderPassDescriptor::SetStencilAttachment(
|
||||
StencilRenderPassAttachment attachment) {
|
||||
if (attachment) {
|
||||
stencil_ = std::move(attachment);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
RenderPass::RenderPass(RenderPassDescriptor desc) : desc_(std::move(desc)) {}
|
||||
|
||||
RenderPass::~RenderPass() = default;
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ import("//flutter/impeller/tools/impeller.gni")
|
||||
|
||||
impeller_component("entity") {
|
||||
sources = [
|
||||
"color.cc",
|
||||
"color.h",
|
||||
"entity.cc",
|
||||
"entity.h",
|
||||
]
|
||||
|
||||
@@ -6,6 +6,8 @@ import("//flutter/impeller/tools/impeller.gni")
|
||||
|
||||
impeller_component("geometry") {
|
||||
sources = [
|
||||
"color.cc",
|
||||
"color.h",
|
||||
"matrix.cc",
|
||||
"matrix.h",
|
||||
"path.cc",
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "color.h"
|
||||
#include "impeller/geometry/color.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
Reference in New Issue
Block a user