[email protected] | 06b73aa | 2012-01-27 23:06:19 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ |
| 6 | #define PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ |
| 7 | |
| 8 | #include "base/basictypes.h" |
| 9 | #include "base/memory/scoped_ptr.h" |
| 10 | #include "ppapi/c/pp_completion_callback.h" |
[email protected] | f0a04c4 | 2011-08-26 22:43:20 | [diff] [blame] | 11 | #include "ppapi/shared_impl/ppapi_shared_export.h" |
[email protected] | 614888b | 2012-01-05 06:18:12 | [diff] [blame] | 12 | #include "ppapi/shared_impl/resource.h" |
| 13 | #include "ppapi/shared_impl/tracked_callback.h" |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 14 | #include "ppapi/thunk/ppb_graphics_3d_api.h" |
| 15 | |
| 16 | namespace gpu { |
| 17 | class CommandBuffer; |
[email protected] | 06b73aa | 2012-01-27 23:06:19 | [diff] [blame] | 18 | class TransferBuffer; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 19 | namespace gles2 { |
| 20 | class GLES2CmdHelper; |
| 21 | class GLES2Implementation; |
| 22 | } // namespace gles2 |
| 23 | } // namespace gpu. |
| 24 | |
| 25 | namespace ppapi { |
| 26 | |
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 27 | class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared |
[email protected] | 614888b | 2012-01-05 06:18:12 | [diff] [blame] | 28 | : public Resource, |
| 29 | public thunk::PPB_Graphics3D_API { |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 30 | public: |
[email protected] | 614888b | 2012-01-05 06:18:12 | [diff] [blame] | 31 | // Resource overrides. |
| 32 | virtual thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() OVERRIDE; |
| 33 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 34 | // PPB_Graphics3D_API implementation. |
[email protected] | af9388e | 2012-02-10 09:39:55 | [diff] [blame] | 35 | virtual int32_t GetAttribs(int32_t attrib_list[]) OVERRIDE; |
| 36 | virtual int32_t SetAttribs(const int32_t attrib_list[]) OVERRIDE; |
[email protected] | 187a88c | 2011-09-03 03:19:35 | [diff] [blame] | 37 | virtual int32_t GetError() OVERRIDE; |
[email protected] | 23bd2af | 2011-08-01 17:48:07 | [diff] [blame] | 38 | virtual int32_t ResizeBuffers(int32_t width, int32_t height) OVERRIDE; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 39 | virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE; |
[email protected] | 9465357 | 2012-02-26 19:05:20 | [diff] [blame] | 40 | virtual void* MapTexSubImage2DCHROMIUM(GLenum target, |
| 41 | GLint level, |
| 42 | GLint xoffset, |
| 43 | GLint yoffset, |
| 44 | GLsizei width, |
| 45 | GLsizei height, |
| 46 | GLenum format, |
| 47 | GLenum type, |
| 48 | GLenum access) OVERRIDE; |
| 49 | virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 50 | |
| 51 | gpu::gles2::GLES2Implementation* gles2_impl() { |
| 52 | return gles2_impl_.get(); |
| 53 | } |
| 54 | |
| 55 | // Sends swap-buffers notification to the plugin. |
| 56 | void SwapBuffersACK(int32_t pp_error); |
| 57 | |
| 58 | protected: |
[email protected] | 614888b | 2012-01-05 06:18:12 | [diff] [blame] | 59 | PPB_Graphics3D_Shared(PP_Instance instance); |
| 60 | PPB_Graphics3D_Shared(const HostResource& host_resource); |
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 61 | virtual ~PPB_Graphics3D_Shared(); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 62 | |
| 63 | virtual gpu::CommandBuffer* GetCommandBuffer() = 0; |
| 64 | virtual int32 DoSwapBuffers() = 0; |
| 65 | |
[email protected] | 614888b | 2012-01-05 06:18:12 | [diff] [blame] | 66 | bool HasPendingSwap() const; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 67 | bool CreateGLES2Impl(int32 command_buffer_size, |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame^] | 68 | int32 transfer_buffer_size, |
| 69 | gpu::gles2::GLES2Implementation* share_gles2); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 70 | void DestroyGLES2Impl(); |
| 71 | |
| 72 | private: |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 73 | scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; |
[email protected] | 06b73aa | 2012-01-27 23:06:19 | [diff] [blame] | 74 | scoped_ptr<gpu::TransferBuffer> transfer_buffer_; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 75 | scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; |
| 76 | |
| 77 | // Callback that needs to be executed when swap-buffers is completed. |
[email protected] | 614888b | 2012-01-05 06:18:12 | [diff] [blame] | 78 | scoped_refptr<TrackedCallback> swap_callback_; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 79 | |
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 80 | DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Shared); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | } // namespace ppapi |
| 84 | |
| 85 | #endif // PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ |
| 86 | |