Update defaults to be closer to Skia.
This commit is contained in:
@@ -11,7 +11,11 @@
|
||||
namespace impeller {
|
||||
|
||||
Canvas::Canvas() {
|
||||
xformation_stack_.push(Matrix{});
|
||||
xformation_stack_.push({});
|
||||
|
||||
Paint default_paint;
|
||||
default_paint.color = Color::White();
|
||||
paint_stack_.push(default_paint);
|
||||
}
|
||||
|
||||
Canvas::~Canvas() = default;
|
||||
@@ -19,6 +23,7 @@ Canvas::~Canvas() = default;
|
||||
void Canvas::Save() {
|
||||
FML_DCHECK(xformation_stack_.size() > 0);
|
||||
xformation_stack_.push(xformation_stack_.top());
|
||||
paint_stack_.push(paint_stack_.top());
|
||||
}
|
||||
|
||||
bool Canvas::Restore() {
|
||||
@@ -27,11 +32,12 @@ bool Canvas::Restore() {
|
||||
return false;
|
||||
}
|
||||
xformation_stack_.pop();
|
||||
paint_stack_.pop();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Canvas::Concat(const Matrix& xformation) {
|
||||
xformation_stack_.top() = xformation_stack_.top() * xformation;
|
||||
xformation_stack_.top() = xformation * xformation_stack_.top();
|
||||
}
|
||||
|
||||
const Matrix& Canvas::GetCurrentTransformation() const {
|
||||
@@ -54,20 +60,28 @@ size_t Canvas::GetSaveCount() const {
|
||||
return xformation_stack_.size();
|
||||
}
|
||||
|
||||
void AssertionBreak() {}
|
||||
void Canvas::RestoreToCount(size_t count) {
|
||||
while (GetSaveCount() > count) {
|
||||
if (!Restore()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Canvas::DrawPath(Path path, Paint paint) {
|
||||
if (path.GetBoundingBox().IsZero()) {
|
||||
AssertionBreak();
|
||||
}
|
||||
Color color = paint.color;
|
||||
color.alpha *= paint_stack_.top().color.alpha;
|
||||
Entity entity;
|
||||
entity.SetTransformation(GetCurrentTransformation());
|
||||
entity.SetPath(std::move(path));
|
||||
entity.SetBackgroundColor(paint.color);
|
||||
entity.SetBackgroundColor(color);
|
||||
ops_.emplace_back(std::move(entity));
|
||||
}
|
||||
|
||||
void Canvas::SaveLayer(const Paint& paint, std::optional<Rect> bounds) {}
|
||||
void Canvas::SaveLayer(const Paint& paint, std::optional<Rect> bounds) {
|
||||
Save();
|
||||
paint_stack_.top() = paint;
|
||||
}
|
||||
|
||||
void Canvas::ClipPath(Path path) {
|
||||
Entity entity;
|
||||
|
||||
@@ -34,6 +34,8 @@ class Canvas {
|
||||
|
||||
size_t GetSaveCount() const;
|
||||
|
||||
void RestoreToCount(size_t count);
|
||||
|
||||
const Matrix& GetCurrentTransformation() const;
|
||||
|
||||
void Concat(const Matrix& xformation);
|
||||
@@ -56,6 +58,7 @@ class Canvas {
|
||||
|
||||
private:
|
||||
std::stack<Matrix> xformation_stack_;
|
||||
std::stack<Paint> paint_stack_;
|
||||
std::vector<Entity> ops_;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(Canvas);
|
||||
|
||||
@@ -181,13 +181,13 @@ struct PipelineColorAttachment {
|
||||
/// final_color = final_color & write_mask;
|
||||
/// ```
|
||||
|
||||
BlendFactor src_color_blend_factor = BlendFactor::kOne;
|
||||
BlendFactor src_color_blend_factor = BlendFactor::kSourceAlpha;
|
||||
BlendOperation color_blend_op = BlendOperation::kAdd;
|
||||
BlendFactor dst_color_blend_factor = BlendFactor::kZero;
|
||||
BlendFactor dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha;
|
||||
|
||||
BlendFactor src_alpha_blend_factor = BlendFactor::kOne;
|
||||
BlendFactor src_alpha_blend_factor = BlendFactor::kSourceAlpha;
|
||||
BlendOperation alpha_blend_op = BlendOperation::kAdd;
|
||||
BlendFactor dst_alpha_blend_factor = BlendFactor::kZero;
|
||||
BlendFactor dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha;
|
||||
|
||||
std::underlying_type_t<ColorWriteMask> write_mask =
|
||||
static_cast<uint64_t>(ColorWriteMask::kAll);
|
||||
|
||||
@@ -86,6 +86,7 @@ struct PipelineBuilder {
|
||||
// convention that the first stage output is the color output.
|
||||
PipelineColorAttachment color0;
|
||||
color0.format = PixelFormat::kB8G8R8A8UNormInt;
|
||||
color0.blending_enabled = true;
|
||||
desc.SetColorAttachmentDescriptor(0u, std::move(color0));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace impeller {
|
||||
class Tessellator {
|
||||
public:
|
||||
enum class FillType {
|
||||
kOdd, // The default winding order.
|
||||
kNonZero,
|
||||
kNonZero, // The default winding order.
|
||||
kOdd,
|
||||
kPositive,
|
||||
kNegative,
|
||||
kAbsGeqTwo,
|
||||
@@ -38,7 +38,7 @@ class Tessellator {
|
||||
VertexCallback callback) const;
|
||||
|
||||
private:
|
||||
FillType fill_type_ = FillType::kOdd;
|
||||
FillType fill_type_ = FillType::kNonZero;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(Tessellator);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user