From b77f2b8b669841a36b2675a540a3f0cc5889ba3a Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Wed, 11 Aug 2021 14:50:23 -0700 Subject: [PATCH] Stub out picture recorders and operations. --- engine/src/flutter/impeller/aiks/BUILD.gn | 4 +++ engine/src/flutter/impeller/aiks/canvas.cc | 23 +++++++--------- engine/src/flutter/impeller/aiks/canvas.h | 6 +++++ engine/src/flutter/impeller/aiks/picture.cc | 5 +++- engine/src/flutter/impeller/aiks/picture.h | 9 ++++++- .../impeller/aiks/picture_operation.cc | 13 +++++++++ .../flutter/impeller/aiks/picture_operation.h | 21 +++++++++++++++ .../flutter/impeller/aiks/picture_recorder.cc | 23 ++++++++++++++++ .../flutter/impeller/aiks/picture_recorder.h | 27 +++++++++++++++++++ 9 files changed, 115 insertions(+), 16 deletions(-) create mode 100644 engine/src/flutter/impeller/aiks/picture_operation.cc create mode 100644 engine/src/flutter/impeller/aiks/picture_operation.h create mode 100644 engine/src/flutter/impeller/aiks/picture_recorder.cc create mode 100644 engine/src/flutter/impeller/aiks/picture_recorder.h diff --git a/engine/src/flutter/impeller/aiks/BUILD.gn b/engine/src/flutter/impeller/aiks/BUILD.gn index 2f735582de..aa14b0af7c 100644 --- a/engine/src/flutter/impeller/aiks/BUILD.gn +++ b/engine/src/flutter/impeller/aiks/BUILD.gn @@ -14,6 +14,10 @@ impeller_component("aiks") { "paint.h", "picture.cc", "picture.h", + "picture_operation.cc", + "picture_operation.h", + "picture_recorder.cc", + "picture_recorder.h", ] public_deps = [ diff --git a/engine/src/flutter/impeller/aiks/canvas.cc b/engine/src/flutter/impeller/aiks/canvas.cc index f3b32fe523..633230b9ff 100644 --- a/engine/src/flutter/impeller/aiks/canvas.cc +++ b/engine/src/flutter/impeller/aiks/canvas.cc @@ -5,6 +5,7 @@ #include "impeller/aiks/canvas.h" #include "flutter/fml/logging.h" +#include "impeller/aiks/picture_operation.h" namespace impeller { @@ -52,24 +53,18 @@ size_t Canvas::GetSaveCount() const { return xformation_stack_.size(); } -void Canvas::DrawPath(Path path, Paint paint) { - FML_LOG(ERROR) << "WIP"; -} +void Canvas::DrawPath(Path path, Paint paint) {} -void Canvas::SaveLayer(const Paint& paint, std::optional bounds) { - FML_LOG(ERROR) << "WIP"; -} +void Canvas::SaveLayer(const Paint& paint, std::optional bounds) {} -void Canvas::ClipPath(Path path) { - FML_LOG(ERROR) << "WIP"; -} +void Canvas::ClipPath(Path path) {} -void Canvas::DrawShadow(Path path, Color color, Scalar elevation) { - FML_LOG(ERROR) << "WIP"; -} +void Canvas::DrawShadow(Path path, Color color, Scalar elevation) {} -void Canvas::DrawPicture(std::shared_ptr picture) { - FML_LOG(ERROR) << "WIP"; +void Canvas::DrawPicture(std::shared_ptr picture) {} + +std::shared_ptr Canvas::EndRecordingAsPicture() { + return std::make_shared(std::move(ops_)); } } // namespace impeller diff --git a/engine/src/flutter/impeller/aiks/canvas.h b/engine/src/flutter/impeller/aiks/canvas.h index bf5ff3b895..e35d0f837a 100644 --- a/engine/src/flutter/impeller/aiks/canvas.h +++ b/engine/src/flutter/impeller/aiks/canvas.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "flutter/fml/macros.h" #include "impeller/aiks/paint.h" @@ -17,6 +18,8 @@ namespace impeller { +class PictureOperation; + class Canvas { public: Canvas(); @@ -49,8 +52,11 @@ class Canvas { void DrawPicture(std::shared_ptr picture); + std::shared_ptr EndRecordingAsPicture(); + private: std::stack xformation_stack_; + std::vector> ops_; FML_DISALLOW_COPY_AND_ASSIGN(Canvas); }; diff --git a/engine/src/flutter/impeller/aiks/picture.cc b/engine/src/flutter/impeller/aiks/picture.cc index 14217674b4..9f7174bb45 100644 --- a/engine/src/flutter/impeller/aiks/picture.cc +++ b/engine/src/flutter/impeller/aiks/picture.cc @@ -4,9 +4,12 @@ #include "impeller/aiks/picture.h" +#include "impeller/aiks/picture_operation.h" + namespace impeller { -Picture::Picture() = default; +Picture::Picture(std::vector> operations) + : ops_(std::move(operations)) {} Picture::~Picture() = default; diff --git a/engine/src/flutter/impeller/aiks/picture.h b/engine/src/flutter/impeller/aiks/picture.h index 3ced1ed0c2..9b43516129 100644 --- a/engine/src/flutter/impeller/aiks/picture.h +++ b/engine/src/flutter/impeller/aiks/picture.h @@ -4,17 +4,24 @@ #pragma once +#include +#include + #include "flutter/fml/macros.h" namespace impeller { +class PictureOperation; + class Picture { public: - Picture(); + Picture(std::vector> operations); ~Picture(); private: + std::vector> ops_; + FML_DISALLOW_COPY_AND_ASSIGN(Picture); }; diff --git a/engine/src/flutter/impeller/aiks/picture_operation.cc b/engine/src/flutter/impeller/aiks/picture_operation.cc new file mode 100644 index 0000000000..ff7ad1f7fa --- /dev/null +++ b/engine/src/flutter/impeller/aiks/picture_operation.cc @@ -0,0 +1,13 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/impeller/aiks/picture_operation.h" + +namespace impeller { + +PictureOperation::PictureOperation() = default; + +PictureOperation::~PictureOperation() = default; + +} // namespace impeller diff --git a/engine/src/flutter/impeller/aiks/picture_operation.h b/engine/src/flutter/impeller/aiks/picture_operation.h new file mode 100644 index 0000000000..cfb63891d5 --- /dev/null +++ b/engine/src/flutter/impeller/aiks/picture_operation.h @@ -0,0 +1,21 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#pragma once + +#include "flutter/fml/macros.h" + +namespace impeller { + +class PictureOperation { + public: + PictureOperation(); + + ~PictureOperation(); + + private: + FML_DISALLOW_COPY_AND_ASSIGN(PictureOperation); +}; + +} // namespace impeller diff --git a/engine/src/flutter/impeller/aiks/picture_recorder.cc b/engine/src/flutter/impeller/aiks/picture_recorder.cc new file mode 100644 index 0000000000..44d76f4451 --- /dev/null +++ b/engine/src/flutter/impeller/aiks/picture_recorder.cc @@ -0,0 +1,23 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/impeller/aiks/picture_recorder.h" + +#include "flutter/impeller/aiks/canvas.h" + +namespace impeller { + +PictureRecorder::PictureRecorder() : canvas_(std::make_shared()) {} + +PictureRecorder::~PictureRecorder() = default; + +std::shared_ptr PictureRecorder::GetCanvas() const { + return canvas_; +} + +std::shared_ptr PictureRecorder::EndRecordingAsPicture() { + return canvas_->EndRecordingAsPicture(); +} + +} // namespace impeller diff --git a/engine/src/flutter/impeller/aiks/picture_recorder.h b/engine/src/flutter/impeller/aiks/picture_recorder.h new file mode 100644 index 0000000000..16c4a72aa3 --- /dev/null +++ b/engine/src/flutter/impeller/aiks/picture_recorder.h @@ -0,0 +1,27 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#pragma once + +#include "flutter/fml/macros.h" +#include "impeller/aiks/canvas.h" +#include "impeller/aiks/picture.h" + +namespace impeller { + +class PictureRecorder { + public: + PictureRecorder(); + + ~PictureRecorder(); + + std::shared_ptr GetCanvas() const; + + std::shared_ptr EndRecordingAsPicture(); + + private: + std::shared_ptr canvas_; +}; + +} // namespace impeller