blob: 9bcc1c72bbcd8c1b4d3ddab85ac7925acc2cf75f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_
#include "base/memory/scoped_callback_factory.h"
#include "ppapi/shared_impl/graphics_3d_impl.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/resource.h"
namespace webkit {
namespace ppapi {
class PPB_Graphics3D_Impl : public Resource,
public ::ppapi::Graphics3DImpl {
public:
virtual ~PPB_Graphics3D_Impl();
static PP_Resource Create(PluginInstance* instance,
PP_Resource share_context,
const int32_t* attrib_list);
static PP_Resource CreateRaw(PluginInstance* instance,
PP_Resource share_context,
const int32_t* attrib_list);
// Resource override.
virtual ::ppapi::thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() OVERRIDE;
// PPB_Graphics3D_API trusted implementation.
virtual PP_Bool InitCommandBuffer(int32_t size) OVERRIDE;
virtual PP_Bool GetRingBuffer(int* shm_handle,
uint32_t* shm_size) OVERRIDE;
virtual PP_Graphics3DTrustedState GetState() OVERRIDE;
virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE;
virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE;
virtual PP_Bool GetTransferBuffer(int32_t id,
int* shm_handle,
uint32_t* shm_size) OVERRIDE;
virtual PP_Bool Flush(int32_t put_offset) OVERRIDE;
virtual PP_Graphics3DTrustedState FlushSync(int32_t put_offset) OVERRIDE;
virtual PP_Graphics3DTrustedState FlushSyncFast(
int32_t put_offset,
int32_t last_known_get) OVERRIDE;
// Binds/unbinds the graphics of this context with the associated instance.
// Returns true if binding/unbinding is successful.
bool BindToInstance(bool bind);
// Returns the id of texture that can be used by the compositor.
unsigned int GetBackingTextureId();
// Notifications that the view has rendered the page and that it has been
// flushed to the screen. These messages are used to send Flush callbacks to
// the plugin.
void ViewInitiatedPaint();
void ViewFlushedPaint();
protected:
// ppapi::Graphics3DImpl overrides.
virtual gpu::CommandBuffer* GetCommandBuffer() OVERRIDE;
virtual int32 DoSwapBuffers() OVERRIDE;
private:
explicit PPB_Graphics3D_Impl(PluginInstance* instance);
bool Init(PP_Resource share_context,
const int32_t* attrib_list);
bool InitRaw(PP_Resource share_context,
const int32_t* attrib_list);
// Notifications received from the GPU process.
void OnSwapBuffers();
void OnContextLost();
// Notifications sent to plugin.
void SendContextLost();
// True if context is bound to instance.
bool bound_to_instance_;
// True when waiting for compositor to commit our backing texture.
bool commit_pending_;
// PluginDelegate's 3D Context. Responsible for providing the command buffer.
scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_;
base::ScopedCallbackFactory<PPB_Graphics3D_Impl> callback_factory_;
DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl);
};
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_
|