32e17222f1094f8630bb6c0b635d5b62d8d5953e
2 * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
23 #ifndef _NINE_SURFACE9_H_
24 #define _NINE_SURFACE9_H_
26 #include "resource9.h"
28 #include "pipe/p_state.h"
29 #include "util/u_double_list.h"
30 #include "util/u_rect.h"
31 #include "util/u_inlines.h"
35 struct NineResource9 base
;
38 struct pipe_context
*pipe
;
39 struct pipe_transfer
*transfer
;
40 struct pipe_surface
*surface
[2]; /* created on-demand (linear, sRGB) */
42 uint8_t texture
; /* rtype of container BaseTex or 0 */
44 /* resource description */
45 unsigned level
; /* refers to the pipe_resource (SetLOD !) */
46 unsigned level_actual
; /* refers to the NineTexture */
50 uint8_t *data
; /* system memory backing */
52 unsigned stride
; /* for system memory backing */
54 /* wine doesn't even use these, 2 will be enough */
55 struct u_rect dirty_rects
[2];
57 static INLINE
struct NineSurface9
*
58 NineSurface9( void *data
)
60 return (struct NineSurface9
*)data
;
64 NineSurface9_new( struct NineDevice9
*pDevice
,
65 struct NineUnknown
*pContainer
,
66 struct pipe_resource
*pResource
,
68 uint8_t TextureType
, /* 0 if pContainer isn't BaseTexure9 */
71 D3DSURFACE_DESC
*pDesc
,
72 struct NineSurface9
**ppOut
);
75 NineSurface9_ctor( struct NineSurface9
*This
,
76 struct NineUnknownParams
*pParams
,
77 struct NineUnknown
*pContainer
,
78 struct pipe_resource
*pResource
,
83 D3DSURFACE_DESC
*pDesc
);
86 NineSurface9_dtor( struct NineSurface9
*This
);
88 /*** Nine private ***/
91 NineSurface9_CreatePipeSurface( struct NineSurface9
*This
, const int sRGB
);
93 static INLINE
struct pipe_surface
*
94 NineSurface9_GetSurface( struct NineSurface9
*This
, int sRGB
)
96 if (This
->surface
[sRGB
])
97 return This
->surface
[sRGB
];
98 return NineSurface9_CreatePipeSurface(This
, sRGB
);
101 static INLINE
struct pipe_resource
*
102 NineSurface9_GetResource( struct NineSurface9
*This
)
104 return This
->base
.resource
;
108 NineSurface9_SetResource( struct NineSurface9
*This
,
109 struct pipe_resource
*resource
, unsigned level
)
112 pipe_resource_reference(&This
->base
.resource
, resource
);
113 pipe_surface_reference(&This
->surface
[0], NULL
);
114 pipe_surface_reference(&This
->surface
[1], NULL
);
118 NineSurface9_SetResourceResize( struct NineSurface9
*This
,
119 struct pipe_resource
*resource
);
122 NineSurface9_AddDirtyRect( struct NineSurface9
*This
,
123 const struct pipe_box
*box
);
126 NineSurface9_ClearDirtyRects( struct NineSurface9
*This
)
128 memset(&This
->dirty_rects
, 0, sizeof(This
->dirty_rects
));
132 NineSurface9_UploadSelf( struct NineSurface9
*This
);
135 NineSurface9_CopySurface( struct NineSurface9
*This
,
136 struct NineSurface9
*From
,
137 const POINT
*pDestPoint
,
138 const RECT
*pSourceRect
);
140 static INLINE boolean
141 NineSurface9_IsOffscreenPlain (struct NineSurface9
*This
)
143 return This
->base
.usage
== 0 && !This
->texture
;
148 NineSurface9_Dump( struct NineSurface9
*This
);
151 NineSurface9_Dump( struct NineSurface9
*This
) { }
154 /*** Direct3D public ***/
157 NineSurface9_GetContainer( struct NineSurface9
*This
,
159 void **ppContainer
);
162 NineSurface9_GetDesc( struct NineSurface9
*This
,
163 D3DSURFACE_DESC
*pDesc
);
166 NineSurface9_LockRect( struct NineSurface9
*This
,
167 D3DLOCKED_RECT
*pLockedRect
,
172 NineSurface9_UnlockRect( struct NineSurface9
*This
);
175 NineSurface9_GetDC( struct NineSurface9
*This
,
179 NineSurface9_ReleaseDC( struct NineSurface9
*This
,
182 #endif /* _NINE_SURFACE9_H_ */