VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/cubetexture.c@ 22496

Last change on this file since 22496 was 22496, checked in by vboxsync, 15 years ago

crOpenGL: update wine to 1.1.27 and better fix for depthstencil surface refcounting

  • Property svn:eol-style set to native
File size: 21.9 KB
Line 
1/*
2 * IWineD3DCubeTexture implementation
3 *
4 * Copyright 2002-2005 Jason Edmeades
5 * Copyright 2002-2005 Raphael Junqueira
6 * Copyright 2005 Oliver Stieber
7 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24/*
25 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
26 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
27 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
28 * a choice of LGPL license versions is made available with the language indicating
29 * that LGPLv2 or any later version may be used, or where a choice of which version
30 * of the LGPL is applied is otherwise unspecified.
31 */
32
33#include "config.h"
34#include "wined3d_private.h"
35
36WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
37
38#define GLINFO_LOCATION (*gl_info)
39
40static void cubetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb)
41{
42 /* Override the IWineD3DResource Preload method. */
43 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
44 IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
45 unsigned int i, j;
46 BOOL srgb_mode;
47 BOOL *dirty;
48
49 switch (srgb)
50 {
51 case SRGB_RGB:
52 srgb_mode = FALSE;
53 break;
54
55 case SRGB_BOTH:
56 cubetexture_internal_preload(iface, SRGB_RGB);
57 /* Fallthrough */
58
59 case SRGB_SRGB:
60 srgb_mode = TRUE;
61 break;
62
63 default:
64 srgb_mode = This->baseTexture.is_srgb;
65 break;
66 }
67 dirty = srgb_mode ? &This->baseTexture.srgbDirty : &This->baseTexture.dirty;
68
69 TRACE("(%p) : About to load texture: dirtified(%u).\n", This, *dirty);
70
71 /* We only have to activate a context for gl when we're not drawing.
72 * In most cases PreLoad will be called during draw and a context was
73 * activated at the beginning of drawPrimitive. */
74 if (!device->isInDraw)
75 {
76 /* No danger of recursive calls, ActivateContext sets isInDraw to true
77 * when loading offscreen render targets into their texture. */
78 ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
79 }
80
81 if (This->resource.format_desc->format == WINED3DFMT_P8
82 || This->resource.format_desc->format == WINED3DFMT_A8P8)
83 {
84 for (i = 0; i < This->baseTexture.levels; ++i)
85 {
86 for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j)
87 {
88 if (palette9_changed((IWineD3DSurfaceImpl *)This->surfaces[j][i]))
89 {
90 TRACE("Reloading surface because the d3d8/9 palette was changed.\n");
91 /* TODO: This is not necessarily needed with hw palettized texture support. */
92 IWineD3DSurface_LoadLocation(This->surfaces[j][i], SFLAG_INSYSMEM, NULL);
93 /* Make sure the texture is reloaded because of the palette change,
94 * this kills performance though :( */
95 IWineD3DSurface_ModifyLocation(This->surfaces[j][i], SFLAG_INTEXTURE, FALSE);
96 }
97 }
98 }
99 }
100
101 /* If the texture is marked dirty or the srgb sampler setting has changed
102 * since the last load then reload the surfaces. */
103 if (*dirty)
104 {
105 for (i = 0; i < This->baseTexture.levels; ++i)
106 {
107 for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j)
108 {
109 IWineD3DSurface_LoadTexture(This->surfaces[j][i], srgb_mode);
110 }
111 }
112 }
113 else
114 {
115 TRACE("(%p) Texture not dirty, nothing to do.\n" , iface);
116 }
117
118 /* No longer dirty. */
119 *dirty = FALSE;
120}
121
122static void cubetexture_cleanup(IWineD3DCubeTextureImpl *This, D3DCB_DESTROYSURFACEFN surface_destroy_cb)
123{
124 unsigned int i, j;
125
126 TRACE("(%p) : Cleaning up.\n", This);
127
128 for (i = 0; i < This->baseTexture.levels; ++i)
129 {
130 for (j = 0; j < 6; ++j)
131 {
132 IWineD3DSurface *surface = This->surfaces[j][i];
133
134 if (surface)
135 {
136 /* Clean out the texture name we gave to the surface so that the
137 * surface doesn't try and release it. */
138 surface_set_texture_name(surface, 0, TRUE);
139 surface_set_texture_name(surface, 0, FALSE);
140 surface_set_texture_target(surface, 0);
141 IWineD3DSurface_SetContainer(surface, NULL);
142 surface_destroy_cb(surface);
143 }
144 }
145 }
146 basetexture_cleanup((IWineD3DBaseTexture *)This);
147}
148
149HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UINT levels,
150 IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, IUnknown *parent)
151{
152 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
153 const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
154 UINT pow2_edge_length;
155 unsigned int i, j;
156 UINT tmp_w;
157 HRESULT hr;
158
159 /* TODO: It should only be possible to create textures for formats
160 * that are reported as supported. */
161 if (WINED3DFMT_UNKNOWN >= format)
162 {
163 WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
164 return WINED3DERR_INVALIDCALL;
165 }
166
167 if (!GL_SUPPORT(ARB_TEXTURE_CUBE_MAP) && pool != WINED3DPOOL_SCRATCH)
168 {
169 WARN("(%p) : Tried to create not supported cube texture.\n", texture);
170 return WINED3DERR_INVALIDCALL;
171 }
172
173 /* Calculate levels for mip mapping */
174 if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
175 {
176 if (!GL_SUPPORT(SGIS_GENERATE_MIPMAP))
177 {
178 WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
179 return WINED3DERR_INVALIDCALL;
180 }
181
182 if (levels > 1)
183 {
184 WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n");
185 return WINED3DERR_INVALIDCALL;
186 }
187
188 levels = 1;
189 }
190 else if (!levels)
191 {
192 levels = wined3d_log2i(edge_length) + 1;
193 TRACE("Calculated levels = %u.\n", levels);
194 }
195
196 hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels,
197 WINED3DRTYPE_CUBETEXTURE, device, 0, usage, format_desc, pool, parent);
198 if (FAILED(hr))
199 {
200 WARN("Failed to initialize basetexture, returning %#x\n", hr);
201 return hr;
202 }
203
204 /* Find the nearest pow2 match. */
205 pow2_edge_length = 1;
206 while (pow2_edge_length < edge_length) pow2_edge_length <<= 1;
207
208 if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO) || (edge_length == pow2_edge_length))
209 {
210 /* Precalculated scaling for 'faked' non power of two texture coords. */
211 texture->baseTexture.pow2Matrix[0] = 1.0f;
212 texture->baseTexture.pow2Matrix[5] = 1.0f;
213 texture->baseTexture.pow2Matrix[10] = 1.0f;
214 texture->baseTexture.pow2Matrix[15] = 1.0f;
215 }
216 else
217 {
218 /* Precalculated scaling for 'faked' non power of two texture coords. */
219 texture->baseTexture.pow2Matrix[0] = ((float)edge_length) / ((float)pow2_edge_length);
220 texture->baseTexture.pow2Matrix[5] = ((float)edge_length) / ((float)pow2_edge_length);
221 texture->baseTexture.pow2Matrix[10] = ((float)edge_length) / ((float)pow2_edge_length);
222 texture->baseTexture.pow2Matrix[15] = 1.0f;
223 texture->baseTexture.pow2Matrix_identity = FALSE;
224 }
225
226 /* Generate all the surfaces. */
227 tmp_w = edge_length;
228 for (i = 0; i < texture->baseTexture.levels; ++i)
229 {
230 /* Create the 6 faces. */
231 for (j = 0; j < 6; ++j)
232 {
233 static const GLenum cube_targets[6] =
234 {
235 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
236 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
237 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
238 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
239 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
240 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
241 };
242
243 hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_w,
244 format, usage, pool, i /* Level */, j, &texture->surfaces[j][i]);
245 if (FAILED(hr))
246 {
247 FIXME("(%p) Failed to create surface, hr %#x.\n", texture, hr);
248 texture->surfaces[j][i] = NULL;
249 cubetexture_cleanup(texture, D3DCB_DefaultDestroySurface);
250 return hr;
251 }
252
253 IWineD3DSurface_SetContainer(texture->surfaces[j][i], (IWineD3DBase *)texture);
254 TRACE("Created surface level %u @ %p.\n", i, texture->surfaces[j][i]);
255 surface_set_texture_target(texture->surfaces[j][i], cube_targets[j]);
256 }
257 tmp_w = max(1, tmp_w >> 1);
258 }
259 texture->baseTexture.internal_preload = cubetexture_internal_preload;
260
261 return WINED3D_OK;
262}
263
264#undef GLINFO_LOCATION
265
266/* *******************************************
267 IWineD3DCubeTexture IUnknown parts follow
268 ******************************************* */
269
270#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
271
272static HRESULT WINAPI IWineD3DCubeTextureImpl_QueryInterface(IWineD3DCubeTexture *iface, REFIID riid, LPVOID *ppobj)
273{
274 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
275 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
276 if (IsEqualGUID(riid, &IID_IUnknown)
277 || IsEqualGUID(riid, &IID_IWineD3DBase)
278 || IsEqualGUID(riid, &IID_IWineD3DResource)
279 || IsEqualGUID(riid, &IID_IWineD3DBaseTexture)
280 || IsEqualGUID(riid, &IID_IWineD3DCubeTexture)) {
281 IUnknown_AddRef(iface);
282 *ppobj = This;
283 return S_OK;
284 }
285 *ppobj = NULL;
286 return E_NOINTERFACE;
287}
288
289static ULONG WINAPI IWineD3DCubeTextureImpl_AddRef(IWineD3DCubeTexture *iface) {
290 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
291 TRACE("(%p) : AddRef increasing from %d\n", This, This->resource.ref);
292 return InterlockedIncrement(&This->resource.ref);
293}
294
295static ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface) {
296 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
297 ULONG ref;
298 TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
299 ref = InterlockedDecrement(&This->resource.ref);
300 if (ref == 0) {
301 IWineD3DCubeTexture_Destroy(iface, D3DCB_DefaultDestroySurface);
302 }
303 return ref;
304}
305
306/* ****************************************************
307 IWineD3DCubeTexture IWineD3DResource parts follow
308 **************************************************** */
309static HRESULT WINAPI IWineD3DCubeTextureImpl_GetDevice(IWineD3DCubeTexture *iface, IWineD3DDevice** ppDevice) {
310 return resource_get_device((IWineD3DResource *)iface, ppDevice);
311}
312
313static HRESULT WINAPI IWineD3DCubeTextureImpl_SetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
314 return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
315}
316
317static HRESULT WINAPI IWineD3DCubeTextureImpl_GetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
318 return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
319}
320
321static HRESULT WINAPI IWineD3DCubeTextureImpl_FreePrivateData(IWineD3DCubeTexture *iface, REFGUID refguid) {
322 return resource_free_private_data((IWineD3DResource *)iface, refguid);
323}
324
325static DWORD WINAPI IWineD3DCubeTextureImpl_SetPriority(IWineD3DCubeTexture *iface, DWORD PriorityNew) {
326 return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
327}
328
329static DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *iface) {
330 return resource_get_priority((IWineD3DResource *)iface);
331}
332
333static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
334 cubetexture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
335}
336
337static void WINAPI IWineD3DCubeTextureImpl_UnLoad(IWineD3DCubeTexture *iface) {
338 unsigned int i, j;
339 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
340 TRACE("(%p)\n", This);
341
342 /* Unload all the surfaces and reset the texture name. If UnLoad was called on the
343 * surface before, this one will be a NOP and vice versa. Unloading an unloaded
344 * surface is fine
345 */
346 for (i = 0; i < This->baseTexture.levels; i++) {
347 for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z ; j++) {
348 IWineD3DSurface_UnLoad(This->surfaces[j][i]);
349 surface_set_texture_name(This->surfaces[j][i], 0, TRUE);
350 surface_set_texture_name(This->surfaces[j][i], 0, FALSE);
351 }
352 }
353
354 basetexture_unload((IWineD3DBaseTexture *)iface);
355}
356
357static WINED3DRESOURCETYPE WINAPI IWineD3DCubeTextureImpl_GetType(IWineD3DCubeTexture *iface) {
358 return resource_get_type((IWineD3DResource *)iface);
359}
360
361static HRESULT WINAPI IWineD3DCubeTextureImpl_GetParent(IWineD3DCubeTexture *iface, IUnknown **pParent) {
362 return resource_get_parent((IWineD3DResource *)iface, pParent);
363}
364
365/* ******************************************************
366 IWineD3DCubeTexture IWineD3DBaseTexture parts follow
367 ****************************************************** */
368static DWORD WINAPI IWineD3DCubeTextureImpl_SetLOD(IWineD3DCubeTexture *iface, DWORD LODNew) {
369 return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
370}
371
372static DWORD WINAPI IWineD3DCubeTextureImpl_GetLOD(IWineD3DCubeTexture *iface) {
373 return basetexture_get_lod((IWineD3DBaseTexture *)iface);
374}
375
376static DWORD WINAPI IWineD3DCubeTextureImpl_GetLevelCount(IWineD3DCubeTexture *iface) {
377 return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
378}
379
380static HRESULT WINAPI IWineD3DCubeTextureImpl_SetAutoGenFilterType(IWineD3DCubeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
381 return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
382}
383
384static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DCubeTextureImpl_GetAutoGenFilterType(IWineD3DCubeTexture *iface) {
385 return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
386}
387
388static void WINAPI IWineD3DCubeTextureImpl_GenerateMipSubLevels(IWineD3DCubeTexture *iface) {
389 basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
390}
391
392/* Internal function, No d3d mapping */
393static BOOL WINAPI IWineD3DCubeTextureImpl_SetDirty(IWineD3DCubeTexture *iface, BOOL dirty) {
394 return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
395}
396
397/* Internal function, No d3d mapping */
398static BOOL WINAPI IWineD3DCubeTextureImpl_GetDirty(IWineD3DCubeTexture *iface) {
399 return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
400}
401
402/* Context activation is done by the caller. */
403static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *iface, BOOL srgb) {
404 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
405 BOOL set_gl_texture_desc;
406 HRESULT hr;
407
408 TRACE("(%p) : relay to BaseTexture\n", This);
409
410 hr = basetexture_bind((IWineD3DBaseTexture *)iface, srgb, &set_gl_texture_desc);
411 if (set_gl_texture_desc && SUCCEEDED(hr)) {
412 UINT i, j;
413 for (i = 0; i < This->baseTexture.levels; ++i) {
414 for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j) {
415 if(This->baseTexture.is_srgb) {
416 surface_set_texture_name(This->surfaces[j][i], This->baseTexture.srgbTextureName, TRUE);
417 } else {
418 surface_set_texture_name(This->surfaces[j][i], This->baseTexture.textureName, FALSE);
419 }
420 }
421 }
422 }
423
424 return hr;
425}
426
427static UINT WINAPI IWineD3DCubeTextureImpl_GetTextureDimensions(IWineD3DCubeTexture *iface){
428 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
429 TRACE("(%p)\n", This);
430
431 return GL_TEXTURE_CUBE_MAP_ARB;
432}
433
434static BOOL WINAPI IWineD3DCubeTextureImpl_IsCondNP2(IWineD3DCubeTexture *iface) {
435 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
436 TRACE("(%p)\n", This);
437
438 return FALSE;
439}
440
441/* *******************************************
442 IWineD3DCubeTexture IWineD3DCubeTexture parts follow
443 ******************************************* */
444static void WINAPI IWineD3DCubeTextureImpl_Destroy(IWineD3DCubeTexture *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroySurface) {
445 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
446
447 cubetexture_cleanup(This, D3DCB_DestroySurface);
448 /* finally delete the object */
449 HeapFree(GetProcessHeap(), 0, This);
450}
451
452static HRESULT WINAPI IWineD3DCubeTextureImpl_GetLevelDesc(IWineD3DCubeTexture *iface, UINT Level, WINED3DSURFACE_DESC* pDesc) {
453 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
454
455 if (Level < This->baseTexture.levels) {
456 TRACE("(%p) level (%d)\n", This, Level);
457 return IWineD3DSurface_GetDesc(This->surfaces[0][Level], pDesc);
458 }
459 WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
460 return WINED3DERR_INVALIDCALL;
461}
462
463static HRESULT WINAPI IWineD3DCubeTextureImpl_GetCubeMapSurface(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, UINT Level, IWineD3DSurface** ppCubeMapSurface) {
464 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
465 HRESULT hr = WINED3DERR_INVALIDCALL;
466
467 if (Level < This->baseTexture.levels && FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
468 *ppCubeMapSurface = This->surfaces[FaceType][Level];
469 IWineD3DSurface_AddRef(*ppCubeMapSurface);
470
471 hr = WINED3D_OK;
472 }
473 if (WINED3D_OK == hr) {
474 TRACE("(%p) -> faceType(%d) level(%d) returning surface@%p\n", This, FaceType, Level, This->surfaces[FaceType][Level]);
475 } else {
476 WARN("(%p) level(%d) overflow Levels(%d) Or FaceType(%d)\n", This, Level, This->baseTexture.levels, FaceType);
477 }
478
479 return hr;
480}
481
482static HRESULT WINAPI IWineD3DCubeTextureImpl_LockRect(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, UINT Level, WINED3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
483 HRESULT hr = WINED3DERR_INVALIDCALL;
484 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
485
486 if (Level < This->baseTexture.levels && FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
487 hr = IWineD3DSurface_LockRect(This->surfaces[FaceType][Level], pLockedRect, pRect, Flags);
488 }
489
490 if (WINED3D_OK == hr) {
491 TRACE("(%p) -> faceType(%d) level(%d) returning memory@%p success(%u)\n", This, FaceType, Level, pLockedRect->pBits, hr);
492 } else {
493 WARN("(%p) level(%d) overflow Levels(%d) Or FaceType(%d)\n", This, Level, This->baseTexture.levels, FaceType);
494 }
495
496 return hr;
497}
498
499static HRESULT WINAPI IWineD3DCubeTextureImpl_UnlockRect(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, UINT Level) {
500 HRESULT hr = WINED3DERR_INVALIDCALL;
501 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
502
503 if (Level < This->baseTexture.levels && FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
504 hr = IWineD3DSurface_UnlockRect(This->surfaces[FaceType][Level]);
505 }
506
507 if (WINED3D_OK == hr) {
508 TRACE("(%p) -> faceType(%d) level(%d) success(%u)\n", This, FaceType, Level, hr);
509 } else {
510 WARN("(%p) level(%d) overflow Levels(%d) Or FaceType(%d)\n", This, Level, This->baseTexture.levels, FaceType);
511 }
512 return hr;
513}
514
515static HRESULT WINAPI IWineD3DCubeTextureImpl_AddDirtyRect(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
516 HRESULT hr = WINED3DERR_INVALIDCALL;
517 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
518 This->baseTexture.dirty = TRUE;
519 This->baseTexture.srgbDirty = TRUE;
520 TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType);
521 if (FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
522 surface_add_dirty_rect(This->surfaces[FaceType][0], pDirtyRect);
523 hr = WINED3D_OK;
524 } else {
525 WARN("(%p) overflow FaceType(%d)\n", This, FaceType);
526 }
527 return hr;
528}
529
530
531const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl =
532{
533 /* IUnknown */
534 IWineD3DCubeTextureImpl_QueryInterface,
535 IWineD3DCubeTextureImpl_AddRef,
536 IWineD3DCubeTextureImpl_Release,
537 /* IWineD3DResource */
538 IWineD3DCubeTextureImpl_GetParent,
539 IWineD3DCubeTextureImpl_GetDevice,
540 IWineD3DCubeTextureImpl_SetPrivateData,
541 IWineD3DCubeTextureImpl_GetPrivateData,
542 IWineD3DCubeTextureImpl_FreePrivateData,
543 IWineD3DCubeTextureImpl_SetPriority,
544 IWineD3DCubeTextureImpl_GetPriority,
545 IWineD3DCubeTextureImpl_PreLoad,
546 IWineD3DCubeTextureImpl_UnLoad,
547 IWineD3DCubeTextureImpl_GetType,
548 /* IWineD3DBaseTexture */
549 IWineD3DCubeTextureImpl_SetLOD,
550 IWineD3DCubeTextureImpl_GetLOD,
551 IWineD3DCubeTextureImpl_GetLevelCount,
552 IWineD3DCubeTextureImpl_SetAutoGenFilterType,
553 IWineD3DCubeTextureImpl_GetAutoGenFilterType,
554 IWineD3DCubeTextureImpl_GenerateMipSubLevels,
555 IWineD3DCubeTextureImpl_SetDirty,
556 IWineD3DCubeTextureImpl_GetDirty,
557 IWineD3DCubeTextureImpl_BindTexture,
558 IWineD3DCubeTextureImpl_GetTextureDimensions,
559 IWineD3DCubeTextureImpl_IsCondNP2,
560 /* IWineD3DCubeTexture */
561 IWineD3DCubeTextureImpl_Destroy,
562 IWineD3DCubeTextureImpl_GetLevelDesc,
563 IWineD3DCubeTextureImpl_GetCubeMapSurface,
564 IWineD3DCubeTextureImpl_LockRect,
565 IWineD3DCubeTextureImpl_UnlockRect,
566 IWineD3DCubeTextureImpl_AddDirtyRect
567};
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette