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

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

Issue 10388010: Decoupling backbuffer allocation suggestion from frontbuffer allocation suggestion. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Caching size in EGL (compiles, not tested), and DCHECKS to win (not tested). Created 8 years, 7 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 #include "content/common/gpu/image_transport_surface.h" 5 #include "content/common/gpu/image_transport_surface.h"
6 6
7 // This conflicts with the defines in Xlib.h and must come first. 7 // This conflicts with the defines in Xlib.h and must come first.
8 #include "content/common/gpu/gpu_messages.h" 8 #include "content/common/gpu/gpu_messages.h"
9 9
10 #include <map> 10 #include <map>
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // gfx::GLSurface implementation 86 // gfx::GLSurface implementation
87 virtual bool Initialize() OVERRIDE; 87 virtual bool Initialize() OVERRIDE;
88 virtual void Destroy() OVERRIDE; 88 virtual void Destroy() OVERRIDE;
89 virtual bool IsOffscreen() OVERRIDE; 89 virtual bool IsOffscreen() OVERRIDE;
90 virtual bool SwapBuffers() OVERRIDE; 90 virtual bool SwapBuffers() OVERRIDE;
91 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; 91 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
92 virtual std::string GetExtensions() OVERRIDE; 92 virtual std::string GetExtensions() OVERRIDE;
93 virtual gfx::Size GetSize() OVERRIDE; 93 virtual gfx::Size GetSize() OVERRIDE;
94 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; 94 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
95 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; 95 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE;
96 virtual void SetBufferAllocation(BufferAllocationState state) OVERRIDE; 96 virtual void SetBackbufferAllocation(bool allocated) OVERRIDE;
97 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE;
97 98
98 protected: 99 protected:
99 // ImageTransportSurface implementation 100 // ImageTransportSurface implementation
100 virtual void OnNewSurfaceACK( 101 virtual void OnNewSurfaceACK(
101 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; 102 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE;
102 virtual void OnBuffersSwappedACK() OVERRIDE; 103 virtual void OnBuffersSwappedACK() OVERRIDE;
103 virtual void OnPostSubBufferACK() OVERRIDE; 104 virtual void OnPostSubBufferACK() OVERRIDE;
104 virtual void OnResizeViewACK() OVERRIDE; 105 virtual void OnResizeViewACK() OVERRIDE;
105 virtual void OnResize(gfx::Size size) OVERRIDE; 106 virtual void OnResize(gfx::Size size) OVERRIDE;
106 107
107 private: 108 private:
108 virtual ~EGLImageTransportSurface() OVERRIDE; 109 virtual ~EGLImageTransportSurface() OVERRIDE;
109 void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface); 110 void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface);
110 void SendBuffersSwapped(); 111 void SendBuffersSwapped();
111 void SendPostSubBuffer(int x, int y, int width, int height); 112 void SendPostSubBuffer(int x, int y, int width, int height);
113 void AdjustBufferAllocations();
112 114
113 // Tracks the current buffer allocation state. 115 // Tracks the current buffer allocation state.
114 BufferAllocationState buffer_allocation_state_; 116 bool backbuffer_suggested_allocation_;
117 bool frontbuffer_suggested_allocation_;
118
119 // The expected size when visible.
120 gfx::Size visible_size_;
115 121
116 uint32 fbo_id_; 122 uint32 fbo_id_;
117 123
118 scoped_refptr<EGLAcceleratedSurface> back_surface_; 124 scoped_refptr<EGLAcceleratedSurface> back_surface_;
119 scoped_refptr<EGLAcceleratedSurface> front_surface_; 125 scoped_refptr<EGLAcceleratedSurface> front_surface_;
120 gfx::Rect previous_damage_rect_; 126 gfx::Rect previous_damage_rect_;
121 127
122 // Whether or not we've successfully made the surface current once. 128 // Whether or not we've successfully made the surface current once.
123 bool made_current_; 129 bool made_current_;
124 130
(...skipping 13 matching lines...) Expand all
138 GpuCommandBufferStub* stub); 144 GpuCommandBufferStub* stub);
139 145
140 // gfx::GLSurface implementation: 146 // gfx::GLSurface implementation:
141 virtual bool Initialize() OVERRIDE; 147 virtual bool Initialize() OVERRIDE;
142 virtual void Destroy() OVERRIDE; 148 virtual void Destroy() OVERRIDE;
143 virtual bool SwapBuffers() OVERRIDE; 149 virtual bool SwapBuffers() OVERRIDE;
144 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; 150 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
145 virtual std::string GetExtensions(); 151 virtual std::string GetExtensions();
146 virtual gfx::Size GetSize() OVERRIDE; 152 virtual gfx::Size GetSize() OVERRIDE;
147 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; 153 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
148 virtual void SetBufferAllocation(BufferAllocationState state) OVERRIDE; 154 virtual void SetBackbufferAllocation(bool allocated) OVERRIDE;
155 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE;
149 156
150 protected: 157 protected:
151 // ImageTransportSurface implementation: 158 // ImageTransportSurface implementation:
152 virtual void OnNewSurfaceACK( 159 virtual void OnNewSurfaceACK(
153 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; 160 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE;
154 virtual void OnBuffersSwappedACK() OVERRIDE; 161 virtual void OnBuffersSwappedACK() OVERRIDE;
155 virtual void OnPostSubBufferACK() OVERRIDE; 162 virtual void OnPostSubBufferACK() OVERRIDE;
156 virtual void OnResizeViewACK() OVERRIDE; 163 virtual void OnResizeViewACK() OVERRIDE;
157 virtual void OnResize(gfx::Size size) OVERRIDE; 164 virtual void OnResize(gfx::Size size) OVERRIDE;
158 165
159 private: 166 private:
160 virtual ~GLXImageTransportSurface(); 167 virtual ~GLXImageTransportSurface();
161 168
162 // Tell the browser to release the surface. 169 // Tell the browser to release the surface.
163 void ReleaseSurface(); 170 void ReleaseSurface();
164 171
165 void SendBuffersSwapped(); 172 void SendBuffersSwapped();
166 void SendPostSubBuffer(int x, int y, int width, int height); 173 void SendPostSubBuffer(int x, int y, int width, int height);
167 174
168 void ResizeSurface(gfx::Size size); 175 void ResizeSurface(gfx::Size size);
176 void AdjustBufferAllocations();
169 177
170 // Tracks the current buffer allocation state. 178 // Tracks the current buffer allocation state.
171 BufferAllocationState buffer_allocation_state_; 179 bool backbuffer_suggested_allocation_;
180 bool frontbuffer_suggested_allocation_;
172 181
173 XID dummy_parent_; 182 XID dummy_parent_;
174 gfx::Size size_; 183 gfx::Size size_;
175 184
176 // Whether or not the image has been bound on the browser side. 185 // Whether or not the image has been bound on the browser side.
177 bool bound_; 186 bool bound_;
178 187
179 // Whether or not we need to send a resize on the next swap. 188 // Whether or not we need to send a resize on the next swap.
180 bool needs_resize_; 189 bool needs_resize_;
181 190
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 EGLAcceleratedSurface::~EGLAcceleratedSurface() { 272 EGLAcceleratedSurface::~EGLAcceleratedSurface() {
264 glDeleteTextures(1, &texture_); 273 glDeleteTextures(1, &texture_);
265 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_); 274 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_);
266 XFreePixmap(gfx::GLSurfaceEGL::GetNativeDisplay(), pixmap_); 275 XFreePixmap(gfx::GLSurfaceEGL::GetNativeDisplay(), pixmap_);
267 } 276 }
268 277
269 EGLImageTransportSurface::EGLImageTransportSurface( 278 EGLImageTransportSurface::EGLImageTransportSurface(
270 GpuChannelManager* manager, 279 GpuChannelManager* manager,
271 GpuCommandBufferStub* stub) 280 GpuCommandBufferStub* stub)
272 : gfx::PbufferGLSurfaceEGL(false, gfx::Size(16, 16)), 281 : gfx::PbufferGLSurfaceEGL(false, gfx::Size(16, 16)),
273 buffer_allocation_state_(BUFFER_ALLOCATION_FRONT_AND_BACK), 282 backbuffer_suggested_allocation_(true),
283 frontbuffer_suggested_allocation_(true),
274 fbo_id_(0), 284 fbo_id_(0),
275 made_current_(false) { 285 made_current_(false) {
276 helper_.reset(new ImageTransportHelper(this, 286 helper_.reset(new ImageTransportHelper(this,
277 manager, 287 manager,
278 stub, 288 stub,
279 gfx::kNullPluginWindow)); 289 gfx::kNullPluginWindow));
280 } 290 }
281 291
282 EGLImageTransportSurface::~EGLImageTransportSurface() { 292 EGLImageTransportSurface::~EGLImageTransportSurface() {
283 Destroy(); 293 Destroy();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 339 }
330 340
331 made_current_ = true; 341 made_current_ = true;
332 return true; 342 return true;
333 } 343 }
334 344
335 unsigned int EGLImageTransportSurface::GetBackingFrameBufferObject() { 345 unsigned int EGLImageTransportSurface::GetBackingFrameBufferObject() {
336 return fbo_id_; 346 return fbo_id_;
337 } 347 }
338 348
339 void EGLImageTransportSurface::SetBufferAllocation( 349 void EGLImageTransportSurface::SetBackbufferAllocation(bool allocated) {
340 BufferAllocationState state) { 350 if (backbuffer_suggested_allocation_ == allocated)
341 if (buffer_allocation_state_ == state)
342 return; 351 return;
343 buffer_allocation_state_ = state; 352 backbuffer_suggested_allocation_ = allocated;
353 AdjustBufferAllocations();
354 }
344 355
345 switch (state) { 356 void EGLImageTransportSurface::SetFrontbufferAllocation(bool allocated) {
346 case BUFFER_ALLOCATION_FRONT_AND_BACK: 357 if (frontbuffer_suggested_allocation_ == allocated)
347 if (!back_surface_.get() && front_surface_.get()) 358 return;
348 OnResize(front_surface_->size()); 359 frontbuffer_suggested_allocation_ = allocated;
349 break; 360 }
350 361
351 case BUFFER_ALLOCATION_FRONT_ONLY: 362 void EGLImageTransportSurface::AdjustBufferAllocations() {
352 if (back_surface_.get() && front_surface_.get()) 363 if (!!back_surface_.get() != backbuffer_suggested_allocation_) {
353 ReleaseSurface(&back_surface_); 364 if (backbuffer_suggested_allocation_)
354 break; 365 OnResize(visible_size_);
355 366 else
356 case BUFFER_ALLOCATION_NONE: 367 ReleaseSurface(&back_surface_);
357 if (back_surface_.get() && front_surface_.get())
358 ReleaseSurface(&back_surface_);
359 break;
360
361 default:
362 NOTREACHED();
363 } 368 }
364 } 369 }
365 370
366 void EGLImageTransportSurface::ReleaseSurface( 371 void EGLImageTransportSurface::ReleaseSurface(
367 scoped_refptr<EGLAcceleratedSurface>* surface) { 372 scoped_refptr<EGLAcceleratedSurface>* surface) {
368 if (surface->get()) { 373 if (surface->get()) {
369 GpuHostMsg_AcceleratedSurfaceRelease_Params params; 374 GpuHostMsg_AcceleratedSurfaceRelease_Params params;
370 params.identifier = (*surface)->pixmap(); 375 params.identifier = (*surface)->pixmap();
371 helper_->SendAcceleratedSurfaceRelease(params); 376 helper_->SendAcceleratedSurfaceRelease(params);
372 *surface = NULL; 377 *surface = NULL;
373 } 378 }
374 } 379 }
375 380
376 void EGLImageTransportSurface::OnResize(gfx::Size size) { 381 void EGLImageTransportSurface::OnResize(gfx::Size size) {
382 visible_size_ = size;
377 back_surface_ = new EGLAcceleratedSurface(size); 383 back_surface_ = new EGLAcceleratedSurface(size);
378 384
379 GLint previous_fbo_id = 0; 385 GLint previous_fbo_id = 0;
380 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previous_fbo_id); 386 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previous_fbo_id);
381 387
382 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_id_); 388 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_id_);
383 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, 389 glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
384 GL_COLOR_ATTACHMENT0, 390 GL_COLOR_ATTACHMENT0,
385 GL_TEXTURE_2D, 391 GL_TEXTURE_2D,
386 back_surface_->texture(), 392 back_surface_->texture(),
387 0); 393 0);
388 glFlush(); 394 glFlush();
389 395
390 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id); 396 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id);
391 397
392 GpuHostMsg_AcceleratedSurfaceNew_Params params; 398 GpuHostMsg_AcceleratedSurfaceNew_Params params;
393 params.width = size.width(); 399 params.width = size.width();
394 params.height = size.height(); 400 params.height = size.height();
395 params.surface_handle = back_surface_->pixmap(); 401 params.surface_handle = back_surface_->pixmap();
396 helper_->SendAcceleratedSurfaceNew(params); 402 helper_->SendAcceleratedSurfaceNew(params);
397 403
398 helper_->SetScheduled(false); 404 helper_->SetScheduled(false);
399 } 405 }
400 406
401 bool EGLImageTransportSurface::SwapBuffers() { 407 bool EGLImageTransportSurface::SwapBuffers() {
408 DCHECK(backbuffer_suggested_allocation_);
409 DCHECK(frontbuffer_suggested_allocation_);
402 front_surface_.swap(back_surface_); 410 front_surface_.swap(back_surface_);
403 DCHECK_NE(front_surface_.get(), static_cast<EGLAcceleratedSurface*>(NULL)); 411 DCHECK_NE(front_surface_.get(), static_cast<EGLAcceleratedSurface*>(NULL));
404 helper_->DeferToFence(base::Bind( 412 helper_->DeferToFence(base::Bind(
405 &EGLImageTransportSurface::SendBuffersSwapped, 413 &EGLImageTransportSurface::SendBuffersSwapped,
406 AsWeakPtr())); 414 AsWeakPtr()));
407 415
408 gfx::Size expected_size = front_surface_->size(); 416 gfx::Size expected_size = front_surface_->size();
409 if (!back_surface_.get() || back_surface_->size() != expected_size) { 417 if (!back_surface_.get() || back_surface_->size() != expected_size) {
410 OnResize(expected_size); 418 OnResize(expected_size);
411 } else { 419 } else {
412 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, 420 glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
413 GL_COLOR_ATTACHMENT0, 421 GL_COLOR_ATTACHMENT0,
414 GL_TEXTURE_2D, 422 GL_TEXTURE_2D,
415 back_surface_->texture(), 423 back_surface_->texture(),
416 0); 424 0);
417 } 425 }
418 previous_damage_rect_ = gfx::Rect(front_surface_->size()); 426 previous_damage_rect_ = gfx::Rect(front_surface_->size());
419 return true; 427 return true;
420 } 428 }
421 429
422 void EGLImageTransportSurface::SendBuffersSwapped() { 430 void EGLImageTransportSurface::SendBuffersSwapped() {
423 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; 431 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
424 params.surface_handle = front_surface_->pixmap(); 432 params.surface_handle = front_surface_->pixmap();
425 helper_->SendAcceleratedSurfaceBuffersSwapped(params); 433 helper_->SendAcceleratedSurfaceBuffersSwapped(params);
426 helper_->SetScheduled(false); 434 helper_->SetScheduled(false);
427 } 435 }
428 436
429 bool EGLImageTransportSurface::PostSubBuffer( 437 bool EGLImageTransportSurface::PostSubBuffer(
430 int x, int y, int width, int height) { 438 int x, int y, int width, int height) {
431 439 DCHECK(backbuffer_suggested_allocation_);
440 DCHECK(frontbuffer_suggested_allocation_);
432 DCHECK_NE(back_surface_.get(), static_cast<EGLAcceleratedSurface*>(NULL)); 441 DCHECK_NE(back_surface_.get(), static_cast<EGLAcceleratedSurface*>(NULL));
433 gfx::Size expected_size = back_surface_->size(); 442 gfx::Size expected_size = back_surface_->size();
434 bool surfaces_same_size = front_surface_.get() && 443 bool surfaces_same_size = front_surface_.get() &&
435 front_surface_->size() == expected_size; 444 front_surface_->size() == expected_size;
436 445
437 const gfx::Rect new_damage_rect(x, y, width, height); 446 const gfx::Rect new_damage_rect(x, y, width, height);
438 447
439 // An empty damage rect is a successful no-op. 448 // An empty damage rect is a successful no-op.
440 if (new_damage_rect.IsEmpty()) 449 if (new_damage_rect.IsEmpty())
441 return true; 450 return true;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } 529 }
521 530
522 void EGLImageTransportSurface::OnResizeViewACK() { 531 void EGLImageTransportSurface::OnResizeViewACK() {
523 NOTREACHED(); 532 NOTREACHED();
524 } 533 }
525 534
526 GLXImageTransportSurface::GLXImageTransportSurface( 535 GLXImageTransportSurface::GLXImageTransportSurface(
527 GpuChannelManager* manager, 536 GpuChannelManager* manager,
528 GpuCommandBufferStub* stub) 537 GpuCommandBufferStub* stub)
529 : gfx::NativeViewGLSurfaceGLX(), 538 : gfx::NativeViewGLSurfaceGLX(),
530 buffer_allocation_state_(BUFFER_ALLOCATION_FRONT_AND_BACK), 539 backbuffer_suggested_allocation_(true),
540 frontbuffer_suggested_allocation_(true),
531 dummy_parent_(0), 541 dummy_parent_(0),
532 size_(1, 1), 542 size_(1, 1),
533 bound_(false), 543 bound_(false),
534 needs_resize_(false), 544 needs_resize_(false),
535 made_current_(false) { 545 made_current_(false) {
536 helper_.reset(new ImageTransportHelper(this, 546 helper_.reset(new ImageTransportHelper(this,
537 manager, 547 manager,
538 stub, 548 stub,
539 gfx::kNullPluginWindow)); 549 gfx::kNullPluginWindow));
540 } 550 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 614 }
605 615
606 void GLXImageTransportSurface::ReleaseSurface() { 616 void GLXImageTransportSurface::ReleaseSurface() {
607 DCHECK(bound_); 617 DCHECK(bound_);
608 GpuHostMsg_AcceleratedSurfaceRelease_Params params; 618 GpuHostMsg_AcceleratedSurfaceRelease_Params params;
609 params.identifier = window_; 619 params.identifier = window_;
610 helper_->SendAcceleratedSurfaceRelease(params); 620 helper_->SendAcceleratedSurfaceRelease(params);
611 bound_ = false; 621 bound_ = false;
612 } 622 }
613 623
614 void GLXImageTransportSurface::SetBufferAllocation( 624 void GLXImageTransportSurface::SetBackbufferAllocation(bool allocated) {
615 BufferAllocationState state) { 625 if (backbuffer_suggested_allocation_ == allocated)
616 if (buffer_allocation_state_ == state)
617 return; 626 return;
618 buffer_allocation_state_ = state; 627 backbuffer_suggested_allocation_ = allocated;
628 AdjustBufferAllocations();
jonathan.backer 2012/05/10 21:37:48 I think that we can just Resize here (the window i
629 }
619 630
620 switch (state) { 631 void GLXImageTransportSurface::SetFrontbufferAllocation(bool allocated) {
621 case BUFFER_ALLOCATION_FRONT_AND_BACK: { 632 if (frontbuffer_suggested_allocation_ == allocated)
622 ResizeSurface(size_); 633 return;
623 break; 634 frontbuffer_suggested_allocation_ = allocated;
jonathan.backer 2012/05/10 21:37:48 I think that we can just ReleaseSurface here when
624 } 635 AdjustBufferAllocations();
625 case BUFFER_ALLOCATION_FRONT_ONLY: { 636 }
626 ResizeSurface(gfx::Size(1,1)); 637
627 break; 638 void GLXImageTransportSurface::AdjustBufferAllocations() {
628 } 639 if (backbuffer_suggested_allocation_) {
jonathan.backer 2012/05/10 21:37:48 We wouldn't need this.
629 case BUFFER_ALLOCATION_NONE: { 640 ResizeSurface(size_);
630 ResizeSurface(gfx::Size(1,1)); 641 } else {
631 if (bound_) 642 ResizeSurface(gfx::Size(1,1));
632 ReleaseSurface(); 643 if (!frontbuffer_suggested_allocation_ && bound_)
633 break; 644 ReleaseSurface();
634 }
635 default:
636 NOTREACHED();
637 } 645 }
638 } 646 }
639 647
640 void GLXImageTransportSurface::ResizeSurface(gfx::Size size) { 648 void GLXImageTransportSurface::ResizeSurface(gfx::Size size) {
641 Display* dpy = static_cast<Display*>(GetDisplay()); 649 Display* dpy = static_cast<Display*>(GetDisplay());
642 XResizeWindow(dpy, window_, size.width(), size.height()); 650 XResizeWindow(dpy, window_, size.width(), size.height());
643 glXWaitX(); 651 glXWaitX();
644 // Seems necessary to perform a swap after a resize 652 // Seems necessary to perform a swap after a resize
645 // in order to resize the front and back buffers (Intel driver bug). 653 // in order to resize the front and back buffers (Intel driver bug).
646 // This doesn't always happen with scissoring enabled, so do it now. 654 // This doesn't always happen with scissoring enabled, so do it now.
647 if (gfx::g_GLX_MESA_copy_sub_buffer && gfx::GLSurface::GetCurrent() == this) 655 if (gfx::g_GLX_MESA_copy_sub_buffer && gfx::GLSurface::GetCurrent() == this)
648 gfx::NativeViewGLSurfaceGLX::SwapBuffers(); 656 gfx::NativeViewGLSurfaceGLX::SwapBuffers();
649 needs_resize_ = true; 657 needs_resize_ = true;
650 } 658 }
651 659
652 void GLXImageTransportSurface::OnResize(gfx::Size size) { 660 void GLXImageTransportSurface::OnResize(gfx::Size size) {
653 TRACE_EVENT0("gpu", "GLXImageTransportSurface::OnResize"); 661 TRACE_EVENT0("gpu", "GLXImageTransportSurface::OnResize");
654 size_ = size; 662 size_ = size;
655 ResizeSurface(size_); 663 ResizeSurface(size_);
656 } 664 }
657 665
658 bool GLXImageTransportSurface::SwapBuffers() { 666 bool GLXImageTransportSurface::SwapBuffers() {
667 DCHECK(backbuffer_suggested_allocation_);
668 DCHECK(frontbuffer_suggested_allocation_);
659 gfx::NativeViewGLSurfaceGLX::SwapBuffers(); 669 gfx::NativeViewGLSurfaceGLX::SwapBuffers();
660 helper_->DeferToFence(base::Bind( 670 helper_->DeferToFence(base::Bind(
661 &GLXImageTransportSurface::SendBuffersSwapped, 671 &GLXImageTransportSurface::SendBuffersSwapped,
662 AsWeakPtr())); 672 AsWeakPtr()));
663 673
664 if (needs_resize_) { 674 if (needs_resize_) {
665 GpuHostMsg_AcceleratedSurfaceNew_Params params; 675 GpuHostMsg_AcceleratedSurfaceNew_Params params;
666 params.width = size_.width(); 676 params.width = size_.width();
667 params.height = size_.height(); 677 params.height = size_.height();
668 params.surface_handle = window_; 678 params.surface_handle = window_;
669 helper_->SendAcceleratedSurfaceNew(params); 679 helper_->SendAcceleratedSurfaceNew(params);
670 bound_ = true; 680 bound_ = true;
671 needs_resize_ = false; 681 needs_resize_ = false;
672 } 682 }
673 return true; 683 return true;
674 } 684 }
675 685
676 void GLXImageTransportSurface::SendBuffersSwapped() { 686 void GLXImageTransportSurface::SendBuffersSwapped() {
677 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; 687 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
678 params.surface_handle = window_; 688 params.surface_handle = window_;
679 helper_->SendAcceleratedSurfaceBuffersSwapped(params); 689 helper_->SendAcceleratedSurfaceBuffersSwapped(params);
680 helper_->SetScheduled(false); 690 helper_->SetScheduled(false);
681 } 691 }
682 692
683 bool GLXImageTransportSurface::PostSubBuffer( 693 bool GLXImageTransportSurface::PostSubBuffer(
684 int x, int y, int width, int height) { 694 int x, int y, int width, int height) {
695 DCHECK(backbuffer_suggested_allocation_);
696 DCHECK(frontbuffer_suggested_allocation_);
685 gfx::NativeViewGLSurfaceGLX::PostSubBuffer(x, y, width, height); 697 gfx::NativeViewGLSurfaceGLX::PostSubBuffer(x, y, width, height);
686 helper_->DeferToFence(base::Bind( 698 helper_->DeferToFence(base::Bind(
687 &GLXImageTransportSurface::SendPostSubBuffer, 699 &GLXImageTransportSurface::SendPostSubBuffer,
688 AsWeakPtr(), x, y, width, height)); 700 AsWeakPtr(), x, y, width, height));
689 701
690 if (needs_resize_) { 702 if (needs_resize_) {
691 GpuHostMsg_AcceleratedSurfaceNew_Params params; 703 GpuHostMsg_AcceleratedSurfaceNew_Params params;
692 params.width = size_.width(); 704 params.width = size_.width();
693 params.height = size_.height(); 705 params.height = size_.height();
694 params.surface_handle = window_; 706 params.surface_handle = window_;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 stub, 951 stub,
940 surface.get(), 952 surface.get(),
941 handle.transport); 953 handle.transport);
942 } 954 }
943 955
944 if (surface->Initialize()) 956 if (surface->Initialize())
945 return surface; 957 return surface;
946 else 958 else
947 return NULL; 959 return NULL;
948 } 960 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698