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_GRAPHICS_3D_IMPL_H_ | 5 #ifndef PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ |
6 #define PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ | 6 #define PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ppapi/c/pp_completion_callback.h" | 10 #include "ppapi/c/pp_completion_callback.h" |
11 #include "ppapi/shared_impl/ppapi_shared_export.h" | 11 #include "ppapi/shared_impl/ppapi_shared_export.h" |
| 12 #include "ppapi/shared_impl/resource.h" |
| 13 #include "ppapi/shared_impl/tracked_callback.h" |
12 #include "ppapi/thunk/ppb_graphics_3d_api.h" | 14 #include "ppapi/thunk/ppb_graphics_3d_api.h" |
13 | 15 |
14 namespace gpu { | 16 namespace gpu { |
15 class CommandBuffer; | 17 class CommandBuffer; |
16 namespace gles2 { | 18 namespace gles2 { |
17 class GLES2CmdHelper; | 19 class GLES2CmdHelper; |
18 class GLES2Implementation; | 20 class GLES2Implementation; |
19 } // namespace gles2 | 21 } // namespace gles2 |
20 } // namespace gpu. | 22 } // namespace gpu. |
21 | 23 |
22 namespace ppapi { | 24 namespace ppapi { |
23 | 25 |
24 class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared | 26 class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared |
25 : public thunk::PPB_Graphics3D_API { | 27 : public Resource, |
| 28 public thunk::PPB_Graphics3D_API { |
26 public: | 29 public: |
| 30 // Resource overrides. |
| 31 virtual thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() OVERRIDE; |
| 32 |
27 // PPB_Graphics3D_API implementation. | 33 // PPB_Graphics3D_API implementation. |
28 virtual int32_t GetAttribs(int32_t* attrib_list) OVERRIDE; | 34 virtual int32_t GetAttribs(int32_t* attrib_list) OVERRIDE; |
29 virtual int32_t SetAttribs(int32_t* attrib_list) OVERRIDE; | 35 virtual int32_t SetAttribs(int32_t* attrib_list) OVERRIDE; |
30 virtual int32_t GetError() OVERRIDE; | 36 virtual int32_t GetError() OVERRIDE; |
31 virtual int32_t ResizeBuffers(int32_t width, int32_t height) OVERRIDE; | 37 virtual int32_t ResizeBuffers(int32_t width, int32_t height) OVERRIDE; |
32 virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE; | 38 virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE; |
33 virtual void* MapTexSubImage2DCHROMIUM(GLenum target, | 39 virtual void* MapTexSubImage2DCHROMIUM(GLenum target, |
34 GLint level, | 40 GLint level, |
35 GLint xoffset, | 41 GLint xoffset, |
36 GLint yoffset, | 42 GLint yoffset, |
37 GLsizei width, | 43 GLsizei width, |
38 GLsizei height, | 44 GLsizei height, |
39 GLenum format, | 45 GLenum format, |
40 GLenum type, | 46 GLenum type, |
41 GLenum access) OVERRIDE; | 47 GLenum access) OVERRIDE; |
42 virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE; | 48 virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE; |
43 | 49 |
44 gpu::gles2::GLES2Implementation* gles2_impl() { | 50 gpu::gles2::GLES2Implementation* gles2_impl() { |
45 return gles2_impl_.get(); | 51 return gles2_impl_.get(); |
46 } | 52 } |
47 | 53 |
48 // Sends swap-buffers notification to the plugin. | 54 // Sends swap-buffers notification to the plugin. |
49 void SwapBuffersACK(int32_t pp_error); | 55 void SwapBuffersACK(int32_t pp_error); |
50 | 56 |
51 protected: | 57 protected: |
52 PPB_Graphics3D_Shared(); | 58 PPB_Graphics3D_Shared(PP_Instance instance); |
| 59 PPB_Graphics3D_Shared(const HostResource& host_resource); |
53 virtual ~PPB_Graphics3D_Shared(); | 60 virtual ~PPB_Graphics3D_Shared(); |
54 | 61 |
55 virtual gpu::CommandBuffer* GetCommandBuffer() = 0; | 62 virtual gpu::CommandBuffer* GetCommandBuffer() = 0; |
56 virtual int32 DoSwapBuffers() = 0; | 63 virtual int32 DoSwapBuffers() = 0; |
57 | 64 |
58 bool HasPendingSwap() { return swap_callback_.func != NULL; } | 65 bool HasPendingSwap() const; |
59 bool CreateGLES2Impl(int32 command_buffer_size, | 66 bool CreateGLES2Impl(int32 command_buffer_size, |
60 int32 transfer_buffer_size); | 67 int32 transfer_buffer_size); |
61 void DestroyGLES2Impl(); | 68 void DestroyGLES2Impl(); |
62 | 69 |
63 private: | 70 private: |
64 int32 transfer_buffer_id_; | 71 int32 transfer_buffer_id_; |
65 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; | 72 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; |
66 scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; | 73 scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; |
67 | 74 |
68 // Callback that needs to be executed when swap-buffers is completed. | 75 // Callback that needs to be executed when swap-buffers is completed. |
69 PP_CompletionCallback swap_callback_; | 76 scoped_refptr<TrackedCallback> swap_callback_; |
70 | 77 |
71 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Shared); | 78 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Shared); |
72 }; | 79 }; |
73 | 80 |
74 } // namespace ppapi | 81 } // namespace ppapi |
75 | 82 |
76 #endif // PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ | 83 #endif // PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ |
77 | 84 |
OLD | NEW |