blob: dec43cf3732cbf590c44c53a5b1f9773352ef5d9 [file] [log] [blame]
[email protected]29ed96a2012-02-04 18:12:161// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]5bba4dc22010-08-17 19:45:282// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]20790a222013-07-25 02:23:055#ifndef CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_
6#define CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_
[email protected]5bba4dc22010-08-17 19:45:287
avi1023d012015-12-25 02:39:148#include <stdint.h>
9
10#include "base/macros.h"
penghuanga206fb492014-09-09 21:27:3211#include "base/memory/shared_memory.h"
[email protected]fa48a62b2011-10-07 21:45:3212#include "base/memory/weak_ptr.h"
lukasza2573ce7d2016-02-16 19:17:2213#include "gpu/command_buffer/common/command_buffer_id.h"
[email protected]22069422014-05-02 04:29:0014#include "gpu/command_buffer/common/mailbox.h"
dyenddfdbbb2016-01-14 22:21:3815#include "gpu/command_buffer/common/sync_token.h"
[email protected]9a578392011-12-07 18:59:2716#include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
[email protected]bbf076f12011-08-24 15:19:3717#include "ppapi/shared_impl/resource.h"
[email protected]5bba4dc22010-08-17 19:45:2818
piman360175c2014-11-07 02:30:0119namespace gpu {
20struct Capabilities;
21}
22
[email protected]adab2332013-07-25 18:04:3223namespace content {
[email protected]22069422014-05-02 04:29:0024class CommandBufferProxyImpl;
25class GpuChannelHost;
[email protected]5bba4dc22010-08-17 19:45:2826
[email protected]49323b32013-08-09 16:05:0627class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared {
[email protected]5bba4dc22010-08-17 19:45:2828 public:
[email protected]bbf076f12011-08-24 15:19:3729 static PP_Resource Create(PP_Instance instance,
[email protected]e18e6392011-06-22 20:57:0030 PP_Resource share_context,
31 const int32_t* attrib_list);
lukasza2573ce7d2016-02-16 19:17:2232 static PP_Resource CreateRaw(PP_Instance instance,
33 PP_Resource share_context,
34 const int32_t* attrib_list,
35 gpu::Capabilities* capabilities,
36 base::SharedMemoryHandle* shared_state_handle,
37 gpu::CommandBufferId* command_buffer_id);
[email protected]66789462011-04-07 20:07:1838
[email protected]eeb4e4a2011-07-19 16:22:0639 // PPB_Graphics3D_API trusted implementation.
dcheng6d18e402014-10-21 12:32:5240 PP_Bool SetGetBuffer(int32_t transfer_buffer_id) override;
41 scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size,
avi1023d012015-12-25 02:39:1442 int32_t* id) override;
dcheng6d18e402014-10-21 12:32:5243 PP_Bool DestroyTransferBuffer(int32_t id) override;
44 PP_Bool Flush(int32_t put_offset) override;
45 gpu::CommandBuffer::State WaitForTokenInRange(int32_t start,
46 int32_t end) override;
47 gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start,
48 int32_t end) override;
dyen4de3d345f2016-01-12 18:30:4249 void EnsureWorkVisible() override;
[email protected]eeb4e4a2011-07-19 16:22:0650
51 // Binds/unbinds the graphics of this context with the associated instance.
52 // Returns true if binding/unbinding is successful.
53 bool BindToInstance(bool bind);
54
[email protected]3e4d8de2012-03-06 03:59:1755 // Returns true if the backing texture is always opaque.
56 bool IsOpaque();
57
[email protected]29ed96a2012-02-04 18:12:1658 // Notifications about the view's progress painting. See PluginInstance.
59 // These messages are used to send Flush callbacks to the plugin.
[email protected]eeb4e4a2011-07-19 16:22:0660 void ViewInitiatedPaint();
[email protected]eeb4e4a2011-07-19 16:22:0661
dyenddfdbbb2016-01-14 22:21:3862 void GetBackingMailbox(gpu::Mailbox* mailbox, gpu::SyncToken* sync_token) {
[email protected]22069422014-05-02 04:29:0063 *mailbox = mailbox_;
dyenddfdbbb2016-01-14 22:21:3864 *sync_token = sync_token_;
[email protected]22069422014-05-02 04:29:0065 }
66
sunnyps0e85ce582015-08-04 05:01:1367 CommandBufferProxyImpl* GetCommandBufferProxy();
[email protected]22069422014-05-02 04:29:0068
Daniel Cheng582416622014-08-26 02:03:5869 GpuChannelHost* channel() { return channel_.get(); }
[email protected]1b2ec22e2011-08-30 00:48:3370
[email protected]eeb4e4a2011-07-19 16:22:0671 protected:
dcheng6d18e402014-10-21 12:32:5272 ~PPB_Graphics3D_Impl() override;
[email protected]9a578392011-12-07 18:59:2773 // ppapi::PPB_Graphics3D_Shared overrides.
dcheng6d18e402014-10-21 12:32:5274 gpu::CommandBuffer* GetCommandBuffer() override;
75 gpu::GpuControl* GetGpuControl() override;
dyenddfdbbb2016-01-14 22:21:3876 int32_t DoSwapBuffers(const gpu::SyncToken& sync_token) override;
[email protected]e18e6392011-06-22 20:57:0077
78 private:
[email protected]bbf076f12011-08-24 15:19:3779 explicit PPB_Graphics3D_Impl(PP_Instance instance);
[email protected]66789462011-04-07 20:07:1880
[email protected]ad63b5c2014-04-11 21:12:3681 bool Init(PPB_Graphics3D_API* share_context, const int32_t* attrib_list);
penghuanga206fb492014-09-09 21:27:3282 bool InitRaw(PPB_Graphics3D_API* share_context,
83 const int32_t* attrib_list,
piman360175c2014-11-07 02:30:0184 gpu::Capabilities* capabilities,
dyen12e45962015-09-18 00:13:5185 base::SharedMemoryHandle* shared_state_handle,
lukasza2573ce7d2016-02-16 19:17:2286 gpu::CommandBufferId* command_buffer_id);
[email protected]eeb4e4a2011-07-19 16:22:0687
88 // Notifications received from the GPU process.
89 void OnSwapBuffers();
90 void OnContextLost();
[email protected]4d2a5ef2012-03-16 23:15:3991 void OnConsoleMessage(const std::string& msg, int id);
[email protected]eeb4e4a2011-07-19 16:22:0692 // Notifications sent to plugin.
93 void SendContextLost();
94
95 // True if context is bound to instance.
96 bool bound_to_instance_;
97 // True when waiting for compositor to commit our backing texture.
98 bool commit_pending_;
[email protected]22069422014-05-02 04:29:0099
100 gpu::Mailbox mailbox_;
dyenddfdbbb2016-01-14 22:21:38101 gpu::SyncToken sync_token_;
[email protected]22069422014-05-02 04:29:00102 bool has_alpha_;
103 scoped_refptr<GpuChannelHost> channel_;
sunnyps0e85ce582015-08-04 05:01:13104 scoped_ptr<CommandBufferProxyImpl> command_buffer_;
[email protected]22069422014-05-02 04:29:00105
[email protected]fa48a62b2011-10-07 21:45:32106 base::WeakPtrFactory<PPB_Graphics3D_Impl> weak_ptr_factory_;
[email protected]66789462011-04-07 20:07:18107
[email protected]66789462011-04-07 20:07:18108 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl);
[email protected]5bba4dc22010-08-17 19:45:28109};
110
[email protected]adab2332013-07-25 18:04:32111} // namespace content
[email protected]5bba4dc22010-08-17 19:45:28112
[email protected]20790a222013-07-25 02:23:05113#endif // CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_