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>
39 class CanvasViewRasterizeThread;
41 class CanvasView : public Control, public Integration::Processor
45 * Construct a new CanvasView.
47 CanvasView(const Vector2& viewBox);
50 * A reference counted object may only be deleted by calling Unreference()
52 virtual ~CanvasView();
56 * Create a new CanvasView.
57 * @return A smart-pointer to the newly allocated CanvasView.
59 static Toolkit::CanvasView New(const Vector2& viewBox);
62 * @copydoc Toolkit::Control::CanvasView::AddDrawable
64 bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable);
66 private: // From Control
68 * @copydoc Control::OnRelayout
70 void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
73 * @copydoc Toolkit::Control::OnSizeSet()
75 void OnSizeSet(const Vector3& targetSize) override;
78 * @copydoc Toolkit::Control::OnInitialize
80 void OnInitialize() override;
83 * @bried Rasterize the canvas, and add it to the view.
85 * @param[in] size The target size of the canvas view rasterization.
87 void AddRasterizationTask();
91 * @copydoc Dali::Integration::Processor::Process()
93 void Process(bool postProcessor) override;
97 * @bried Apply the rasterized image to the canvas view
99 * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
101 void ApplyRasterizedImage(PixelData rasterizedPixelData);
104 CanvasView(const CanvasView&) = delete;
105 CanvasView& operator=(const CanvasView&) = delete;
108 CanvasRenderer mCanvasRenderer;
109 Dali::Texture mTexture;
110 TextureSet mTextureSet;
112 CanvasViewRasterizeThread* mCanvasViewRasterizeThread;
115 } // namespace Internal
117 // Helpers for public-api forwarding methods
118 inline Toolkit::Internal::CanvasView& GetImpl(Toolkit::CanvasView& obj)
120 DALI_ASSERT_ALWAYS(obj);
121 Dali::RefObject& handle = obj.GetImplementation();
122 return static_cast<Toolkit::Internal::CanvasView&>(handle);
125 inline const Toolkit::Internal::CanvasView& GetImpl(const Toolkit::CanvasView& obj)
127 DALI_ASSERT_ALWAYS(obj);
128 const Dali::RefObject& handle = obj.GetImplementation();
129 return static_cast<const Toolkit::Internal::CanvasView&>(handle);
132 } // namespace Toolkit
136 #endif // DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H