OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_LINUX_H_ | 5 #ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_LINUX_H_ |
6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_LINUX_H_ | 6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_LINUX_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #if defined(ENABLE_GPU) | 9 #if defined(ENABLE_GPU) |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "ipc/ipc_channel.h" | 12 #include "ipc/ipc_channel.h" |
13 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
| 15 #include "ui/gfx/surface/transport_dib.h" |
15 | 16 |
16 class GpuChannelManager; | 17 class GpuChannelManager; |
17 | 18 |
| 19 struct GpuHostMsg_AcceleratedSurfaceNew_Params; |
| 20 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; |
18 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; | 21 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; |
19 struct GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params; | |
20 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; | |
21 | 22 |
22 namespace gfx { | 23 namespace gfx { |
23 class GLSurface; | 24 class GLSurface; |
24 } | 25 } |
25 | 26 |
26 namespace gpu { | 27 namespace gpu { |
27 class GpuScheduler; | 28 class GpuScheduler; |
28 | 29 |
29 namespace gles2 { | 30 namespace gles2 { |
30 class GLES2Decoder; | 31 class GLES2Decoder; |
31 } | 32 } |
32 } | 33 } |
33 | 34 |
34 class ImageTransportSurface { | 35 class ImageTransportSurface { |
35 public: | 36 public: |
36 virtual void OnSetSurfaceACK(uint64 surface_id) = 0; | 37 virtual void OnNewSurfaceACK( |
| 38 uint64 surface_id, TransportDIB::Handle surface_handle) = 0; |
37 virtual void OnBuffersSwappedACK() = 0; | 39 virtual void OnBuffersSwappedACK() = 0; |
38 virtual void OnResize(gfx::Size size) = 0; | 40 virtual void OnResize(gfx::Size size) = 0; |
39 | 41 |
40 // Creates the appropriate surface depending on the GL implementation. | 42 // Creates the appropriate surface depending on the GL implementation. |
41 static scoped_refptr<gfx::GLSurface> | 43 static scoped_refptr<gfx::GLSurface> |
42 CreateSurface(GpuChannelManager* manager, | 44 CreateSurface(GpuChannelManager* manager, |
43 int32 render_view_id, | 45 int32 render_view_id, |
44 int32 renderer_id, | 46 int32 renderer_id, |
45 int32 command_buffer_id); | 47 int32 command_buffer_id); |
46 }; | 48 }; |
47 | 49 |
48 class ImageTransportHelper : public IPC::Channel::Listener { | 50 class ImageTransportHelper : public IPC::Channel::Listener { |
49 public: | 51 public: |
50 // Takes weak pointers to objects that outlive the helper. | 52 // Takes weak pointers to objects that outlive the helper. |
51 ImageTransportHelper(ImageTransportSurface* surface, | 53 ImageTransportHelper(ImageTransportSurface* surface, |
52 GpuChannelManager* manager, | 54 GpuChannelManager* manager, |
53 int32 render_view_id, | 55 int32 render_view_id, |
54 int32 renderer_id, | 56 int32 renderer_id, |
55 int32 command_buffer_id); | 57 int32 command_buffer_id); |
56 ~ImageTransportHelper(); | 58 ~ImageTransportHelper(); |
57 | 59 |
58 bool Initialize(); | 60 bool Initialize(); |
59 void Destroy(); | 61 void Destroy(); |
60 | 62 |
61 // IPC::Channel::Listener implementation: | 63 // IPC::Channel::Listener implementation: |
62 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 64 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
63 | 65 |
64 // Helper send functions. Caller fills in the surface specific params | 66 // Helper send functions. Caller fills in the surface specific params |
65 // like size and surface id. The helper fills in the rest. | 67 // like size and surface id. The helper fills in the rest. |
| 68 void SendAcceleratedSurfaceNew( |
| 69 GpuHostMsg_AcceleratedSurfaceNew_Params params); |
| 70 void SendAcceleratedSurfaceBuffersSwapped( |
| 71 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params); |
66 void SendAcceleratedSurfaceRelease( | 72 void SendAcceleratedSurfaceRelease( |
67 GpuHostMsg_AcceleratedSurfaceRelease_Params params); | 73 GpuHostMsg_AcceleratedSurfaceRelease_Params params); |
68 void SendAcceleratedSurfaceSetIOSurface( | |
69 GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params params); | |
70 void SendAcceleratedSurfaceBuffersSwapped( | |
71 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params); | |
72 | 74 |
73 // Whether or not we should execute more commands. | 75 // Whether or not we should execute more commands. |
74 void SetScheduled(bool is_scheduled); | 76 void SetScheduled(bool is_scheduled); |
75 | 77 |
| 78 // Make the surface's context current |
| 79 bool MakeCurrent(); |
| 80 |
76 private: | 81 private: |
77 gpu::GpuScheduler* Scheduler(); | 82 gpu::GpuScheduler* Scheduler(); |
78 gpu::gles2::GLES2Decoder* Decoder(); | 83 gpu::gles2::GLES2Decoder* Decoder(); |
79 | 84 |
80 // IPC::Message handlers. | 85 // IPC::Message handlers. |
81 void OnSetSurfaceACK(uint64 surface_id); | 86 void OnNewSurfaceACK(uint64 surface_id, TransportDIB::Handle surface_handle); |
82 void OnBuffersSwappedACK(); | 87 void OnBuffersSwappedACK(); |
83 | 88 |
84 // Backbuffer resize callback. | 89 // Backbuffer resize callback. |
85 void Resize(gfx::Size size); | 90 void Resize(gfx::Size size); |
86 | 91 |
87 // Weak pointers that to objects that outlive this helper. | 92 // Weak pointers that to objects that outlive this helper. |
88 ImageTransportSurface* surface_; | 93 ImageTransportSurface* surface_; |
89 GpuChannelManager* manager_; | 94 GpuChannelManager* manager_; |
90 | 95 |
91 int32 render_view_id_; | 96 int32 render_view_id_; |
92 int32 renderer_id_; | 97 int32 renderer_id_; |
93 int32 command_buffer_id_; | 98 int32 command_buffer_id_; |
94 int32 route_id_; | 99 int32 route_id_; |
95 | 100 |
96 DISALLOW_COPY_AND_ASSIGN(ImageTransportHelper); | 101 DISALLOW_COPY_AND_ASSIGN(ImageTransportHelper); |
97 }; | 102 }; |
98 | 103 |
99 #endif // defined(ENABLE_GPU) | 104 #endif // defined(ENABLE_GPU) |
100 | 105 |
101 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_LINUX_H_ | 106 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_LINUX_H_ |
OLD | NEW |