OSDN Git Service

#36897 [DTXC] MIDIインポート機能の呼び出し口を、ファイルメニュー内にも配置。
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / direct3d9 / EffectHandle.cpp
1 #include "stdafx.h"\r
2 /*\r
3 * Copyright (c) 2007-2010 SlimDX Group\r
4\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy\r
6 * of this software and associated documentation files (the "Software"), to deal\r
7 * in the Software without restriction, including without limitation the rights\r
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
9 * copies of the Software, and to permit persons to whom the Software is\r
10 * furnished to do so, subject to the following conditions:\r
11\r
12 * The above copyright notice and this permission notice shall be included in\r
13 * all copies or substantial portions of the Software.\r
14\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
21 * THE SOFTWARE.\r
22 */\r
23 #include <d3d9.h>\r
24 #include <d3dx9.h>\r
25 \r
26 #include "EffectHandle.h"\r
27 \r
28 using namespace System;\r
29 using namespace System::Runtime::InteropServices;\r
30 \r
31 namespace SlimDX\r
32 {\r
33 namespace Direct3D9\r
34 {\r
35         EffectHandle::EffectHandle( D3DXHANDLE handle )\r
36         {\r
37                 m_Handle = handle;\r
38                 m_StringData = IntPtr::Zero;\r
39 \r
40                 GC::SuppressFinalize(this);\r
41         }\r
42 \r
43         EffectHandle::EffectHandle( String^ name )\r
44         {\r
45                 m_StringData = Marshal::StringToHGlobalAnsi( name );\r
46                 m_HasString = true;\r
47                 m_StringDataSize = name->Length;\r
48                 GC::AddMemoryPressure( m_StringDataSize );\r
49 \r
50                 m_Handle = reinterpret_cast<D3DXHANDLE>( m_StringData.ToPointer() );\r
51         }\r
52 \r
53         void EffectHandle::Destruct()\r
54         {\r
55                 if( m_HasString )\r
56                 {\r
57                         Marshal::FreeHGlobal( m_StringData );\r
58                         GC::RemoveMemoryPressure( m_StringDataSize );\r
59                 }\r
60         }\r
61 \r
62         EffectHandle::operator EffectHandle^( String^ name )\r
63         {\r
64                 return gcnew EffectHandle( name );\r
65         }\r
66 \r
67         bool EffectHandle::operator == ( EffectHandle^ left, EffectHandle^ right )\r
68         {\r
69                 //preferred to ReferenceEquals\r
70                 Object^ leftObj = left;\r
71                 Object^ rightObj = right;\r
72                 if(leftObj == nullptr)\r
73                         return rightObj == nullptr;\r
74 \r
75                 return EffectHandle::Equals( left, right );\r
76         }\r
77 \r
78         bool EffectHandle::operator != ( EffectHandle^ left, EffectHandle^ right )\r
79         {\r
80                 return !( left == right );\r
81         }\r
82 \r
83         int EffectHandle::GetHashCode()\r
84         {\r
85                 IntPtr ptr( const_cast<void*>( reinterpret_cast<const void*>( m_Handle ) ) );\r
86                 return ptr.GetHashCode();\r
87         }\r
88 \r
89         bool EffectHandle::Equals( Object^ value )\r
90         {\r
91                 if( ((Object^) value) == nullptr )\r
92                         return false;\r
93 \r
94                 if( value->GetType() != GetType() )\r
95                         return false;\r
96 \r
97                 return Equals( safe_cast<EffectHandle^>( value ) );\r
98         }\r
99 \r
100         bool EffectHandle::Equals( EffectHandle^ value )\r
101         {\r
102                 if( ((Object^) value) == nullptr )\r
103                         return false;\r
104 \r
105                 if( ReferenceEquals( this, value ) )\r
106                         return true;\r
107 \r
108                 return ( m_Handle == value->InternalHandle );\r
109         }\r
110 \r
111         bool EffectHandle::Equals( EffectHandle^ value1, EffectHandle^ value2 )\r
112         {\r
113                 return value1->Equals( value2 );\r
114         }\r
115 }\r
116 }