Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CopyOrRestoreData()

unsafe int Microsoft.Xna.Framework.Graphics.TextureCube.CopyOrRestoreData ( [MarshalAs(UnmanagedType.U1)] bool isStoring)
inlinepackage

Definition at line 477 of file TextureCube.cs.

478 {
479 IDirect3DCubeTexture9* ptr = pComPtr;
480 if (ptr == null)
481 {
482 return 0;
483 }
484 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DSURFACE_DESC d3DSURFACE_DESC);
485 int num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DSURFACE_DESC*, int>)(int)(*(uint*)(*(int*)ptr + 68)))((nint)ptr, 0u, &d3DSURFACE_DESC);
486 if (num >= 0)
487 {
488 if (isStoring)
489 {
490 pFaceData = new IntPtr[_levelCount * 6];
491 }
492 uint num2 = System.Runtime.CompilerServices.Unsafe.As<_D3DSURFACE_DESC, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DSURFACE_DESC, 24));
493 uint num3 = System.Runtime.CompilerServices.Unsafe.As<_D3DSURFACE_DESC, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DSURFACE_DESC, 28));
494 bool flag = Texture.CheckCompressedTexture(*(_D3DFORMAT*)(&d3DSURFACE_DESC));
495 byte b = ((!flag) ? Texture.GetExpectedByteSizeFromFormat(*(_D3DFORMAT*)(&d3DSURFACE_DESC)) : ((byte)((*(int*)(&d3DSURFACE_DESC) == 827611204) ? 8u : 16u)));
496 int num4 = 0;
497 int num5 = 0;
498 if (0 < _levelCount)
499 {
500 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DLOCKED_RECT d3DLOCKED_RECT);
501 do
502 {
503 int num6 = 0;
504 do
505 {
506 byte* ptr2 = null;
507 int num7;
508 if (!isStoring)
509 {
510 ref IntPtr reference = ref pFaceData[num4];
511 num4++;
512 ptr2 = (byte*)reference.ToPointer();
513 num7 = 0;
514 }
515 else
516 {
517 num7 = 16;
518 }
519 ptr = pComPtr;
520 num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DCUBEMAP_FACES, uint, _D3DLOCKED_RECT*, tagRECT*, uint, int>)(int)(*(uint*)(*(int*)ptr + 76)))((nint)ptr, (_D3DCUBEMAP_FACES)num6, (uint)num5, &d3DLOCKED_RECT, null, (uint)num7);
521 if (num < 0)
522 {
523 break;
524 }
525 uint num8 = num2;
526 uint num9 = num3;
527 if (flag)
528 {
529 num8 = num2 + 3 >> 2;
530 num9 = num3 + 3 >> 2;
531 }
532 uint num10 = b * num8;
533 byte* ptr3 = (byte*)(int)System.Runtime.CompilerServices.Unsafe.As<_D3DLOCKED_RECT, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DLOCKED_RECT, 4));
534 if (isStoring)
535 {
536 ptr2 = (byte*)_003CModule_003E.new_005B_005D(num10 * num9);
537 }
538 byte* ptr4 = ptr2;
539 if (0 < num9)
540 {
541 uint num11 = num9;
542 do
543 {
544 if (isStoring)
545 {
546 _003CModule_003E.memcpy_s(ptr4, num10 * num9, ptr3, num10);
547 }
548 else
549 {
550 _003CModule_003E.memcpy_s(ptr3, *(uint*)(&d3DLOCKED_RECT), ptr4, num10);
551 }
552 ptr3 = *(int*)(&d3DLOCKED_RECT) + ptr3;
553 ptr4 = (int)num10 + ptr4;
554 num11--;
555 }
556 while (num11 != 0);
557 }
558 ptr = pComPtr;
559 num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DCUBEMAP_FACES, uint, int>)(int)(*(uint*)(*(int*)ptr + 80)))((nint)ptr, (_D3DCUBEMAP_FACES)num6, (uint)num5);
560 if (num < 0)
561 {
562 break;
563 }
564 if (isStoring)
565 {
566 IntPtr intPtr = (IntPtr)ptr2;
567 ref IntPtr reference2 = ref pFaceData[num4];
568 num4++;
569 reference2 = intPtr;
570 }
571 num6++;
572 }
573 while (num6 < 6);
574 num2 = ((num2 <= 1) ? 1u : (num2 >> 1));
575 num3 = ((num3 <= 1) ? 1u : (num3 >> 1));
576 num5++;
577 }
578 while (num5 < _levelCount);
579 }
580 }
581 return num;
582 }
unsafe IDirect3DCubeTexture9 * pComPtr

References Microsoft.Xna.Framework.Graphics.Texture._levelCount, Microsoft.Xna.Framework.Graphics.Texture.CheckCompressedTexture(), Microsoft.Xna.Framework.Graphics.Texture.GetExpectedByteSizeFromFormat(), Microsoft.Xna.Framework.Graphics.TextureCube.pComPtr, and Microsoft.Xna.Framework.Graphics.TextureCube.pFaceData.

Referenced by Microsoft.Xna.Framework.Graphics.TextureCube.RecreateAndPopulateObject(), and Microsoft.Xna.Framework.Graphics.TextureCube.SaveDataForRecreation().