OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_SHARED_IMPL_RESOURCE_OBJECT_BASE_H_ | 5 #ifndef PPAPI_SHARED_IMPL_RESOURCE_OBJECT_BASE_H_ |
6 #define PPAPI_SHARED_IMPL_RESOURCE_OBJECT_BASE_H_ | 6 #define PPAPI_SHARED_IMPL_RESOURCE_OBJECT_BASE_H_ |
7 | 7 |
8 namespace ppapi { | 8 namespace ppapi { |
9 | 9 |
10 namespace thunk { | 10 namespace thunk { |
| 11 class PPB_Font_API; |
11 class PPB_Graphics2D_API; | 12 class PPB_Graphics2D_API; |
12 class PPB_ImageData_API; | 13 class PPB_ImageData_API; |
13 } | 14 } |
14 | 15 |
15 namespace shared_impl { | 16 namespace shared_impl { |
16 | 17 |
17 class ResourceObjectBase { | 18 class ResourceObjectBase { |
18 public: | 19 public: |
19 | 20 |
| 21 virtual thunk::PPB_Font_API* AsFont_API() { return NULL; } |
20 virtual thunk::PPB_Graphics2D_API* AsGraphics2D_API() { return NULL; } | 22 virtual thunk::PPB_Graphics2D_API* AsGraphics2D_API() { return NULL; } |
21 virtual thunk::PPB_ImageData_API* AsImageData_API() { return NULL; } | 23 virtual thunk::PPB_ImageData_API* AsImageData_API() { return NULL; } |
22 | 24 |
23 template <typename T> T* GetAs() { return NULL; } | 25 template <typename T> T* GetAs() { return NULL; } |
24 }; | 26 }; |
25 | 27 |
26 template<> | 28 template<> |
| 29 inline thunk::PPB_Font_API* ResourceObjectBase::GetAs() { |
| 30 return AsFont_API(); |
| 31 } |
| 32 template<> |
27 inline thunk::PPB_Graphics2D_API* ResourceObjectBase::GetAs() { | 33 inline thunk::PPB_Graphics2D_API* ResourceObjectBase::GetAs() { |
28 return AsGraphics2D_API(); | 34 return AsGraphics2D_API(); |
29 } | 35 } |
30 template<> | 36 template<> |
31 inline thunk::PPB_ImageData_API* ResourceObjectBase::GetAs() { | 37 inline thunk::PPB_ImageData_API* ResourceObjectBase::GetAs() { |
32 return AsImageData_API(); | 38 return AsImageData_API(); |
33 } | 39 } |
34 | 40 |
35 } // namespace shared_impl | 41 } // namespace shared_impl |
36 } // namespace ppapi | 42 } // namespace ppapi |
37 | 43 |
38 #endif // PPAPI_SHARED_IMPL_RESOURCE_OBJECT_BASE_H_ | 44 #endif // PPAPI_SHARED_IMPL_RESOURCE_OBJECT_BASE_H_ |
OLD | NEW |