VirtualBox

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

Last change on this file since 20817 was 20612, checked in by vboxsync, 16 years ago

crOpenGL: update wine to 1.1.23

  • Property svn:eol-style set to native
File size: 22.2 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, device->lastActiveRenderTarget, 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 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 if (texture->resource.format_desc->Flags & WINED3DFMT_FLAG_FILTERING)
205 {
206 texture->baseTexture.minMipLookup = minMipLookup;
207 texture->baseTexture.magLookup = magLookup;
208 }
209 else
210 {
211 texture->baseTexture.minMipLookup = minMipLookup_noFilter;
212 texture->baseTexture.magLookup = magLookup_noFilter;
213 }
214
215 /* Find the nearest pow2 match. */
216 pow2_edge_length = 1;
217 while (pow2_edge_length < edge_length) pow2_edge_length <<= 1;
218
219 if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO) || (edge_length == pow2_edge_length))
220 {
221 /* Precalculated scaling for 'faked' non power of two texture coords. */
222 texture->baseTexture.pow2Matrix[0] = 1.0;
223 texture->baseTexture.pow2Matrix[5] = 1.0;
224 texture->baseTexture.pow2Matrix[10] = 1.0;
225 texture->baseTexture.pow2Matrix[15] = 1.0;
226 }
227 else
228 {
229 /* Precalculated scaling for 'faked' non power of two texture coords. */
230 texture->baseTexture.pow2Matrix[0] = ((float)edge_length) / ((float)pow2_edge_length);
231 texture->baseTexture.pow2Matrix[5] = ((float)edge_length) / ((float)pow2_edge_length);
232 texture->baseTexture.pow2Matrix[10] = ((float)edge_length) / ((float)pow2_edge_length);
233 texture->baseTexture.pow2Matrix[15] = 1.0;
234 texture->baseTexture.pow2Matrix_identity = FALSE;
235 }
236
237 /* Generate all the surfaces. */
238 tmp_w = edge_length;
239 for (i = 0; i < texture->baseTexture.levels; ++i)
240 {
241 /* Create the 6 faces. */
242 for (j = 0; j < 6; ++j)
243 {
244 static const GLenum cube_targets[6] =
245 {
246 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
247 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
248 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
249 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
250 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
251 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
252 };
253
254 hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_w,
255 format, usage, pool, i /* Level */, j, &texture->surfaces[j][i]);
256 if (FAILED(hr))
257 {
258 FIXME("(%p) Failed to create surface, hr %#x.\n", texture, hr);
259 texture->surfaces[j][i] = NULL;
260 cubetexture_cleanup(texture, D3DCB_DefaultDestroySurface);
261 return hr;
262 }
263
264 IWineD3DSurface_SetContainer(texture->surfaces[j][i], (IWineD3DBase *)texture);
265 TRACE("Created surface level %u @ %p.\n", i, texture->surfaces[j][i]);
266 surface_set_texture_target(texture->surfaces[j][i], cube_targets[j]);
267 }
268 tmp_w = max(1, tmp_w >> 1);
269 }
270 texture->baseTexture.internal_preload = cubetexture_internal_preload;
271
272 return WINED3D_OK;
273}
274
275#undef GLINFO_LOCATION
276
277/* *******************************************
278 IWineD3DCubeTexture IUnknown parts follow
279 ******************************************* */
280
281#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
282
283static HRESULT WINAPI IWineD3DCubeTextureImpl_QueryInterface(IWineD3DCubeTexture *iface, REFIID riid, LPVOID *ppobj)
284{
285 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
286 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
287 if (IsEqualGUID(riid, &IID_IUnknown)
288 || IsEqualGUID(riid, &IID_IWineD3DBase)
289 || IsEqualGUID(riid, &IID_IWineD3DResource)
290 || IsEqualGUID(riid, &IID_IWineD3DBaseTexture)
291 || IsEqualGUID(riid, &IID_IWineD3DCubeTexture)) {
292 IUnknown_AddRef(iface);
293 *ppobj = This;
294 return S_OK;
295 }
296 *ppobj = NULL;
297 return E_NOINTERFACE;
298}
299
300static ULONG WINAPI IWineD3DCubeTextureImpl_AddRef(IWineD3DCubeTexture *iface) {
301 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
302 TRACE("(%p) : AddRef increasing from %d\n", This, This->resource.ref);
303 return InterlockedIncrement(&This->resource.ref);
304}
305
306static ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface) {
307 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
308 ULONG ref;
309 TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
310 ref = InterlockedDecrement(&This->resource.ref);
311 if (ref == 0) {
312 IWineD3DCubeTexture_Destroy(iface, D3DCB_DefaultDestroySurface);
313 }
314 return ref;
315}
316
317/* ****************************************************
318 IWineD3DCubeTexture IWineD3DResource parts follow
319 **************************************************** */
320static HRESULT WINAPI IWineD3DCubeTextureImpl_GetDevice(IWineD3DCubeTexture *iface, IWineD3DDevice** ppDevice) {
321 return resource_get_device((IWineD3DResource *)iface, ppDevice);
322}
323
324static HRESULT WINAPI IWineD3DCubeTextureImpl_SetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
325 return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
326}
327
328static HRESULT WINAPI IWineD3DCubeTextureImpl_GetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
329 return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
330}
331
332static HRESULT WINAPI IWineD3DCubeTextureImpl_FreePrivateData(IWineD3DCubeTexture *iface, REFGUID refguid) {
333 return resource_free_private_data((IWineD3DResource *)iface, refguid);
334}
335
336static DWORD WINAPI IWineD3DCubeTextureImpl_SetPriority(IWineD3DCubeTexture *iface, DWORD PriorityNew) {
337 return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
338}
339
340static DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *iface) {
341 return resource_get_priority((IWineD3DResource *)iface);
342}
343
344static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
345 cubetexture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
346}
347
348static void WINAPI IWineD3DCubeTextureImpl_UnLoad(IWineD3DCubeTexture *iface) {
349 unsigned int i, j;
350 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
351 TRACE("(%p)\n", This);
352
353 /* Unload all the surfaces and reset the texture name. If UnLoad was called on the
354 * surface before, this one will be a NOP and vice versa. Unloading an unloaded
355 * surface is fine
356 */
357 for (i = 0; i < This->baseTexture.levels; i++) {
358 for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z ; j++) {
359 IWineD3DSurface_UnLoad(This->surfaces[j][i]);
360 surface_set_texture_name(This->surfaces[j][i], 0, TRUE);
361 surface_set_texture_name(This->surfaces[j][i], 0, FALSE);
362 }
363 }
364
365 basetexture_unload((IWineD3DBaseTexture *)iface);
366}
367
368static WINED3DRESOURCETYPE WINAPI IWineD3DCubeTextureImpl_GetType(IWineD3DCubeTexture *iface) {
369 return resource_get_type((IWineD3DResource *)iface);
370}
371
372static HRESULT WINAPI IWineD3DCubeTextureImpl_GetParent(IWineD3DCubeTexture *iface, IUnknown **pParent) {
373 return resource_get_parent((IWineD3DResource *)iface, pParent);
374}
375
376/* ******************************************************
377 IWineD3DCubeTexture IWineD3DBaseTexture parts follow
378 ****************************************************** */
379static DWORD WINAPI IWineD3DCubeTextureImpl_SetLOD(IWineD3DCubeTexture *iface, DWORD LODNew) {
380 return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
381}
382
383static DWORD WINAPI IWineD3DCubeTextureImpl_GetLOD(IWineD3DCubeTexture *iface) {
384 return basetexture_get_lod((IWineD3DBaseTexture *)iface);
385}
386
387static DWORD WINAPI IWineD3DCubeTextureImpl_GetLevelCount(IWineD3DCubeTexture *iface) {
388 return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
389}
390
391static HRESULT WINAPI IWineD3DCubeTextureImpl_SetAutoGenFilterType(IWineD3DCubeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
392 return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
393}
394
395static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DCubeTextureImpl_GetAutoGenFilterType(IWineD3DCubeTexture *iface) {
396 return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
397}
398
399static void WINAPI IWineD3DCubeTextureImpl_GenerateMipSubLevels(IWineD3DCubeTexture *iface) {
400 basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
401}
402
403/* Internal function, No d3d mapping */
404static BOOL WINAPI IWineD3DCubeTextureImpl_SetDirty(IWineD3DCubeTexture *iface, BOOL dirty) {
405 return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
406}
407
408/* Internal function, No d3d mapping */
409static BOOL WINAPI IWineD3DCubeTextureImpl_GetDirty(IWineD3DCubeTexture *iface) {
410 return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
411}
412
413static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *iface, BOOL srgb) {
414 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
415 BOOL set_gl_texture_desc;
416 HRESULT hr;
417
418 TRACE("(%p) : relay to BaseTexture\n", This);
419
420 hr = basetexture_bind((IWineD3DBaseTexture *)iface, srgb, &set_gl_texture_desc);
421 if (set_gl_texture_desc && SUCCEEDED(hr)) {
422 UINT i, j;
423 for (i = 0; i < This->baseTexture.levels; ++i) {
424 for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j) {
425 if(This->baseTexture.is_srgb) {
426 surface_set_texture_name(This->surfaces[j][i], This->baseTexture.srgbTextureName, TRUE);
427 } else {
428 surface_set_texture_name(This->surfaces[j][i], This->baseTexture.textureName, FALSE);
429 }
430 }
431 }
432 }
433
434 return hr;
435}
436
437static UINT WINAPI IWineD3DCubeTextureImpl_GetTextureDimensions(IWineD3DCubeTexture *iface){
438 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
439 TRACE("(%p)\n", This);
440
441 return GL_TEXTURE_CUBE_MAP_ARB;
442}
443
444static BOOL WINAPI IWineD3DCubeTextureImpl_IsCondNP2(IWineD3DCubeTexture *iface) {
445 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
446 TRACE("(%p)\n", This);
447
448 return FALSE;
449}
450
451/* *******************************************
452 IWineD3DCubeTexture IWineD3DCubeTexture parts follow
453 ******************************************* */
454static void WINAPI IWineD3DCubeTextureImpl_Destroy(IWineD3DCubeTexture *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroySurface) {
455 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
456
457 cubetexture_cleanup(This, D3DCB_DestroySurface);
458 /* finally delete the object */
459 HeapFree(GetProcessHeap(), 0, This);
460}
461
462static HRESULT WINAPI IWineD3DCubeTextureImpl_GetLevelDesc(IWineD3DCubeTexture *iface, UINT Level, WINED3DSURFACE_DESC* pDesc) {
463 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
464
465 if (Level < This->baseTexture.levels) {
466 TRACE("(%p) level (%d)\n", This, Level);
467 return IWineD3DSurface_GetDesc(This->surfaces[0][Level], pDesc);
468 }
469 WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
470 return WINED3DERR_INVALIDCALL;
471}
472
473static HRESULT WINAPI IWineD3DCubeTextureImpl_GetCubeMapSurface(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, UINT Level, IWineD3DSurface** ppCubeMapSurface) {
474 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
475 HRESULT hr = WINED3DERR_INVALIDCALL;
476
477 if (Level < This->baseTexture.levels && FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
478 *ppCubeMapSurface = This->surfaces[FaceType][Level];
479 IWineD3DSurface_AddRef(*ppCubeMapSurface);
480
481 hr = WINED3D_OK;
482 }
483 if (WINED3D_OK == hr) {
484 TRACE("(%p) -> faceType(%d) level(%d) returning surface@%p\n", This, FaceType, Level, This->surfaces[FaceType][Level]);
485 } else {
486 WARN("(%p) level(%d) overflow Levels(%d) Or FaceType(%d)\n", This, Level, This->baseTexture.levels, FaceType);
487 }
488
489 return hr;
490}
491
492static HRESULT WINAPI IWineD3DCubeTextureImpl_LockRect(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, UINT Level, WINED3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
493 HRESULT hr = WINED3DERR_INVALIDCALL;
494 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
495
496 if (Level < This->baseTexture.levels && FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
497 hr = IWineD3DSurface_LockRect(This->surfaces[FaceType][Level], pLockedRect, pRect, Flags);
498 }
499
500 if (WINED3D_OK == hr) {
501 TRACE("(%p) -> faceType(%d) level(%d) returning memory@%p success(%u)\n", This, FaceType, Level, pLockedRect->pBits, hr);
502 } else {
503 WARN("(%p) level(%d) overflow Levels(%d) Or FaceType(%d)\n", This, Level, This->baseTexture.levels, FaceType);
504 }
505
506 return hr;
507}
508
509static HRESULT WINAPI IWineD3DCubeTextureImpl_UnlockRect(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, UINT Level) {
510 HRESULT hr = WINED3DERR_INVALIDCALL;
511 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
512
513 if (Level < This->baseTexture.levels && FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
514 hr = IWineD3DSurface_UnlockRect(This->surfaces[FaceType][Level]);
515 }
516
517 if (WINED3D_OK == hr) {
518 TRACE("(%p) -> faceType(%d) level(%d) success(%u)\n", This, FaceType, Level, hr);
519 } else {
520 WARN("(%p) level(%d) overflow Levels(%d) Or FaceType(%d)\n", This, Level, This->baseTexture.levels, FaceType);
521 }
522 return hr;
523}
524
525static HRESULT WINAPI IWineD3DCubeTextureImpl_AddDirtyRect(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
526 HRESULT hr = WINED3DERR_INVALIDCALL;
527 IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
528 This->baseTexture.dirty = TRUE;
529 This->baseTexture.srgbDirty = TRUE;
530 TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType);
531 if (FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
532 surface_add_dirty_rect(This->surfaces[FaceType][0], pDirtyRect);
533 hr = WINED3D_OK;
534 } else {
535 WARN("(%p) overflow FaceType(%d)\n", This, FaceType);
536 }
537 return hr;
538}
539
540
541const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl =
542{
543 /* IUnknown */
544 IWineD3DCubeTextureImpl_QueryInterface,
545 IWineD3DCubeTextureImpl_AddRef,
546 IWineD3DCubeTextureImpl_Release,
547 /* IWineD3DResource */
548 IWineD3DCubeTextureImpl_GetParent,
549 IWineD3DCubeTextureImpl_GetDevice,
550 IWineD3DCubeTextureImpl_SetPrivateData,
551 IWineD3DCubeTextureImpl_GetPrivateData,
552 IWineD3DCubeTextureImpl_FreePrivateData,
553 IWineD3DCubeTextureImpl_SetPriority,
554 IWineD3DCubeTextureImpl_GetPriority,
555 IWineD3DCubeTextureImpl_PreLoad,
556 IWineD3DCubeTextureImpl_UnLoad,
557 IWineD3DCubeTextureImpl_GetType,
558 /* IWineD3DBaseTexture */
559 IWineD3DCubeTextureImpl_SetLOD,
560 IWineD3DCubeTextureImpl_GetLOD,
561 IWineD3DCubeTextureImpl_GetLevelCount,
562 IWineD3DCubeTextureImpl_SetAutoGenFilterType,
563 IWineD3DCubeTextureImpl_GetAutoGenFilterType,
564 IWineD3DCubeTextureImpl_GenerateMipSubLevels,
565 IWineD3DCubeTextureImpl_SetDirty,
566 IWineD3DCubeTextureImpl_GetDirty,
567 IWineD3DCubeTextureImpl_BindTexture,
568 IWineD3DCubeTextureImpl_GetTextureDimensions,
569 IWineD3DCubeTextureImpl_IsCondNP2,
570 /* IWineD3DCubeTexture */
571 IWineD3DCubeTextureImpl_Destroy,
572 IWineD3DCubeTextureImpl_GetLevelDesc,
573 IWineD3DCubeTextureImpl_GetCubeMapSurface,
574 IWineD3DCubeTextureImpl_LockRect,
575 IWineD3DCubeTextureImpl_UnlockRect,
576 IWineD3DCubeTextureImpl_AddDirtyRect
577};
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