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

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

Issue 9194005: gpu: reference target surfaces through a globally unique surface id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "content/common/gpu/image_transport_surface.h" 7 #include "content/common/gpu/image_transport_surface.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 13 matching lines...) Expand all
24 namespace { 24 namespace {
25 25
26 // We are backed by an Pbuffer offscreen surface through which ANGLE provides 26 // We are backed by an Pbuffer offscreen surface through which ANGLE provides
27 // a handle to the corresponding render target texture through an extension. 27 // a handle to the corresponding render target texture through an extension.
28 class PbufferImageTransportSurface 28 class PbufferImageTransportSurface
29 : public gfx::GLSurfaceAdapter, 29 : public gfx::GLSurfaceAdapter,
30 public ImageTransportSurface, 30 public ImageTransportSurface,
31 public base::SupportsWeakPtr<PbufferImageTransportSurface> { 31 public base::SupportsWeakPtr<PbufferImageTransportSurface> {
32 public: 32 public:
33 PbufferImageTransportSurface(GpuChannelManager* manager, 33 PbufferImageTransportSurface(GpuChannelManager* manager,
34 int32 render_view_id, 34 GpuCommandBufferStub* stub);
35 int32 client_id,
36 int32 command_buffer_id);
37 35
38 // gfx::GLSurface implementation 36 // gfx::GLSurface implementation
39 virtual bool Initialize() OVERRIDE; 37 virtual bool Initialize() OVERRIDE;
40 virtual void Destroy() OVERRIDE; 38 virtual void Destroy() OVERRIDE;
41 virtual bool IsOffscreen() OVERRIDE; 39 virtual bool IsOffscreen() OVERRIDE;
42 virtual bool SwapBuffers() OVERRIDE; 40 virtual bool SwapBuffers() OVERRIDE;
43 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; 41 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
44 virtual std::string GetExtensions() OVERRIDE; 42 virtual std::string GetExtensions() OVERRIDE;
45 virtual void SetVisible(bool visible) OVERRIDE; 43 virtual void SetVisible(bool visible) OVERRIDE;
46 44
(...skipping 16 matching lines...) Expand all
63 // Size to resize to when the surface becomes visible. 61 // Size to resize to when the surface becomes visible.
64 gfx::Size visible_size_; 62 gfx::Size visible_size_;
65 63
66 scoped_ptr<ImageTransportHelper> helper_; 64 scoped_ptr<ImageTransportHelper> helper_;
67 65
68 DISALLOW_COPY_AND_ASSIGN(PbufferImageTransportSurface); 66 DISALLOW_COPY_AND_ASSIGN(PbufferImageTransportSurface);
69 }; 67 };
70 68
71 PbufferImageTransportSurface::PbufferImageTransportSurface( 69 PbufferImageTransportSurface::PbufferImageTransportSurface(
72 GpuChannelManager* manager, 70 GpuChannelManager* manager,
73 int32 render_view_id, 71 GpuCommandBufferStub* stub)
74 int32 client_id, 72 : GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1))),
75 int32 command_buffer_id) 73 is_visible_(true) {
76 : GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false,
77 gfx::Size(1, 1))),
78 is_visible_(true) {
79 helper_.reset(new ImageTransportHelper(this, 74 helper_.reset(new ImageTransportHelper(this,
80 manager, 75 manager,
81 render_view_id, 76 stub,
82 client_id,
83 command_buffer_id,
84 gfx::kNullPluginWindow)); 77 gfx::kNullPluginWindow));
85 } 78 }
86 79
87 PbufferImageTransportSurface::~PbufferImageTransportSurface() { 80 PbufferImageTransportSurface::~PbufferImageTransportSurface() {
88 Destroy(); 81 Destroy();
89 } 82 }
90 83
91 bool PbufferImageTransportSurface::Initialize() { 84 bool PbufferImageTransportSurface::Initialize() {
92 // Only support this path if the GL implementation is ANGLE. 85 // Only support this path if the GL implementation is ANGLE.
93 // IO surfaces will not work with, for example, OSMesa software renderer 86 // IO surfaces will not work with, for example, OSMesa software renderer
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 Resize(size); 172 Resize(size);
180 173
181 visible_size_ = size; 174 visible_size_ = size;
182 } 175 }
183 176
184 } // namespace anonymous 177 } // namespace anonymous
185 178
186 // static 179 // static
187 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( 180 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface(
188 GpuChannelManager* manager, 181 GpuChannelManager* manager,
189 int32 render_view_id, 182 GpuCommandBufferStub* stub,
190 int32 client_id,
191 int32 command_buffer_id,
192 gfx::PluginWindowHandle handle) { 183 gfx::PluginWindowHandle handle) {
193 scoped_refptr<gfx::GLSurface> surface; 184 scoped_refptr<gfx::GLSurface> surface;
194 185
195 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && 186 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
196 !CommandLine::ForCurrentProcess()->HasSwitch( 187 !CommandLine::ForCurrentProcess()->HasSwitch(
197 switches::kDisableImageTransportSurface)) { 188 switches::kDisableImageTransportSurface)) {
198 const char* extensions = eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY), 189 const char* extensions = eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY),
199 EGL_EXTENSIONS); 190 EGL_EXTENSIONS);
200 if (strstr(extensions, "EGL_ANGLE_query_surface_pointer") && 191 if (strstr(extensions, "EGL_ANGLE_query_surface_pointer") &&
201 strstr(extensions, "EGL_ANGLE_surface_d3d_texture_2d_share_handle")) { 192 strstr(extensions, "EGL_ANGLE_surface_d3d_texture_2d_share_handle")) {
202 surface = new PbufferImageTransportSurface(manager, 193 surface = new PbufferImageTransportSurface(manager, stub);
203 render_view_id,
204 client_id,
205 command_buffer_id);
206 } 194 }
207 } 195 }
208 196
209 if (!surface.get()) { 197 if (!surface.get()) {
210 surface = gfx::GLSurface::CreateViewGLSurface(false, handle); 198 surface = gfx::GLSurface::CreateViewGLSurface(false, handle);
211 if (!surface.get()) 199 if (!surface.get())
212 return NULL; 200 return NULL;
213 201
214 surface = new PassThroughImageTransportSurface(manager, 202 surface = new PassThroughImageTransportSurface(manager,
215 render_view_id, 203 stub,
216 client_id,
217 command_buffer_id,
218 surface.get()); 204 surface.get());
219 } 205 }
220 206
221 if (surface->Initialize()) 207 if (surface->Initialize())
222 return surface; 208 return surface;
223 else 209 else
224 return NULL; 210 return NULL;
225 } 211 }
226 212
227 #endif // ENABLE_GPU 213 #endif // ENABLE_GPU
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698