|
1 /* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 * |
|
3 * Permission is hereby granted, free of charge, to any person obtaining a |
|
4 * copy of this software and /or associated documentation files |
|
5 * (the "Materials "), to deal in the Materials without restriction, |
|
6 * including without limitation the rights to use, copy, modify, merge, |
|
7 * publish, distribute, sublicense, and/or sell copies of the Materials, |
|
8 * and to permit persons to whom the Materials are furnished to do so, |
|
9 * subject to the following conditions: |
|
10 * |
|
11 * The above copyright notice and this permission notice shall be included |
|
12 * in all copies or substantial portions of the Materials. |
|
13 * |
|
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
|
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR |
|
20 * THE USE OR OTHER DEALINGS IN THE MATERIALS. |
|
21 */ |
|
22 |
|
23 #ifndef __SFBLITTER_H |
|
24 #define __SFBLITTER_H |
|
25 |
|
26 #ifndef __RIDEFS_H |
|
27 # include "riDefs.h" |
|
28 #endif |
|
29 |
|
30 #ifndef __RIIMAGE_H |
|
31 # include "riImage.h" |
|
32 #endif |
|
33 |
|
34 #include "VG/openvg.h" |
|
35 |
|
36 namespace OpenVGRI { |
|
37 |
|
38 class PPCompiler; |
|
39 |
|
40 struct BlitterHash { |
|
41 BlitterHash() {value[0] = 0; } |
|
42 bool operator==(const BlitterHash& rhs) const { return value[0] == rhs.value[0]; } |
|
43 RIuint32 value[1]; |
|
44 }; |
|
45 |
|
46 // \todo Rename to just "Blitter" and move out of the same compilation unit. |
|
47 class DynamicBlitter { |
|
48 public: |
|
49 struct BlitSignatureState { |
|
50 VGMaskOperation maskOperation; |
|
51 |
|
52 bool incompatibleStrides; |
|
53 bool isMaskOperation; |
|
54 bool unsafeInput; |
|
55 |
|
56 // Derived: |
|
57 Color::Descriptor srcDesc; |
|
58 Color::Descriptor dstDesc; |
|
59 }; |
|
60 |
|
61 struct BlitUniforms { |
|
62 void* dst; |
|
63 const void* src; |
|
64 RIuint32 srcX; |
|
65 RIuint32 srcY; |
|
66 RIuint32 dstX; |
|
67 RIuint32 dstY; |
|
68 RIuint32 width; |
|
69 RIuint32 height; |
|
70 RIint32 srcStride; |
|
71 RIint32 dstStride; |
|
72 }; |
|
73 |
|
74 public: |
|
75 DynamicBlitter(); |
|
76 ~DynamicBlitter(); |
|
77 |
|
78 static void calculateHash(BlitterHash& hash, const BlitSignatureState& state); |
|
79 |
|
80 void setMaskOperation(VGMaskOperation maskOperation) { m_maskOperation = maskOperation; } |
|
81 void enableMaskOperation(bool isMaskOperation) { m_isMaskOperation = isMaskOperation; } |
|
82 void setFillColor(const Color& fillColor) { m_fillColor = fillColor; } |
|
83 void enableFill(bool isFill) { m_isFill = isFill; } |
|
84 |
|
85 void prepareBlit(Image* dst, const Image* src, int sx, int sy, int dx, int dy, int w, int h); |
|
86 void blit(); |
|
87 |
|
88 const BlitSignatureState& getSignatureState() { return m_signatureState; } |
|
89 const BlitUniforms& getUniforms() { return m_uniforms; } |
|
90 |
|
91 private: |
|
92 |
|
93 VGMaskOperation m_maskOperation; |
|
94 bool m_isMaskOperation; |
|
95 Color m_fillColor; |
|
96 bool m_isFill; |
|
97 |
|
98 BlitSignatureState m_signatureState; |
|
99 BlitUniforms m_uniforms; |
|
100 }; |
|
101 } |
|
102 |
|
103 #endif |
|
104 |