1 #ifndef DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H
2 #define DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H
5 * Copyright (c) 2018 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.
20 #include <dali/public-api/actors/sampling.h>
21 #include <dali/public-api/rendering/sampler.h>
22 #include <dali/internal/common/message.h>
23 #include <dali/internal/event/common/event-thread-services.h>
35 typedef Dali::FilterMode::Type FilterMode;
36 typedef Dali::WrapMode::Type WrapMode;
42 :mMinificationFilter(FilterMode::DEFAULT),
43 mMagnificationFilter(FilterMode::DEFAULT),
44 mSWrapMode(WrapMode::DEFAULT),
45 mTWrapMode(WrapMode::DEFAULT),
46 mRWrapMode(WrapMode::DEFAULT)
57 * Sets the filter modes for an existing sampler
58 * @param[in] sampler The sampler
59 * @param[in] minFilterMode The filter to use under minification
60 * @param[in] magFilterMode The filter to use under magnification
62 void SetFilterMode( unsigned int minFilterMode, unsigned int magFilterMode )
64 mMinificationFilter = static_cast<Dali::FilterMode::Type>(minFilterMode);
65 mMagnificationFilter = static_cast<Dali::FilterMode::Type>(magFilterMode );
69 * Sets the wrap mode for an existing sampler
70 * @param[in] sampler The sampler
71 * @param[in] rWrapMode Wrapping mode in z direction
72 * @param[in] sWrapMode Wrapping mode in x direction
73 * @param[in] tWrapMode Wrapping mode in y direction
75 void SetWrapMode( unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode )
77 mRWrapMode = static_cast<Dali::WrapMode::Type>(rWrapMode);
78 mSWrapMode = static_cast<Dali::WrapMode::Type>(sWrapMode);
79 mTWrapMode = static_cast<Dali::WrapMode::Type>(tWrapMode);
82 bool operator==(const Sampler& rhs) const
84 return ( ( mMinificationFilter == rhs.mMinificationFilter ) &&
85 ( mMagnificationFilter == rhs.mMagnificationFilter ) &&
86 ( mSWrapMode == rhs.mSWrapMode ) &&
87 ( mTWrapMode == rhs.mTWrapMode ) &&
88 ( mRWrapMode == rhs.mRWrapMode ) );
91 bool operator!=(const Sampler& rhs) const
93 return !(*this == rhs);
96 FilterMode mMinificationFilter : 4; ///< The minify filter
97 FilterMode mMagnificationFilter : 4; ///< The magnify filter
98 WrapMode mSWrapMode : 4; ///< The horizontal wrap mode
99 WrapMode mTWrapMode : 4; ///< The vertical wrap mode
100 WrapMode mRWrapMode : 4; ///< The vertical wrap mode
104 inline void SetFilterModeMessage( EventThreadServices& eventThreadServices, SceneGraph::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
106 typedef MessageValue2< SceneGraph::Sampler, unsigned int, unsigned int > LocalType;
108 // Reserve some memory inside the message queue
109 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
111 // Construct message in the message queue memory; note that delete should not be called on the return value
112 new (slot) LocalType( &sampler, &Sampler::SetFilterMode, minFilterMode, magFilterMode );
115 inline void SetWrapModeMessage( EventThreadServices& eventThreadServices, SceneGraph::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode )
117 typedef MessageValue3< SceneGraph::Sampler, unsigned int, unsigned int, unsigned int > LocalType;
119 // Reserve some memory inside the message queue
120 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
122 // Construct message in the message queue memory; note that delete should not be called on the return value
123 new (slot) LocalType( &sampler, &Sampler::SetWrapMode, rWrapMode, sWrapMode, tWrapMode );
126 } // namespace SceneGraph
128 } // namespace Internal
133 #endif // DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H