Merge pull request #10 from gunyarakun/fix-invalid-return
[cocotron.git] / Onyx2D / O2Paint_pattern.m
blob0887ce3d4c2c285a1b6261d9fd2ce743c8400214
1 /*------------------------------------------------------------------------
2  *
3  * Derivative of the OpenVG 1.0.1 Reference Implementation
4  * -------------------------------------
5  *
6  * Copyright (c) 2007 The Khronos Group Inc.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and /or associated documentation files
10  * (the "Materials "), to deal in the Materials without restriction,
11  * including without limitation the rights to use, copy, modify, merge,
12  * publish, distribute, sublicense, and/or sell copies of the Materials,
13  * and to permit persons to whom the Materials are furnished to do so,
14  * subject to the following conditions: 
15  *
16  * The above copyright notice and this permission notice shall be included 
17  * in all copies or substantial portions of the Materials. 
18  *
19  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
23  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
25  * THE USE OR OTHER DEALINGS IN THE MATERIALS.
26  *
27  *-------------------------------------------------------------------*/
28 #import <Onyx2D/O2Paint_pattern.h>
29 #import <Onyx2D/O2Surface.h>
31 @implementation O2Paint_pattern
33 ONYX2D_STATIC int o2pattern_largb8u_PRE(O2Paint *selfX,int x,int y,O2argb8u *span,int length){
34    O2Paint_pattern *self=(O2Paint_pattern *)selfX;
35    O2Image         *image=self->_image;
36       
37    O2ImageReadPatternSpan_largb8u_PRE(image,x,y,span,length,self->m_surfaceToPaintMatrix,kO2PatternTilingNoDistortion);
38    
39    return length;
42 ONYX2D_STATIC int o2pattern_largb32f_PRE(O2Paint *selfX,int x,int y,O2argb32f *span,int length){
43    O2Paint_pattern *self=(O2Paint_pattern *)selfX;
44    int i;
45    
46    for(i=0;i<length;i++)
47     span[i]=O2argb32fInit(1,0,0,1);
49    return length;
52 #if 0
53 static int O2PaintReadPremultipliedPatternSpan(O2Paint *selfX,int x,int y,O2argb32f *span,int length){
54    O2Paint_pattern *self=(O2Paint_pattern *)selfX;
55    
56    O2ImageReadPatternSpan_largb32f_PRE(self->_image,x, y,span,length, self->m_surfaceToPaintMatrix, kO2PatternTilingConstantSpacing);
57    return length;
59 #endif
61 -initWithImage:(O2Image *)image surfaceToPaintTransform:(O2AffineTransform)xform phase:(O2Size)phase {   
62 //   O2PaintInitWithTransform(self,O2AffineTransformMakeTranslation(phase.width,phase.height));
63    O2PaintInitWithTransform(self,O2AffineTransformIdentity);
64    _paint_largb8u_PRE=o2pattern_largb8u_PRE;
65    _paint_largb32f_PRE=o2pattern_largb32f_PRE;
66    _image=[image retain];
67    _phase=phase;
68    return self;
71 -(void)dealloc {
72    [_image release];
73    [super dealloc];
76 @end