-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathd2dTexture.pas
98 lines (85 loc) · 1.79 KB
/
d2dTexture.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
unit d2dTexture;
interface
uses
Direct3D8,
d2dInterfaces,
d2dClasses;
type
Td2dTexture = class(Td2dProtoObjectPrim, Id2dTexture)
private
f_DXTexture: IDirect3DTexture8;
f_SrcPicHeight: Integer;
f_SrcPicWidth: Integer;
protected
function pm_GetDirectXTexture: IDirect3DTexture8;
function pm_GetSrcPicHeight: Integer;
function pm_GetSrcPicWidth: Integer;
procedure pm_SetSrcPicHeight(const Value: Integer);
procedure pm_SetSrcPicWidth(const Value: Integer);
public
function IsOrphan: Boolean;
class function Make(aDXTex: IDirect3DTexture8): Id2dTexture;
end;
implementation
uses
SysUtils,
d2dCore;
function Td2dTexture.IsOrphan: Boolean;
var
l_Count: Integer;
begin
Result := True;
if f_DXTexture <> nil then
begin
l_Count := f_DXTexture._AddRef;
try
Result := l_Count = 2;
finally
f_DXTexture._Release;
end;
end;
end;
class function Td2dTexture.Make(aDXTex: IDirect3DTexture8): Id2dTexture;
var
l_Tex: Td2dTexture;
begin
Result := nil;
if aDXTex <> nil then
begin
l_Tex := Td2dTexture.Create;
try
l_Tex.f_DXTexture := aDXTex;
Result := l_Tex;
finally
FreeAndNil(l_Tex);
end;
end;
end;
function Td2dTexture.pm_GetDirectXTexture: IDirect3DTexture8;
begin
if Self <> nil then
Result := f_DXTexture;
end;
function Td2dTexture.pm_GetSrcPicHeight: Integer;
begin
if f_SrcPicHeight > 0 then
Result := f_SrcPicHeight
else
Result := gD2DE.Texture_GetHeight(f_DXTexture);
end;
function Td2dTexture.pm_GetSrcPicWidth: Integer;
begin
if f_SrcPicWidth > 0 then
Result := f_SrcPicWidth
else
Result := gD2DE.Texture_GetWidth(f_DXTexture);
end;
procedure Td2dTexture.pm_SetSrcPicHeight(const Value: Integer);
begin
f_SrcPicHeight := Value;
end;
procedure Td2dTexture.pm_SetSrcPicWidth(const Value: Integer);
begin
f_SrcPicWidth := Value;
end;
end.