blob: 84bad21d19e049f1c556174f727ff3f21b932585 [file] [log] [blame]
[email protected]06b73aa2012-01-27 23:06:191// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]eeb4e4a2011-07-19 16:22:062// 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
avie029c4132015-12-23 06:45:228#include <stdint.h>
9
dchengced92242016-04-07 00:00:1210#include <memory>
11
avie029c4132015-12-23 06:45:2212#include "base/macros.h"
[email protected]eeb4e4a2011-07-19 16:22:0613#include "ppapi/c/pp_completion_callback.h"
[email protected]f0a04c42011-08-26 22:43:2014#include "ppapi/shared_impl/ppapi_shared_export.h"
[email protected]614888b2012-01-05 06:18:1215#include "ppapi/shared_impl/resource.h"
16#include "ppapi/shared_impl/tracked_callback.h"
[email protected]eeb4e4a2011-07-19 16:22:0617#include "ppapi/thunk/ppb_graphics_3d_api.h"
pimanb36392c22016-07-13 02:11:3618#include "ui/gfx/geometry/size.h"
[email protected]eeb4e4a2011-07-19 16:22:0619
20namespace gpu {
21class CommandBuffer;
[email protected]744e0792013-09-27 01:18:3522class GpuControl;
[email protected]06b73aa2012-01-27 23:06:1923class TransferBuffer;
[email protected]eeb4e4a2011-07-19 16:22:0624namespace gles2 {
25class GLES2CmdHelper;
26class GLES2Implementation;
jbroman35f3e1eb2016-01-04 22:37:3827class GLES2Interface;
[email protected]eeb4e4a2011-07-19 16:22:0628} // namespace gles2
29} // namespace gpu.
30
31namespace ppapi {
32
[email protected]9a578392011-12-07 18:59:2733class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared
[email protected]614888b2012-01-05 06:18:1234 : public Resource,
35 public thunk::PPB_Graphics3D_API {
[email protected]eeb4e4a2011-07-19 16:22:0636 public:
[email protected]614888b2012-01-05 06:18:1237 // Resource overrides.
nicke4784432015-04-23 14:01:4838 thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() override;
[email protected]614888b2012-01-05 06:18:1239
[email protected]eeb4e4a2011-07-19 16:22:0640 // PPB_Graphics3D_API implementation.
nicke4784432015-04-23 14:01:4841 int32_t GetAttribs(int32_t attrib_list[]) override;
42 int32_t SetAttribs(const int32_t attrib_list[]) override;
43 int32_t GetError() override;
44 int32_t ResizeBuffers(int32_t width, int32_t height) override;
raymesbc71ad0b2016-03-14 07:30:3545 int32_t SwapBuffers(scoped_refptr<TrackedCallback> callback) override;
46 int32_t SwapBuffersWithSyncToken(scoped_refptr<TrackedCallback> callback,
erikchenb13637b2016-07-08 09:38:5647 const gpu::SyncToken& sync_token,
pimanb36392c22016-07-13 02:11:3648 const gfx::Size& size) override;
nicke4784432015-04-23 14:01:4849 int32_t GetAttribMaxValue(int32_t attribute, int32_t* value) override;
[email protected]252c4bd2013-03-30 03:00:0350
nicke4784432015-04-23 14:01:4851 void* MapTexSubImage2DCHROMIUM(GLenum target,
52 GLint level,
53 GLint xoffset,
54 GLint yoffset,
55 GLsizei width,
56 GLsizei height,
57 GLenum format,
58 GLenum type,
59 GLenum access) override;
60 void UnmapTexSubImage2DCHROMIUM(const void* mem) override;
[email protected]eeb4e4a2011-07-19 16:22:0661
[email protected]665b5c542014-02-22 08:06:2662 gpu::gles2::GLES2Implementation* gles2_impl() { return gles2_impl_.get(); }
jbroman35f3e1eb2016-01-04 22:37:3863 gpu::gles2::GLES2Interface* gles2_interface();
[email protected]eeb4e4a2011-07-19 16:22:0664
65 // Sends swap-buffers notification to the plugin.
66 void SwapBuffersACK(int32_t pp_error);
67
68 protected:
[email protected]614888b2012-01-05 06:18:1269 PPB_Graphics3D_Shared(PP_Instance instance);
pimanb36392c22016-07-13 02:11:3670 PPB_Graphics3D_Shared(const HostResource& host_resource,
71 const gfx::Size& size);
nicke4784432015-04-23 14:01:4872 ~PPB_Graphics3D_Shared() override;
[email protected]eeb4e4a2011-07-19 16:22:0673
74 virtual gpu::CommandBuffer* GetCommandBuffer() = 0;
[email protected]744e0792013-09-27 01:18:3575 virtual gpu::GpuControl* GetGpuControl() = 0;
erikchenb13637b2016-07-08 09:38:5676 virtual int32_t DoSwapBuffers(const gpu::SyncToken& sync_token,
pimanb36392c22016-07-13 02:11:3677 const gfx::Size& size) = 0;
[email protected]eeb4e4a2011-07-19 16:22:0678
[email protected]614888b2012-01-05 06:18:1279 bool HasPendingSwap() const;
avie029c4132015-12-23 06:45:2280 bool CreateGLES2Impl(int32_t command_buffer_size,
81 int32_t transfer_buffer_size,
[email protected]9ed07f82012-05-29 21:54:5582 gpu::gles2::GLES2Implementation* share_gles2);
[email protected]eeb4e4a2011-07-19 16:22:0683 void DestroyGLES2Impl();
84
85 private:
dchengced92242016-04-07 00:00:1286 std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_;
87 std::unique_ptr<gpu::TransferBuffer> transfer_buffer_;
88 std::unique_ptr<gpu::gles2::GLES2Implementation> gles2_impl_;
[email protected]eeb4e4a2011-07-19 16:22:0689
pimanb36392c22016-07-13 02:11:3690 // A local cache of the size of the viewport. This is only valid in plugin
91 // resources.
92 gfx::Size size_;
erikchenb13637b2016-07-08 09:38:5693
[email protected]eeb4e4a2011-07-19 16:22:0694 // Callback that needs to be executed when swap-buffers is completed.
[email protected]614888b2012-01-05 06:18:1295 scoped_refptr<TrackedCallback> swap_callback_;
[email protected]eeb4e4a2011-07-19 16:22:0696
[email protected]9a578392011-12-07 18:59:2797 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Shared);
[email protected]eeb4e4a2011-07-19 16:22:0698};
99
100} // namespace ppapi
101
102#endif // PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_