Merge branch 'devel/graphics' into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / rendering / sampler-impl.h
1 #ifndef DALI_INTERNAL_SAMPLER_H
2 #define DALI_INTERNAL_SAMPLER_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/common/connectable.h>      // Dali::Internal::Connectable
23 #include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
24 #include <dali/internal/event/common/object-impl.h>      // Dali::Internal::Object
25 #include <dali/public-api/actors/sampling.h>
26 #include <dali/public-api/common/dali-common.h>   // DALI_ASSERT_ALWAYS
27 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
28 #include <dali/public-api/rendering/sampler.h>    // Dali::Sampler
29
30 namespace Dali
31 {
32 namespace Internal
33 {
34 namespace Render
35 {
36 struct Sampler;
37 }
38
39 class Sampler;
40 using SamplerPtr = IntrusivePtr<Sampler>;
41
42 /**
43  * Sampler is an object that contains an array of structures of values that
44  * can be accessed as properties.
45  */
46 class Sampler : public BaseObject
47 {
48 public:
49   /**
50    * Create a new Sampler.
51    * @return A smart-pointer to the newly allocated Sampler.
52    */
53   static SamplerPtr New();
54
55   /**
56    * @copydoc Dali::Sampler::SetFilterMode()
57    */
58   void SetFilterMode(Dali::FilterMode::Type minFilter, Dali::FilterMode::Type magFilter);
59
60   /**
61    * @copydoc Dali::Sampler::SetWrapMode()
62    */
63   void SetWrapMode(Dali::WrapMode::Type rWrap, Dali::WrapMode::Type sWrap, Dali::WrapMode::Type tWrap);
64
65   /**
66    * Get the render thread sampler
67    *
68    * @return The render thread sampler
69    */
70   Render::Sampler* GetSamplerRenderObject();
71
72 private:
73   Sampler();
74
75   /**
76    * Second stage initialization
77    */
78   void Initialize();
79
80 protected:
81   /**
82    * A reference counted object may only be deleted by calling Unreference()
83    */
84   ~Sampler() override;
85
86 private:                                     // data
87   EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via the update thread
88   Render::Sampler*     mRenderObject;        ///<Render thread sampler for this sampler
89 };
90
91 } // namespace Internal
92
93 // Helpers for public-api forwarding methods
94 inline Internal::Sampler& GetImplementation(Dali::Sampler& handle)
95 {
96   DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
97
98   BaseObject& object = handle.GetBaseObject();
99
100   return static_cast<Internal::Sampler&>(object);
101 }
102
103 inline const Internal::Sampler& GetImplementation(const Dali::Sampler& handle)
104 {
105   DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
106
107   const BaseObject& object = handle.GetBaseObject();
108
109   return static_cast<const Internal::Sampler&>(object);
110 }
111
112 } // namespace Dali
113
114 #endif // DALI_INTERNAL_SAMPLER_H