Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(949)

Side by Side Diff: content/common/gpu/image_transport_surface_win.cc

Issue 8060045: Use shared D3D9 texture to transport the compositor's backing buffer to the browser... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/image_transport_surface_mac.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #if defined(ENABLE_GPU)
6
7 #include "content/common/gpu/image_transport_surface.h"
8
9 #include "base/bind.h"
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/win/windows_version.h"
14 #include "content/common/gpu/gpu_messages.h"
15 #include "ui/gfx/gl/gl_bindings.h"
16 #include "ui/gfx/gl/gl_context.h"
17 #include "ui/gfx/gl/gl_implementation.h"
18 #include "ui/gfx/gl/gl_surface_egl.h"
19 #include "ui/gfx/native_widget_types.h"
20
21 namespace {
22
23 // We are backed by an Pbuffer offscreen surface through which ANGLE provides
24 // a handle to the corresponding render target texture through an extension.
25 class PbufferImageTransportSurface
26 : public gfx::GLSurfaceAdapter,
27 public ImageTransportSurface,
28 public base::SupportsWeakPtr<PbufferImageTransportSurface> {
29 public:
30 PbufferImageTransportSurface(GpuChannelManager* manager,
31 int32 render_view_id,
32 int32 renderer_id,
33 int32 command_buffer_id);
34
35 // GLSurface implementation
36 virtual bool Initialize();
37 virtual void Destroy();
38 virtual bool IsOffscreen();
39 virtual bool SwapBuffers();
40
41 protected:
42 // ImageTransportSurface implementation
43 virtual void OnNewSurfaceACK(uint64 surface_id,
44 TransportDIB::Handle shm_handle) OVERRIDE;
45 virtual void OnBuffersSwappedACK() OVERRIDE;
46 virtual void OnResizeViewACK() OVERRIDE;
47 virtual void OnResize(gfx::Size size) OVERRIDE;
48
49 private:
50 virtual ~PbufferImageTransportSurface();
51 void SendBuffersSwapped();
52
53 scoped_ptr<ImageTransportHelper> helper_;
54
55 DISALLOW_COPY_AND_ASSIGN(PbufferImageTransportSurface);
56 };
57
58 PbufferImageTransportSurface::PbufferImageTransportSurface(
59 GpuChannelManager* manager,
60 int32 render_view_id,
61 int32 renderer_id,
62 int32 command_buffer_id)
63 : GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false,
64 gfx::Size(1, 1))) {
65 helper_.reset(new ImageTransportHelper(this,
66 manager,
67 render_view_id,
68 renderer_id,
69 command_buffer_id,
70 gfx::kNullPluginWindow));
71 }
72
73 PbufferImageTransportSurface::~PbufferImageTransportSurface() {
74 Destroy();
75 }
76
77 bool PbufferImageTransportSurface::Initialize() {
78 // Only support this path if the GL implementation is ANGLE.
79 // IO surfaces will not work with, for example, OSMesa software renderer
80 // GL contexts.
81 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2)
82 return false;
83
84 if (!helper_->Initialize())
85 return false;
86
87 return GLSurfaceAdapter::Initialize();
88 }
89
90 void PbufferImageTransportSurface::Destroy() {
91 helper_->Destroy();
92 GLSurfaceAdapter::Destroy();
93 }
94
95 bool PbufferImageTransportSurface::IsOffscreen() {
96 return false;
97 }
98
99 bool PbufferImageTransportSurface::SwapBuffers() {
100 HANDLE surface_handle = GetShareHandle();
101 if (!surface_handle)
102 return false;
103
104 helper_->DeferToFence(base::Bind(
105 &PbufferImageTransportSurface::SendBuffersSwapped,
106 AsWeakPtr()));
107
108 return true;
109 }
110
111 void PbufferImageTransportSurface::SendBuffersSwapped() {
112 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
113 params.surface_id = reinterpret_cast<int64>(GetShareHandle());
114 params.size = GetSize();
115 helper_->SendAcceleratedSurfaceBuffersSwapped(params);
116
117 helper_->SetScheduled(false);
118 }
119
120 void PbufferImageTransportSurface::OnBuffersSwappedACK() {
121 helper_->SetScheduled(true);
122 }
123
124 void PbufferImageTransportSurface::OnNewSurfaceACK(
125 uint64 surface_id,
126 TransportDIB::Handle shm_handle) {
127 NOTIMPLEMENTED();
128 }
129
130 void PbufferImageTransportSurface::OnResizeViewACK() {
131 NOTIMPLEMENTED();
132 }
133
134 void PbufferImageTransportSurface::OnResize(gfx::Size size) {
135 Resize(size);
136 }
137
138 } // namespace anonymous
139
140 // static
141 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface(
142 GpuChannelManager* manager,
143 int32 render_view_id,
144 int32 renderer_id,
145 int32 command_buffer_id,
146 gfx::PluginWindowHandle handle) {
147 scoped_refptr<gfx::GLSurface> surface;
148
149 base::win::OSInfo* os_info = base::win::OSInfo::GetInstance();
150
151 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
152 os_info->version() >= base::win::VERSION_VISTA) {
153 surface = new PbufferImageTransportSurface(manager,
154 render_view_id,
155 renderer_id,
156 command_buffer_id);
157 } else {
158 surface = gfx::GLSurface::CreateViewGLSurface(false, handle);
159 if (!surface.get())
160 return NULL;
161
162 surface = new PassThroughImageTransportSurface(manager,
163 render_view_id,
164 renderer_id,
165 command_buffer_id,
166 surface.get());
167 }
168
169 if (surface->Initialize())
170 return surface;
171 else
172 return NULL;
173 }
174
175 #endif // ENABLE_GPU
OLDNEW
« no previous file with comments | « content/common/gpu/image_transport_surface_mac.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698