OLD | NEW |
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/mac/scoped_cftyperef.h" | 9 #include "base/mac/scoped_cftyperef.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "content/common/gpu/gpu_messages.h" | 11 #include "content/common/gpu/gpu_messages.h" |
12 #include "ui/gfx/gl/gl_context.h" | 12 #include "ui/gfx/gl/gl_context.h" |
13 #include "ui/gfx/gl/gl_bindings.h" | 13 #include "ui/gfx/gl/gl_bindings.h" |
14 #include "ui/gfx/gl/gl_implementation.h" | 14 #include "ui/gfx/gl/gl_implementation.h" |
15 #include "ui/gfx/gl/gl_surface_cgl.h" | 15 #include "ui/gfx/gl/gl_surface_cgl.h" |
16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/gfx/surface/io_surface_support_mac.h" | 17 #include "ui/gfx/surface/io_surface_support_mac.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // We are backed by an offscreen surface for the purposes of creating | 21 // We are backed by an offscreen surface for the purposes of creating |
22 // a context, but use FBOs to render to texture backed IOSurface | 22 // a context, but use FBOs to render to texture backed IOSurface |
23 class IOSurfaceImageTransportSurface : public gfx::NoOpGLSurfaceCGL, | 23 class IOSurfaceImageTransportSurface : public gfx::NoOpGLSurfaceCGL, |
24 public ImageTransportSurface { | 24 public ImageTransportSurface { |
25 public: | 25 public: |
26 IOSurfaceImageTransportSurface(GpuChannelManager* manager, | 26 IOSurfaceImageTransportSurface(GpuChannelManager* manager, |
27 int32 render_view_id, | 27 GpuCommandBufferStub* stub, |
28 int32 client_id, | |
29 int32 command_buffer_id, | |
30 gfx::PluginWindowHandle handle); | 28 gfx::PluginWindowHandle handle); |
31 | 29 |
32 // GLSurface implementation | 30 // GLSurface implementation |
33 virtual bool Initialize() OVERRIDE; | 31 virtual bool Initialize() OVERRIDE; |
34 virtual void Destroy() OVERRIDE; | 32 virtual void Destroy() OVERRIDE; |
35 virtual bool IsOffscreen() OVERRIDE; | 33 virtual bool IsOffscreen() OVERRIDE; |
36 virtual bool SwapBuffers() OVERRIDE; | 34 virtual bool SwapBuffers() OVERRIDE; |
37 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | 35 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
38 virtual std::string GetExtensions() OVERRIDE; | 36 virtual std::string GetExtensions() OVERRIDE; |
39 virtual gfx::Size GetSize() OVERRIDE; | 37 virtual gfx::Size GetSize() OVERRIDE; |
40 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 38 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
41 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 39 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
42 | 40 |
43 protected: | 41 protected: |
44 // ImageTransportSurface implementation | 42 // ImageTransportSurface implementation |
45 virtual void OnNewSurfaceACK(uint64 surface_id, | 43 virtual void OnNewSurfaceACK(uint64 surface_handle, |
46 TransportDIB::Handle shm_handle) OVERRIDE; | 44 TransportDIB::Handle shm_handle) OVERRIDE; |
47 virtual void OnBuffersSwappedACK() OVERRIDE; | 45 virtual void OnBuffersSwappedACK() OVERRIDE; |
48 virtual void OnPostSubBufferACK() OVERRIDE; | 46 virtual void OnPostSubBufferACK() OVERRIDE; |
49 virtual void OnResizeViewACK() OVERRIDE; | 47 virtual void OnResizeViewACK() OVERRIDE; |
50 virtual void OnResize(gfx::Size size) OVERRIDE; | 48 virtual void OnResize(gfx::Size size) OVERRIDE; |
51 | 49 |
52 private: | 50 private: |
53 virtual ~IOSurfaceImageTransportSurface() OVERRIDE; | 51 virtual ~IOSurfaceImageTransportSurface() OVERRIDE; |
54 | 52 |
55 uint32 fbo_id_; | 53 uint32 fbo_id_; |
56 GLuint texture_id_; | 54 GLuint texture_id_; |
57 | 55 |
58 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; | 56 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; |
59 | 57 |
60 // The id of |io_surface_| or 0 if that's NULL. | 58 // The id of |io_surface_| or 0 if that's NULL. |
61 uint64 io_surface_id_; | 59 uint64 io_surface_handle_; |
62 | 60 |
63 // Weak pointer to the context that this was last made current to. | 61 // Weak pointer to the context that this was last made current to. |
64 gfx::GLContext* context_; | 62 gfx::GLContext* context_; |
65 | 63 |
66 gfx::Size size_; | 64 gfx::Size size_; |
67 | 65 |
68 // Whether or not we've successfully made the surface current once. | 66 // Whether or not we've successfully made the surface current once. |
69 bool made_current_; | 67 bool made_current_; |
70 | 68 |
71 scoped_ptr<ImageTransportHelper> helper_; | 69 scoped_ptr<ImageTransportHelper> helper_; |
72 | 70 |
73 DISALLOW_COPY_AND_ASSIGN(IOSurfaceImageTransportSurface); | 71 DISALLOW_COPY_AND_ASSIGN(IOSurfaceImageTransportSurface); |
74 }; | 72 }; |
75 | 73 |
76 // We are backed by an offscreen surface for the purposes of creating | 74 // We are backed by an offscreen surface for the purposes of creating |
77 // a context, but use FBOs to render to texture backed IOSurface | 75 // a context, but use FBOs to render to texture backed IOSurface |
78 class TransportDIBImageTransportSurface : public gfx::NoOpGLSurfaceCGL, | 76 class TransportDIBImageTransportSurface : public gfx::NoOpGLSurfaceCGL, |
79 public ImageTransportSurface { | 77 public ImageTransportSurface { |
80 public: | 78 public: |
81 TransportDIBImageTransportSurface(GpuChannelManager* manager, | 79 TransportDIBImageTransportSurface(GpuChannelManager* manager, |
82 int32 render_view_id, | 80 GpuCommandBufferStub* stub, |
83 int32 client_id, | |
84 int32 command_buffer_id, | |
85 gfx::PluginWindowHandle handle); | 81 gfx::PluginWindowHandle handle); |
86 | 82 |
87 // GLSurface implementation | 83 // GLSurface implementation |
88 virtual bool Initialize() OVERRIDE; | 84 virtual bool Initialize() OVERRIDE; |
89 virtual void Destroy() OVERRIDE; | 85 virtual void Destroy() OVERRIDE; |
90 virtual bool IsOffscreen() OVERRIDE; | 86 virtual bool IsOffscreen() OVERRIDE; |
91 virtual bool SwapBuffers() OVERRIDE; | 87 virtual bool SwapBuffers() OVERRIDE; |
92 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | 88 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
93 virtual std::string GetExtensions() OVERRIDE; | 89 virtual std::string GetExtensions() OVERRIDE; |
94 virtual gfx::Size GetSize() OVERRIDE; | 90 virtual gfx::Size GetSize() OVERRIDE; |
95 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 91 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
96 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 92 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
97 | 93 |
98 protected: | 94 protected: |
99 // ImageTransportSurface implementation | 95 // ImageTransportSurface implementation |
100 virtual void OnBuffersSwappedACK() OVERRIDE; | 96 virtual void OnBuffersSwappedACK() OVERRIDE; |
101 virtual void OnPostSubBufferACK() OVERRIDE; | 97 virtual void OnPostSubBufferACK() OVERRIDE; |
102 virtual void OnNewSurfaceACK(uint64 surface_id, | 98 virtual void OnNewSurfaceACK(uint64 surface_handle, |
103 TransportDIB::Handle shm_handle) OVERRIDE; | 99 TransportDIB::Handle shm_handle) OVERRIDE; |
104 virtual void OnResizeViewACK() OVERRIDE; | 100 virtual void OnResizeViewACK() OVERRIDE; |
105 virtual void OnResize(gfx::Size size) OVERRIDE; | 101 virtual void OnResize(gfx::Size size) OVERRIDE; |
106 | 102 |
107 private: | 103 private: |
108 virtual ~TransportDIBImageTransportSurface() OVERRIDE; | 104 virtual ~TransportDIBImageTransportSurface() OVERRIDE; |
109 | 105 |
110 uint32 fbo_id_; | 106 uint32 fbo_id_; |
111 GLuint render_buffer_id_; | 107 GLuint render_buffer_id_; |
112 | 108 |
113 scoped_ptr<TransportDIB> shared_mem_; | 109 scoped_ptr<TransportDIB> shared_mem_; |
114 | 110 |
115 gfx::Size size_; | 111 gfx::Size size_; |
116 | 112 |
117 static uint32 next_id_; | 113 static uint32 next_handle_; |
118 | 114 |
119 // Whether or not we've successfully made the surface current once. | 115 // Whether or not we've successfully made the surface current once. |
120 bool made_current_; | 116 bool made_current_; |
121 | 117 |
122 scoped_ptr<ImageTransportHelper> helper_; | 118 scoped_ptr<ImageTransportHelper> helper_; |
123 | 119 |
124 DISALLOW_COPY_AND_ASSIGN(TransportDIBImageTransportSurface); | 120 DISALLOW_COPY_AND_ASSIGN(TransportDIBImageTransportSurface); |
125 }; | 121 }; |
126 | 122 |
127 uint32 TransportDIBImageTransportSurface::next_id_ = 1; | 123 uint32 TransportDIBImageTransportSurface::next_handle_ = 1; |
128 | 124 |
129 void AddBooleanValue(CFMutableDictionaryRef dictionary, | 125 void AddBooleanValue(CFMutableDictionaryRef dictionary, |
130 const CFStringRef key, | 126 const CFStringRef key, |
131 bool value) { | 127 bool value) { |
132 CFDictionaryAddValue(dictionary, key, | 128 CFDictionaryAddValue(dictionary, key, |
133 (value ? kCFBooleanTrue : kCFBooleanFalse)); | 129 (value ? kCFBooleanTrue : kCFBooleanFalse)); |
134 } | 130 } |
135 | 131 |
136 void AddIntegerValue(CFMutableDictionaryRef dictionary, | 132 void AddIntegerValue(CFMutableDictionaryRef dictionary, |
137 const CFStringRef key, | 133 const CFStringRef key, |
138 int32 value) { | 134 int32 value) { |
139 base::mac::ScopedCFTypeRef<CFNumberRef> number( | 135 base::mac::ScopedCFTypeRef<CFNumberRef> number( |
140 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); | 136 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); |
141 CFDictionaryAddValue(dictionary, key, number.get()); | 137 CFDictionaryAddValue(dictionary, key, number.get()); |
142 } | 138 } |
143 | 139 |
144 IOSurfaceImageTransportSurface::IOSurfaceImageTransportSurface( | 140 IOSurfaceImageTransportSurface::IOSurfaceImageTransportSurface( |
145 GpuChannelManager* manager, | 141 GpuChannelManager* manager, |
146 int32 render_view_id, | 142 GpuCommandBufferStub* stub, |
147 int32 client_id, | |
148 int32 command_buffer_id, | |
149 gfx::PluginWindowHandle handle) | 143 gfx::PluginWindowHandle handle) |
150 : gfx::NoOpGLSurfaceCGL(gfx::Size(1, 1)), | 144 : gfx::NoOpGLSurfaceCGL(gfx::Size(1, 1)), |
151 fbo_id_(0), | 145 fbo_id_(0), |
152 texture_id_(0), | 146 texture_id_(0), |
153 io_surface_id_(0), | 147 io_surface_handle_(0), |
154 context_(NULL), | 148 context_(NULL), |
155 made_current_(false) { | 149 made_current_(false) { |
156 helper_.reset(new ImageTransportHelper(this, | 150 helper_.reset(new ImageTransportHelper(this, manager, stub, handle)); |
157 manager, | |
158 render_view_id, | |
159 client_id, | |
160 command_buffer_id, | |
161 handle)); | |
162 | |
163 } | 151 } |
164 | 152 |
165 IOSurfaceImageTransportSurface::~IOSurfaceImageTransportSurface() { | 153 IOSurfaceImageTransportSurface::~IOSurfaceImageTransportSurface() { |
166 Destroy(); | 154 Destroy(); |
167 } | 155 } |
168 | 156 |
169 bool IOSurfaceImageTransportSurface::Initialize() { | 157 bool IOSurfaceImageTransportSurface::Initialize() { |
170 // Only support IOSurfaces if the GL implementation is the native desktop GL. | 158 // Only support IOSurfaces if the GL implementation is the native desktop GL. |
171 // IO surfaces will not work with, for example, OSMesa software renderer | 159 // IO surfaces will not work with, for example, OSMesa software renderer |
172 // GL contexts. | 160 // GL contexts. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } | 207 } |
220 | 208 |
221 unsigned int IOSurfaceImageTransportSurface::GetBackingFrameBufferObject() { | 209 unsigned int IOSurfaceImageTransportSurface::GetBackingFrameBufferObject() { |
222 return fbo_id_; | 210 return fbo_id_; |
223 } | 211 } |
224 | 212 |
225 bool IOSurfaceImageTransportSurface::SwapBuffers() { | 213 bool IOSurfaceImageTransportSurface::SwapBuffers() { |
226 glFlush(); | 214 glFlush(); |
227 | 215 |
228 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 216 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
229 params.surface_id = io_surface_id_; | 217 params.surface_handle = io_surface_handle_; |
230 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 218 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
231 | 219 |
232 helper_->SetScheduled(false); | 220 helper_->SetScheduled(false); |
233 return true; | 221 return true; |
234 } | 222 } |
235 | 223 |
236 bool IOSurfaceImageTransportSurface::PostSubBuffer( | 224 bool IOSurfaceImageTransportSurface::PostSubBuffer( |
237 int x, int y, int width, int height) { | 225 int x, int y, int width, int height) { |
238 glFlush(); | 226 glFlush(); |
239 | 227 |
240 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; | 228 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
241 params.surface_id = io_surface_id_; | 229 params.surface_handle = io_surface_handle_; |
242 params.x = x; | 230 params.x = x; |
243 params.y = y; | 231 params.y = y; |
244 params.width = width; | 232 params.width = width; |
245 params.height = height; | 233 params.height = height; |
246 helper_->SendAcceleratedSurfacePostSubBuffer(params); | 234 helper_->SendAcceleratedSurfacePostSubBuffer(params); |
247 | 235 |
248 helper_->SetScheduled(false); | 236 helper_->SetScheduled(false); |
249 return true; | 237 return true; |
250 } | 238 } |
251 | 239 |
(...skipping 11 matching lines...) Expand all Loading... |
263 | 251 |
264 void IOSurfaceImageTransportSurface::OnBuffersSwappedACK() { | 252 void IOSurfaceImageTransportSurface::OnBuffersSwappedACK() { |
265 helper_->SetScheduled(true); | 253 helper_->SetScheduled(true); |
266 } | 254 } |
267 | 255 |
268 void IOSurfaceImageTransportSurface::OnPostSubBufferACK() { | 256 void IOSurfaceImageTransportSurface::OnPostSubBufferACK() { |
269 helper_->SetScheduled(true); | 257 helper_->SetScheduled(true); |
270 } | 258 } |
271 | 259 |
272 void IOSurfaceImageTransportSurface::OnNewSurfaceACK( | 260 void IOSurfaceImageTransportSurface::OnNewSurfaceACK( |
273 uint64 surface_id, | 261 uint64 surface_handle, |
274 TransportDIB::Handle /* shm_handle */) { | 262 TransportDIB::Handle /* shm_handle */) { |
275 DCHECK_EQ(io_surface_id_, surface_id); | 263 DCHECK_EQ(io_surface_handle_, surface_handle); |
276 helper_->SetScheduled(true); | 264 helper_->SetScheduled(true); |
277 } | 265 } |
278 | 266 |
279 void IOSurfaceImageTransportSurface::OnResizeViewACK() { | 267 void IOSurfaceImageTransportSurface::OnResizeViewACK() { |
280 NOTREACHED(); | 268 NOTREACHED(); |
281 } | 269 } |
282 | 270 |
283 void IOSurfaceImageTransportSurface::OnResize(gfx::Size size) { | 271 void IOSurfaceImageTransportSurface::OnResize(gfx::Size size) { |
284 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); | 272 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); |
285 | 273 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 static_cast<CGLContextObj>(context_->GetHandle()), | 334 static_cast<CGLContextObj>(context_->GetHandle()), |
347 target, | 335 target, |
348 GL_RGBA, | 336 GL_RGBA, |
349 size_.width(), | 337 size_.width(), |
350 size_.height(), | 338 size_.height(), |
351 GL_BGRA, | 339 GL_BGRA, |
352 GL_UNSIGNED_INT_8_8_8_8_REV, | 340 GL_UNSIGNED_INT_8_8_8_8_REV, |
353 io_surface_.get(), | 341 io_surface_.get(), |
354 plane); | 342 plane); |
355 | 343 |
356 io_surface_id_ = io_surface_support->IOSurfaceGetID(io_surface_); | 344 io_surface_handle_ = io_surface_support->IOSurfaceGetID(io_surface_); |
357 glFlush(); | 345 glFlush(); |
358 | 346 |
359 glBindTexture(target, previous_texture_id); | 347 glBindTexture(target, previous_texture_id); |
360 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id); | 348 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id); |
361 | 349 |
362 GpuHostMsg_AcceleratedSurfaceNew_Params params; | 350 GpuHostMsg_AcceleratedSurfaceNew_Params params; |
363 params.width = size_.width(); | 351 params.width = size_.width(); |
364 params.height = size_.height(); | 352 params.height = size_.height(); |
365 params.surface_id = io_surface_id_; | 353 params.surface_handle = io_surface_handle_; |
366 params.create_transport_dib = false; | 354 params.create_transport_dib = false; |
367 helper_->SendAcceleratedSurfaceNew(params); | 355 helper_->SendAcceleratedSurfaceNew(params); |
368 | 356 |
369 helper_->SetScheduled(false); | 357 helper_->SetScheduled(false); |
370 } | 358 } |
371 | 359 |
372 TransportDIBImageTransportSurface::TransportDIBImageTransportSurface( | 360 TransportDIBImageTransportSurface::TransportDIBImageTransportSurface( |
373 GpuChannelManager* manager, | 361 GpuChannelManager* manager, |
374 int32 render_view_id, | 362 GpuCommandBufferStub* stub, |
375 int32 client_id, | |
376 int32 command_buffer_id, | |
377 gfx::PluginWindowHandle handle) | 363 gfx::PluginWindowHandle handle) |
378 : gfx::NoOpGLSurfaceCGL(gfx::Size(1, 1)), | 364 : gfx::NoOpGLSurfaceCGL(gfx::Size(1, 1)), |
379 fbo_id_(0), | 365 fbo_id_(0), |
380 render_buffer_id_(0), | 366 render_buffer_id_(0), |
381 made_current_(false) { | 367 made_current_(false) { |
382 helper_.reset(new ImageTransportHelper(this, | 368 helper_.reset(new ImageTransportHelper(this, manager, stub, handle)); |
383 manager, | |
384 render_view_id, | |
385 client_id, | |
386 command_buffer_id, | |
387 handle)); | |
388 | 369 |
389 } | 370 } |
390 | 371 |
391 TransportDIBImageTransportSurface::~TransportDIBImageTransportSurface() { | 372 TransportDIBImageTransportSurface::~TransportDIBImageTransportSurface() { |
392 Destroy(); | 373 Destroy(); |
393 } | 374 } |
394 | 375 |
395 bool TransportDIBImageTransportSurface::Initialize() { | 376 bool TransportDIBImageTransportSurface::Initialize() { |
396 if (!helper_->Initialize()) | 377 if (!helper_->Initialize()) |
397 return false; | 378 return false; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 glReadPixels(0, 0, | 434 glReadPixels(0, 0, |
454 size_.width(), size_.height(), | 435 size_.width(), size_.height(), |
455 GL_BGRA, // This pixel format should have no conversion. | 436 GL_BGRA, // This pixel format should have no conversion. |
456 GL_UNSIGNED_INT_8_8_8_8_REV, | 437 GL_UNSIGNED_INT_8_8_8_8_REV, |
457 shared_mem_->memory()); | 438 shared_mem_->memory()); |
458 glPixelStorei(GL_PACK_ALIGNMENT, current_alignment); | 439 glPixelStorei(GL_PACK_ALIGNMENT, current_alignment); |
459 | 440 |
460 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id); | 441 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id); |
461 | 442 |
462 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 443 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
463 params.surface_id = next_id_; | 444 params.surface_handle = next_handle_; |
464 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 445 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
465 | 446 |
466 helper_->SetScheduled(false); | 447 helper_->SetScheduled(false); |
467 return true; | 448 return true; |
468 } | 449 } |
469 | 450 |
470 bool TransportDIBImageTransportSurface::PostSubBuffer( | 451 bool TransportDIBImageTransportSurface::PostSubBuffer( |
471 int x, int y, int width, int height) { | 452 int x, int y, int width, int height) { |
472 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); | 453 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); |
473 | 454 |
(...skipping 16 matching lines...) Expand all Loading... |
490 GL_BGRA, // This pixel format should have no conversion. | 471 GL_BGRA, // This pixel format should have no conversion. |
491 GL_UNSIGNED_INT_8_8_8_8_REV, | 472 GL_UNSIGNED_INT_8_8_8_8_REV, |
492 &buffer[(x + y * size_.width()) * 4]); | 473 &buffer[(x + y * size_.width()) * 4]); |
493 | 474 |
494 glPixelStorei(GL_PACK_ALIGNMENT, current_alignment); | 475 glPixelStorei(GL_PACK_ALIGNMENT, current_alignment); |
495 glPixelStorei(GL_PACK_ROW_LENGTH, current_pack_row_length); | 476 glPixelStorei(GL_PACK_ROW_LENGTH, current_pack_row_length); |
496 | 477 |
497 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id); | 478 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id); |
498 | 479 |
499 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; | 480 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
500 params.surface_id = next_id_; | 481 params.surface_handle = next_handle_; |
501 params.x = x; | 482 params.x = x; |
502 params.y = y; | 483 params.y = y; |
503 params.width = width; | 484 params.width = width; |
504 params.height = height; | 485 params.height = height; |
505 helper_->SendAcceleratedSurfacePostSubBuffer(params); | 486 helper_->SendAcceleratedSurfacePostSubBuffer(params); |
506 | 487 |
507 helper_->SetScheduled(false); | 488 helper_->SetScheduled(false); |
508 return true; | 489 return true; |
509 } | 490 } |
510 | 491 |
(...skipping 11 matching lines...) Expand all Loading... |
522 | 503 |
523 void TransportDIBImageTransportSurface::OnBuffersSwappedACK() { | 504 void TransportDIBImageTransportSurface::OnBuffersSwappedACK() { |
524 helper_->SetScheduled(true); | 505 helper_->SetScheduled(true); |
525 } | 506 } |
526 | 507 |
527 void TransportDIBImageTransportSurface::OnPostSubBufferACK() { | 508 void TransportDIBImageTransportSurface::OnPostSubBufferACK() { |
528 helper_->SetScheduled(true); | 509 helper_->SetScheduled(true); |
529 } | 510 } |
530 | 511 |
531 void TransportDIBImageTransportSurface::OnNewSurfaceACK( | 512 void TransportDIBImageTransportSurface::OnNewSurfaceACK( |
532 uint64 surface_id, | 513 uint64 surface_handle, |
533 TransportDIB::Handle shm_handle) { | 514 TransportDIB::Handle shm_handle) { |
534 helper_->SetScheduled(true); | 515 helper_->SetScheduled(true); |
535 | 516 |
536 shared_mem_.reset(TransportDIB::Map(shm_handle)); | 517 shared_mem_.reset(TransportDIB::Map(shm_handle)); |
537 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); | 518 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); |
538 } | 519 } |
539 | 520 |
540 void TransportDIBImageTransportSurface::OnResizeViewACK() { | 521 void TransportDIBImageTransportSurface::OnResizeViewACK() { |
541 NOTREACHED(); | 522 NOTREACHED(); |
542 } | 523 } |
(...skipping 20 matching lines...) Expand all Loading... |
563 GL_COLOR_ATTACHMENT0_EXT, | 544 GL_COLOR_ATTACHMENT0_EXT, |
564 GL_RENDERBUFFER_EXT, | 545 GL_RENDERBUFFER_EXT, |
565 render_buffer_id_); | 546 render_buffer_id_); |
566 | 547 |
567 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, previous_renderbuffer_id); | 548 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, previous_renderbuffer_id); |
568 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id); | 549 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id); |
569 | 550 |
570 GpuHostMsg_AcceleratedSurfaceNew_Params params; | 551 GpuHostMsg_AcceleratedSurfaceNew_Params params; |
571 params.width = size_.width(); | 552 params.width = size_.width(); |
572 params.height = size_.height(); | 553 params.height = size_.height(); |
573 params.surface_id = next_id_++; | 554 params.surface_handle = next_handle_++; |
574 params.create_transport_dib = true; | 555 params.create_transport_dib = true; |
575 helper_->SendAcceleratedSurfaceNew(params); | 556 helper_->SendAcceleratedSurfaceNew(params); |
576 | 557 |
577 helper_->SetScheduled(false); | 558 helper_->SetScheduled(false); |
578 } | 559 } |
579 | 560 |
580 } // namespace | 561 } // namespace |
581 | 562 |
582 // static | 563 // static |
583 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( | 564 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( |
584 GpuChannelManager* manager, | 565 GpuChannelManager* manager, |
585 int32 render_view_id, | 566 GpuCommandBufferStub* stub, |
586 int32 client_id, | |
587 int32 command_buffer_id, | |
588 gfx::PluginWindowHandle handle) { | 567 gfx::PluginWindowHandle handle) { |
589 scoped_refptr<gfx::GLSurface> surface; | 568 scoped_refptr<gfx::GLSurface> surface; |
590 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); | 569 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); |
591 | 570 |
592 switch (gfx::GetGLImplementation()) { | 571 switch (gfx::GetGLImplementation()) { |
593 case gfx::kGLImplementationDesktopGL: | 572 case gfx::kGLImplementationDesktopGL: |
594 case gfx::kGLImplementationAppleGL: | 573 case gfx::kGLImplementationAppleGL: |
595 if (!io_surface_support) { | 574 if (!io_surface_support) { |
596 surface = new TransportDIBImageTransportSurface(manager, | 575 surface = new TransportDIBImageTransportSurface(manager, stub, handle); |
597 render_view_id, | |
598 client_id, | |
599 command_buffer_id, | |
600 handle); | |
601 } else { | 576 } else { |
602 surface = new IOSurfaceImageTransportSurface(manager, | 577 surface = new IOSurfaceImageTransportSurface(manager, stub, handle); |
603 render_view_id, | |
604 client_id, | |
605 command_buffer_id, | |
606 handle); | |
607 } | 578 } |
608 break; | 579 break; |
609 default: | 580 default: |
610 NOTREACHED(); | 581 NOTREACHED(); |
611 return NULL; | 582 return NULL; |
612 } | 583 } |
613 if (surface->Initialize()) | 584 if (surface->Initialize()) |
614 return surface; | 585 return surface; |
615 else | 586 else |
616 return NULL; | 587 return NULL; |
617 } | 588 } |
618 | 589 |
619 #endif // defined(USE_GPU) | 590 #endif // defined(USE_GPU) |
OLD | NEW |