| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 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 CHROME_GPU_GPU_COMMAND_BUFFER_STUB_H_ | |
| 6 #define CHROME_GPU_GPU_COMMAND_BUFFER_STUB_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #if defined(ENABLE_GPU) | |
| 10 | |
| 11 #include <vector> | |
| 12 #include <string> | |
| 13 | |
| 14 #include "base/process.h" | |
| 15 #include "base/weak_ptr.h" | |
| 16 #include "gpu/command_buffer/service/command_buffer_service.h" | |
| 17 #include "gpu/command_buffer/service/gpu_processor.h" | |
| 18 #include "ipc/ipc_channel.h" | |
| 19 #include "ipc/ipc_message.h" | |
| 20 #include "ui/gfx/native_widget_types.h" | |
| 21 #include "ui/gfx/size.h" | |
| 22 | |
| 23 class GpuChannel; | |
| 24 | |
| 25 class GpuCommandBufferStub | |
| 26 : public IPC::Channel::Listener, | |
| 27 public IPC::Message::Sender, | |
| 28 public base::SupportsWeakPtr<GpuCommandBufferStub> { | |
| 29 public: | |
| 30 GpuCommandBufferStub(GpuChannel* channel, | |
| 31 gfx::PluginWindowHandle handle, | |
| 32 GpuCommandBufferStub* parent, | |
| 33 const gfx::Size& size, | |
| 34 const std::string& allowed_extensions, | |
| 35 const std::vector<int32>& attribs, | |
| 36 uint32 parent_texture_id, | |
| 37 int32 route_id, | |
| 38 int32 renderer_id, | |
| 39 int32 render_view_id); | |
| 40 | |
| 41 virtual ~GpuCommandBufferStub(); | |
| 42 | |
| 43 // IPC::Channel::Listener implementation: | |
| 44 virtual bool OnMessageReceived(const IPC::Message& message); | |
| 45 | |
| 46 // IPC::Message::Sender implementation: | |
| 47 virtual bool Send(IPC::Message* msg); | |
| 48 | |
| 49 // Get the GLContext associated with this object. | |
| 50 gpu::GPUProcessor* processor() const { return processor_.get(); } | |
| 51 | |
| 52 // Identifies the various GpuCommandBufferStubs in the GPU process belonging | |
| 53 // to the same renderer process. | |
| 54 int32 route_id() const { return route_id_; } | |
| 55 | |
| 56 // Identifies the various render views in the renderer process. | |
| 57 int32 renderer_route_id() const { return renderer_id_; } | |
| 58 | |
| 59 #if defined(OS_WIN) | |
| 60 // Called only by the compositor window's window proc | |
| 61 void OnCompositorWindowPainted(); | |
| 62 #endif // defined(OS_WIN) | |
| 63 | |
| 64 #if defined(OS_MACOSX) | |
| 65 // Called only by the GpuChannel. | |
| 66 void AcceleratedSurfaceBuffersSwapped(uint64 swap_buffers_count); | |
| 67 #endif // defined(OS_MACOSX) | |
| 68 | |
| 69 private: | |
| 70 // Message handlers: | |
| 71 void OnInitialize(base::SharedMemoryHandle ring_buffer, | |
| 72 int32 size, | |
| 73 bool* result); | |
| 74 void OnGetState(gpu::CommandBuffer::State* state); | |
| 75 void OnAsyncGetState(); | |
| 76 void OnFlush(int32 put_offset, gpu::CommandBuffer::State* state); | |
| 77 void OnAsyncFlush(int32 put_offset); | |
| 78 void OnCreateTransferBuffer(int32 size, int32* id); | |
| 79 void OnRegisterTransferBuffer(base::SharedMemoryHandle transfer_buffer, | |
| 80 size_t size, | |
| 81 int32* id); | |
| 82 void OnDestroyTransferBuffer(int32 id); | |
| 83 void OnGetTransferBuffer(int32 id, | |
| 84 base::SharedMemoryHandle* transfer_buffer, | |
| 85 uint32* size); | |
| 86 void OnResizeOffscreenFrameBuffer(const gfx::Size& size); | |
| 87 | |
| 88 void OnSwapBuffers(); | |
| 89 | |
| 90 #if defined(OS_MACOSX) | |
| 91 void OnSetWindowSize(const gfx::Size& size); | |
| 92 void SwapBuffersCallback(); | |
| 93 #endif // defined(OS_MACOSX) | |
| 94 | |
| 95 #if defined(OS_WIN) | |
| 96 bool CreateCompositorWindow(); | |
| 97 #endif // defined(OS_WIN) | |
| 98 | |
| 99 void ResizeCallback(gfx::Size size); | |
| 100 | |
| 101 // The lifetime of objects of this class is managed by a GpuChannel. The | |
| 102 // GpuChannels destroy all the GpuCommandBufferStubs that they own when they | |
| 103 // are destroyed. So a raw pointer is safe. | |
| 104 GpuChannel* channel_; | |
| 105 | |
| 106 gfx::PluginWindowHandle handle_; | |
| 107 base::WeakPtr<GpuCommandBufferStub> parent_; | |
| 108 gfx::Size initial_size_; | |
| 109 std::string allowed_extensions_; | |
| 110 std::vector<int32> requested_attribs_; | |
| 111 uint32 parent_texture_id_; | |
| 112 int32 route_id_; | |
| 113 | |
| 114 #if defined(OS_WIN) | |
| 115 HWND compositor_window_; | |
| 116 #endif // defined(OS_WIN) | |
| 117 | |
| 118 // The following two fields are used on Mac OS X to identify the window | |
| 119 // for the rendering results on the browser side. | |
| 120 int32 renderer_id_; | |
| 121 int32 render_view_id_; | |
| 122 | |
| 123 scoped_ptr<gpu::CommandBufferService> command_buffer_; | |
| 124 scoped_ptr<gpu::GPUProcessor> processor_; | |
| 125 | |
| 126 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); | |
| 127 }; | |
| 128 | |
| 129 #endif // defined(ENABLE_GPU) | |
| 130 | |
| 131 #endif // CHROME_GPU_GPU_COMMAND_BUFFER_STUB_H_ | |
| OLD | NEW |