Dali 3D User Interface Engine
image-sampler.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 // CLASS HEADER
20 
21 // EXTERNAL INCLUDES
22 #include <iosfwd>
23 
24 namespace Dali
25 {
26 
27 namespace Internal
28 {
29 
30 namespace ImageSampler
31 {
32 
39 void StoreSamplingParameter( unsigned int& options, unsigned int mode, int bitShift )
40 {
41  if( mode != 0 )
42  {
43  options |= ( mode << bitShift );
44  }
45 }
46 
54 unsigned int RetrieveSamplingParameter( unsigned int options, int mask, int bitShift )
55 {
56  unsigned int index = options & mask;
57 
58  index = ( index >> bitShift ); // Zero based index for array
59  return index;
60 }
61 
62 unsigned int PackBitfield( FilterMode::Type minify, FilterMode::Type magnify, WrapMode::Type uWrap, WrapMode::Type vWrap )
63 {
64  unsigned int bitfield = 0;
65  StoreSamplingParameter( bitfield, minify, MINIFY_BIT_SHIFT );
66  StoreSamplingParameter( bitfield, magnify, MAGNIFY_BIT_SHIFT );
67  StoreSamplingParameter( bitfield, uWrap, UWRAP_BIT_SHIFT );
68  StoreSamplingParameter( bitfield, vWrap, VWRAP_BIT_SHIFT );
69  return bitfield;
70 }
71 
72 FilterMode::Type GetMinifyFilterMode( unsigned int bitfield )
73 {
75 }
76 
77 FilterMode::Type GetMagnifyFilterMode( unsigned int bitfield )
78 {
80 }
81 
82 WrapMode::Type GetUWrapMode( unsigned int bitfield )
83 {
84  return static_cast<WrapMode::Type>( RetrieveSamplingParameter( bitfield, MASK_UWRAP_MODE, UWRAP_BIT_SHIFT ) );
85 }
86 
87 WrapMode::Type GetVWrapMode( unsigned int bitfield )
88 {
89  return static_cast<WrapMode::Type>( RetrieveSamplingParameter( bitfield, MASK_VWRAP_MODE, VWRAP_BIT_SHIFT ) );
90 }
91 
92 } // namespace ImageSampler
93 
94 } // namespace Internal
95 
96 } // namespace Dali
Dali Docs Home
Read more about Dali