blob: 28f71ab1d0e3d8293f65780a13a986d5b4d01ef1 [file] [log] [blame]
[email protected]eeb4e4a2011-07-19 16:22:061// Copyright (c) 2011 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]0bd753682010-12-16 18:15:525#ifndef WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_
6#define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_
[email protected]5bba4dc22010-08-17 19:45:287
[email protected]eeb4e4a2011-07-19 16:22:068#include "base/memory/scoped_callback_factory.h"
9#include "ppapi/shared_impl/graphics_3d_impl.h"
[email protected]bbf076f12011-08-24 15:19:3710#include "ppapi/shared_impl/resource.h"
[email protected]eeb4e4a2011-07-19 16:22:0611#include "webkit/plugins/ppapi/plugin_delegate.h"
[email protected]5bba4dc22010-08-17 19:45:2812
[email protected]0bd753682010-12-16 18:15:5213namespace webkit {
14namespace ppapi {
[email protected]5bba4dc22010-08-17 19:45:2815
[email protected]bbf076f12011-08-24 15:19:3716class PPB_Graphics3D_Impl : public ::ppapi::Resource,
[email protected]eeb4e4a2011-07-19 16:22:0617 public ::ppapi::Graphics3DImpl {
[email protected]5bba4dc22010-08-17 19:45:2818 public:
[email protected]66789462011-04-07 20:07:1819 virtual ~PPB_Graphics3D_Impl();
20
[email protected]bbf076f12011-08-24 15:19:3721 static PP_Resource Create(PP_Instance instance,
[email protected]e18e6392011-06-22 20:57:0022 PP_Resource share_context,
23 const int32_t* attrib_list);
[email protected]bbf076f12011-08-24 15:19:3724 static PP_Resource CreateRaw(PP_Instance instance,
[email protected]eeb4e4a2011-07-19 16:22:0625 PP_Resource share_context,
26 const int32_t* attrib_list);
[email protected]66789462011-04-07 20:07:1827
[email protected]7f8b26b2011-08-18 15:41:0128 // Resource override.
[email protected]e18e6392011-06-22 20:57:0029 virtual ::ppapi::thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() OVERRIDE;
30
[email protected]eeb4e4a2011-07-19 16:22:0631 // PPB_Graphics3D_API trusted implementation.
32 virtual PP_Bool InitCommandBuffer(int32_t size) OVERRIDE;
33 virtual PP_Bool GetRingBuffer(int* shm_handle,
34 uint32_t* shm_size) OVERRIDE;
35 virtual PP_Graphics3DTrustedState GetState() OVERRIDE;
36 virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE;
37 virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE;
38 virtual PP_Bool GetTransferBuffer(int32_t id,
39 int* shm_handle,
40 uint32_t* shm_size) OVERRIDE;
41 virtual PP_Bool Flush(int32_t put_offset) OVERRIDE;
42 virtual PP_Graphics3DTrustedState FlushSync(int32_t put_offset) OVERRIDE;
43 virtual PP_Graphics3DTrustedState FlushSyncFast(
44 int32_t put_offset,
45 int32_t last_known_get) OVERRIDE;
46
47 // Binds/unbinds the graphics of this context with the associated instance.
48 // Returns true if binding/unbinding is successful.
49 bool BindToInstance(bool bind);
50
51 // Returns the id of texture that can be used by the compositor.
52 unsigned int GetBackingTextureId();
53
54 // Notifications that the view has rendered the page and that it has been
55 // flushed to the screen. These messages are used to send Flush callbacks to
56 // the plugin.
57 void ViewInitiatedPaint();
58 void ViewFlushedPaint();
59
[email protected]1b2ec22e2011-08-30 00:48:3360 PluginDelegate::PlatformContext3D* platform_context() {
61 return platform_context_.get();
62 }
63
[email protected]eeb4e4a2011-07-19 16:22:0664 protected:
65 // ppapi::Graphics3DImpl overrides.
66 virtual gpu::CommandBuffer* GetCommandBuffer() OVERRIDE;
67 virtual int32 DoSwapBuffers() OVERRIDE;
[email protected]e18e6392011-06-22 20:57:0068
69 private:
[email protected]bbf076f12011-08-24 15:19:3770 explicit PPB_Graphics3D_Impl(PP_Instance instance);
[email protected]66789462011-04-07 20:07:1871
[email protected]9d8fe822011-08-16 21:02:5272 bool Init(PP_Resource share_context,
[email protected]66789462011-04-07 20:07:1873 const int32_t* attrib_list);
[email protected]