1 #ifndef DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/devel-api/adaptor-framework/canvas-renderer-drawable.h>
23 #include <dali/devel-api/adaptor-framework/canvas-renderer-shape.h>
24 #include <dali/devel-api/adaptor-framework/canvas-renderer.h>
25 #include <dali/devel-api/rendering/renderer-devel.h>
26 #include <dali/integration-api/processor-interface.h>
29 #include <dali-toolkit/devel-api/controls/canvas-view/canvas-view.h>
30 #include <dali-toolkit/public-api/controls/control-impl.h>
40 class CanvasView : public Control, public Integration::Processor
44 * Construct a new CanvasView.
46 CanvasView(const Vector2& viewBox);
49 * A reference counted object may only be deleted by calling Unreference()
51 virtual ~CanvasView();
55 * Create a new CanvasView.
56 * @return A smart-pointer to the newly allocated CanvasView.
58 static Toolkit::CanvasView New(const Vector2& viewBox);
61 * @copydoc Toolkit::Control::CanvasView::AddDrawable
63 bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable);
65 private: // From Control
67 * @copydoc Control::OnRelayout
69 void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
72 * @copydoc Toolkit::Control::OnSizeSet()
74 void OnSizeSet(const Vector3& targetSize) override;
77 * @copydoc Toolkit::Control::OnInitialize
79 void OnInitialize() override;
81 protected: // Implementation of Processor
83 * @copydoc Dali::Integration::Processor::Process()
85 void Process() override;
89 * @brief Draw drawables added to CanvasView on inner canvas.
90 * Then make that buffer into a texture and add it to renderer.
95 CanvasView(const CanvasView&) = delete;
96 CanvasView& operator=(const CanvasView&) = delete;
99 CanvasRenderer mCanvasRenderer;
100 Dali::Texture mTexture;
104 } // namespace Internal
106 // Helpers for public-api forwarding methods
107 inline Toolkit::Internal::CanvasView& GetImpl(Toolkit::CanvasView& obj)
109 DALI_ASSERT_ALWAYS(obj);
110 Dali::RefObject& handle = obj.GetImplementation();
111 return static_cast<Toolkit::Internal::CanvasView&>(handle);
114 inline const Toolkit::Internal::CanvasView& GetImpl(const Toolkit::CanvasView& obj)
116 DALI_ASSERT_ALWAYS(obj);
117 const Dali::RefObject& handle = obj.GetImplementation();
118 return static_cast<const Toolkit::Internal::CanvasView&>(handle);
121 } // namespace Toolkit
125 #endif // DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H