Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
RenderTarget2D.cs
Go to the documentation of this file.
1using System;
5
7
9{
11
12 internal bool _contentLost;
13
14 private EventHandler<EventArgs> _003Cbacking_store_003EContentLost;
15
16 public bool IsContentLost
17 {
18 [return: MarshalAs(UnmanagedType.U1)]
19 get
20 {
21 if (!_contentLost)
22 {
24 }
25 return _contentLost;
26 }
27 }
28
30
32
34
35 [SpecialName]
36 public virtual event EventHandler<EventArgs> ContentLost
37 {
38 [MethodImpl(MethodImplOptions.Synchronized)]
39 add
40 {
42 }
43 [MethodImpl(MethodImplOptions.Synchronized)]
44 remove
45 {
47 }
48 }
49
50 public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, [MarshalAs(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
51 {
52 try
53 {
54 CreateRenderTarget(graphicsDevice, width, height, mipMap, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage);
55 return;
56 }
57 catch
58 {
59 //try-fault
60 base.Dispose(true);
61 throw;
62 }
63 }
64
65 public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, [MarshalAs(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat)
66 {
67 try
68 {
69 CreateRenderTarget(graphicsDevice, width, height, mipMap, preferredFormat, preferredDepthFormat, 0, RenderTargetUsage.DiscardContents);
70 return;
71 }
72 catch
73 {
74 //try-fault
75 base.Dispose(true);
76 throw;
77 }
78 }
79
80 public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height)
81 {
82 try
83 {
84 CreateRenderTarget(graphicsDevice, width, height, mipMap: false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.DiscardContents);
85 return;
86 }
87 catch
88 {
89 //try-fault
90 base.Dispose(true);
91 throw;
92 }
93 }
94
95 private void _007ERenderTarget2D()
96 {
97 }
98
99 internal void CreateRenderTarget(GraphicsDevice graphicsDevice, int width, int height, [MarshalAs(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
100 {
101 if (graphicsDevice == null)
102 {
104 }
105 graphicsDevice.Adapter.QueryFormat(isBackBuffer: false, graphicsDevice._deviceType, graphicsDevice._graphicsProfile, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, out var selectedFormat, out var selectedDepthFormat, out var selectedMultiSampleCount);
106 Texture2D.ValidateCreationParameters(graphicsDevice._profileCapabilities, width, height, selectedFormat, mipMap);
107 (helper = new RenderTargetHelper(this, width, height, selectedFormat, selectedDepthFormat, selectedMultiSampleCount, usage, graphicsDevice._profileCapabilities)).CreateSurfaces(graphicsDevice);
108 CreateTexture(graphicsDevice, width, height, mipMap, 1u, (_D3DPOOL)0, selectedFormat);
110 }
111
112 internal override int SaveDataForRecreation()
113 {
114 return 0;
115 }
116
118 {
119 //ILSpy generated this explicit interface implementation from .override directive in SaveDataForRecreation
120 return this.SaveDataForRecreation();
121 }
122
123 internal unsafe override int RecreateAndPopulateObject()
124 {
125 if (pComPtr != null)
126 {
127 return -2147467259;
128 }
129 int num = ((_levelCount > 1) ? 1 : 0);
130 CreateTexture(_parent, _width, _height, (byte)num != 0, 1u, (_D3DPOOL)0, _format);
133 return 0;
134 }
135
137 {
138 //ILSpy generated this explicit interface implementation from .override directive in RecreateAndPopulateObject
139 return this.RecreateAndPopulateObject();
140 }
141
142 internal override void ReleaseNativeObject([MarshalAs(UnmanagedType.U1)] bool disposeManagedResource)
143 {
144 base.ReleaseNativeObject(disposeManagedResource);
146 }
147
148 void IGraphicsResource.ReleaseNativeObject([MarshalAs(UnmanagedType.U1)] bool disposeManagedResource)
149 {
150 //ILSpy generated this explicit interface implementation from .override directive in ReleaseNativeObject
151 this.ReleaseNativeObject(disposeManagedResource);
152 }
153
154 internal virtual void SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)
155 {
156 _contentLost = isContentLost;
157 if (isContentLost)
158 {
160 }
161 }
162
163 void IDynamicGraphicsResource.SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)
164 {
165 //ILSpy generated this explicit interface implementation from .override directive in SetContentLost
166 this.SetContentLost(isContentLost);
167 }
168
169 [SpecialName]
170 protected virtual void raise_ContentLost(object value0, EventArgs value1)
171 {
172 _003Cbacking_store_003EContentLost?.Invoke(value0, value1);
173 }
174
175 [HandleProcessCorruptedStateExceptions]
176 protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool P_0)
177 {
178 if (P_0)
179 {
180 try
181 {
182 return;
183 }
184 finally
185 {
186 base.Dispose(true);
187 }
188 }
189 base.Dispose(false);
190 }
191}
bool QueryFormat([MarshalAs(UnmanagedType.U1)] bool isBackBuffer, _D3DDEVTYPE deviceType, GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat, out int selectedMultiSampleCount)
virtual void SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)
RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, [MarshalAs(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
override void Dispose([MarshalAs(UnmanagedType.U1)] bool P_0)
virtual EventHandler< EventArgs > ContentLost
RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height)
virtual void raise_ContentLost(object value0, EventArgs value1)
void CreateRenderTarget(GraphicsDevice graphicsDevice, int width, int height, [MarshalAs(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
EventHandler< EventArgs > _003Cbacking_store_003EContentLost
override void ReleaseNativeObject([MarshalAs(UnmanagedType.U1)] bool disposeManagedResource)
RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, [MarshalAs(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat)
unsafe void CreateSurfaces(GraphicsDevice graphicsDevice)
static void ValidateCreationParameters(ProfileCapabilities profile, int width, int height, SurfaceFormat format, [MarshalAs(UnmanagedType.U1)] bool mipMap)
Definition Texture2D.cs:633
unsafe IDirect3DTexture9 * pComPtr
Definition Texture2D.cs:22
unsafe void CreateTexture(GraphicsDevice graphicsDevice, int width, int height, [MarshalAs(UnmanagedType.U1)] bool mipMap, uint usage, _D3DPOOL pool, SurfaceFormat format)
Definition Texture2D.cs:609
static ? Delegate Remove(Delegate? source, Delegate? value)
Definition Delegate.cs:463
static ? Delegate Combine(Delegate? a, Delegate? b)
Definition Delegate.cs:379
static readonly EventArgs Empty
Definition EventArgs.cs:9
void SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)
void ReleaseNativeObject([MarshalAs(UnmanagedType.U1)] bool disposeManagedResource)