author | Matt Plumtree <matt.plumtree@nokia.com> |
Mon, 15 Nov 2010 09:56:25 +0000 | |
branch | bug235_bringup_0 |
changeset 77 | b0395290e61f |
parent 69 | 3f914c77c2e9 |
permissions | -rw-r--r-- |
24 | 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 |
||
69
3f914c77c2e9
Host OpenVG building using GCC, without LLVM integration.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
53
diff
changeset
|
23 |
#ifndef __SFDYNAMICBLITTER_H |
3f914c77c2e9
Host OpenVG building using GCC, without LLVM integration.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
53
diff
changeset
|
24 |
#include "sfDynamicBlitter.h" |
3f914c77c2e9
Host OpenVG building using GCC, without LLVM integration.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
53
diff
changeset
|
25 |
#endif |
24 | 26 |
|
69
3f914c77c2e9
Host OpenVG building using GCC, without LLVM integration.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
53
diff
changeset
|
27 |
#if defined(RI_COMPILE_LLVM_BYTECODE) |
24 | 28 |
#include "sfCompiler.h" |
69
3f914c77c2e9
Host OpenVG building using GCC, without LLVM integration.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
53
diff
changeset
|
29 |
#endif |
24 | 30 |
|
31 |
namespace OpenVGRI { |
|
32 |
||
33 |
DynamicBlitter::DynamicBlitter() : |
|
34 |
m_maskOperation(VG_SET_MASK), |
|
35 |
m_isMaskOperation(false), |
|
36 |
m_fillColor(), |
|
37 |
m_isFill(false), |
|
38 |
||
39 |
m_signatureState(), |
|
40 |
m_uniforms() |
|
41 |
{ |
|
42 |
} |
|
43 |
||
44 |
DynamicBlitter::~DynamicBlitter() |
|
45 |
{ |
|
46 |
} |
|
47 |
||
48 |
/*static*/ void DynamicBlitter::calculateHash(BlitterHash& hash, const BlitSignatureState& state) |
|
49 |
{ |
|
50 |
const RIuint32 descBits = 10; |
|
51 |
const RIuint32 maskOperationBits = 3; |
|
52 |
const RIuint32 boolBits = 1; |
|
53 |
||
54 |
RIuint32 srcFormat = (RIuint32)(state.srcDesc.toIndex()); |
|
55 |
RIuint32 dstFormat = (RIuint32)(state.dstDesc.toIndex()); |
|
56 |
RIuint32 maskOperation = ((RIuint32)(state.maskOperation - VG_CLEAR_MASK)); |
|
57 |
RIuint32 incompatibleStride = ((RIuint32)state.incompatibleStrides); |
|
58 |
RIuint32 isMaskOperation = ((RIuint32)state.isMaskOperation); |
|
59 |
RIuint32 unsafeInput = (RIuint32)state.unsafeInput; |
|
60 |
||
61 |
int b = 0; |
|
62 |
||
63 |
b = riInsertBits32(hash.value, sizeof(hash.value), srcFormat, descBits, b); |
|
64 |
b = riInsertBits32(hash.value, sizeof(hash.value), dstFormat, descBits, b); |
|
65 |
b = riInsertBits32(hash.value, sizeof(hash.value), maskOperation, maskOperationBits, b); |
|
66 |
b = riInsertBits32(hash.value, sizeof(hash.value), incompatibleStride, boolBits, b); |
|
67 |
b = riInsertBits32(hash.value, sizeof(hash.value), isMaskOperation, boolBits, b); |
|
68 |
b = riInsertBits32(hash.value, sizeof(hash.value), unsafeInput, boolBits, b); |
|
69 |
} |
|
70 |
||
71 |
/** |
|
72 |
* \brief Blit a region. The input coordinates and dimensions must be validated outside |
|
73 |
* the blitter currently. |
|
74 |
* \note The user must also apply the storage offset to the image(s). |
|
75 |
*/ |
|
76 |
void DynamicBlitter::prepareBlit(Image* dst, const Image* src, int sx, int sy, int dx, int dy, int w, int h) |
|
77 |
{ |
|
78 |
//const Image *srcImage = src->getImage(); |
|
79 |
//Image* dstImage = dst->m_image; |
|
80 |
||
81 |
// \todo Move these to derivation of the state? |
|
82 |
m_signatureState.srcDesc = src->getDescriptor(); |
|
83 |
m_signatureState.dstDesc = dst->getDescriptor(); |
|
84 |
m_signatureState.isMaskOperation = m_isMaskOperation; |
|
85 |
m_signatureState.maskOperation = m_isMaskOperation ? m_maskOperation : VG_CLEAR_MASK; |
|
86 |
m_signatureState.incompatibleStrides = false; |
|
87 |
m_signatureState.unsafeInput = false; |
|
88 |
||
89 |
m_uniforms.src = src->getData(); |
|
90 |
m_uniforms.dst = dst->getData(); |
|
91 |
m_uniforms.srcX = sx; |
|
92 |
m_uniforms.srcY = sy; |
|
93 |
m_uniforms.dstX = dx; |
|
94 |
m_uniforms.dstY = dy; |
|
95 |
m_uniforms.width = w; |
|
96 |
m_uniforms.height = h; |
|
97 |
m_uniforms.srcStride = src->getStride(); |
|
98 |
m_uniforms.dstStride = dst->getStride(); |
|
99 |
||
100 |
if (m_signatureState.srcDesc.isZeroConversion(m_signatureState.dstDesc)) |
|
101 |
{ |
|
102 |
const int fullCopyStride = Image::descriptorToStride(m_signatureState.srcDesc, m_uniforms.width); |
|
103 |
||
104 |
if ((m_uniforms.dstStride != m_uniforms.srcStride) || (fullCopyStride != m_uniforms.srcStride)) |
|
105 |
m_signatureState.incompatibleStrides = true; |
|
106 |
} |
|
107 |
||
108 |
if (src->isUnsafe()) |
|
109 |
m_signatureState.unsafeInput = true; |
|
110 |
||
111 |
} |
|
112 |
||
113 |
void DynamicBlitter::blit() |
|
114 |
{ |
|
69
3f914c77c2e9
Host OpenVG building using GCC, without LLVM integration.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
53
diff
changeset
|
115 |
#if defined(RI_COMPILE_LLVM_BYTECODE) |
24 | 116 |
bool compiledBlitter = false; |
117 |
{ |
|
118 |
PPCompiler& compiler = PPCompiler::getCompiler(); |
|
119 |
PPCompiler::BlitterHandle blitterHandle = compiler.compileBlitter(getSignatureState()); |
|
120 |
if (blitterHandle) |
|
121 |
{ |
|
122 |
compiledBlitter = true; |
|
123 |
BlitterFunction func = compiler.getBlitterPtr(blitterHandle); |
|
124 |
func(getUniforms()); |
|
125 |
compiler.releaseBlitter(blitterHandle); |
|
126 |
} |
|
127 |
} |
|
128 |
||
129 |
if (!compiledBlitter) |
|
130 |
#endif |
|
131 |
{ |
|
69
3f914c77c2e9
Host OpenVG building using GCC, without LLVM integration.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
53
diff
changeset
|
132 |
OpenVGRI::executeBlitter(getSignatureState(), getUniforms()); |
24 | 133 |
} |
134 |
} |
|
135 |
||
136 |
} |