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

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

Issue 9192014: Replace WGC3D visibility extension with resource_usage extension. [Part 2 of 3] (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Clarifying a comment 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
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 // This conflicts with the defines in Xlib.h and must come first. 9 // This conflicts with the defines in Xlib.h and must come first.
10 #include "content/common/gpu/gpu_messages.h" 10 #include "content/common/gpu/gpu_messages.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // gfx::GLSurface implementation 68 // gfx::GLSurface implementation
69 virtual bool Initialize() OVERRIDE; 69 virtual bool Initialize() OVERRIDE;
70 virtual void Destroy() OVERRIDE; 70 virtual void Destroy() OVERRIDE;
71 virtual bool IsOffscreen() OVERRIDE; 71 virtual bool IsOffscreen() OVERRIDE;
72 virtual bool SwapBuffers() OVERRIDE; 72 virtual bool SwapBuffers() OVERRIDE;
73 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; 73 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
74 virtual std::string GetExtensions() OVERRIDE; 74 virtual std::string GetExtensions() OVERRIDE;
75 virtual gfx::Size GetSize() OVERRIDE; 75 virtual gfx::Size GetSize() OVERRIDE;
76 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; 76 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
77 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; 77 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE;
78 virtual void SetVisible(bool visible) OVERRIDE; 78 virtual void SetResourceUsage(ResourceUsage resourceUsage) OVERRIDE;
79 79
80 protected: 80 protected:
81 // ImageTransportSurface implementation 81 // ImageTransportSurface implementation
82 virtual void OnNewSurfaceACK( 82 virtual void OnNewSurfaceACK(
83 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; 83 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE;
84 virtual void OnBuffersSwappedACK() OVERRIDE; 84 virtual void OnBuffersSwappedACK() OVERRIDE;
85 virtual void OnPostSubBufferACK() OVERRIDE; 85 virtual void OnPostSubBufferACK() OVERRIDE;
86 virtual void OnResizeViewACK() OVERRIDE; 86 virtual void OnResizeViewACK() OVERRIDE;
87 virtual void OnResize(gfx::Size size) OVERRIDE; 87 virtual void OnResize(gfx::Size size) OVERRIDE;
88 88
(...skipping 28 matching lines...) Expand all
117 int32 command_buffer_id); 117 int32 command_buffer_id);
118 118
119 // gfx::GLSurface implementation: 119 // gfx::GLSurface implementation:
120 virtual bool Initialize() OVERRIDE; 120 virtual bool Initialize() OVERRIDE;
121 virtual void Destroy() OVERRIDE; 121 virtual void Destroy() OVERRIDE;
122 virtual bool SwapBuffers() OVERRIDE; 122 virtual bool SwapBuffers() OVERRIDE;
123 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; 123 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
124 virtual std::string GetExtensions(); 124 virtual std::string GetExtensions();
125 virtual gfx::Size GetSize() OVERRIDE; 125 virtual gfx::Size GetSize() OVERRIDE;
126 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; 126 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
127 virtual void SetVisible(bool visible) OVERRIDE; 127 virtual void SetResourceUsage(ResourceUsage resourceUsage) OVERRIDE;
128 128
129 protected: 129 protected:
130 // ImageTransportSurface implementation: 130 // ImageTransportSurface implementation:
131 virtual void OnNewSurfaceACK( 131 virtual void OnNewSurfaceACK(
132 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; 132 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE;
133 virtual void OnBuffersSwappedACK() OVERRIDE; 133 virtual void OnBuffersSwappedACK() OVERRIDE;
134 virtual void OnPostSubBufferACK() OVERRIDE; 134 virtual void OnPostSubBufferACK() OVERRIDE;
135 virtual void OnResizeViewACK() OVERRIDE; 135 virtual void OnResizeViewACK() OVERRIDE;
136 virtual void OnResize(gfx::Size size) OVERRIDE; 136 virtual void OnResize(gfx::Size size) OVERRIDE;
137 137
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 305 }
306 306
307 made_current_ = true; 307 made_current_ = true;
308 return true; 308 return true;
309 } 309 }
310 310
311 unsigned int EGLImageTransportSurface::GetBackingFrameBufferObject() { 311 unsigned int EGLImageTransportSurface::GetBackingFrameBufferObject() {
312 return fbo_id_; 312 return fbo_id_;
313 } 313 }
314 314
315 void EGLImageTransportSurface::SetVisible(bool visible) { 315 void EGLImageTransportSurface::SetResourceUsage(ResourceUsage resourceUsage) {
316 if (!visible && back_surface_.get() && front_surface_.get()) { 316 switch (resourceUsage) {
317 ReleaseSurface(&back_surface_); 317 case RESOURCE_USAGE_FULL:
318 } else if (visible && !back_surface_.get() && front_surface_.get()) { 318 if (!back_surface_.get() && front_surface_.get()) {
319 // Leverage the OnResize hook because it does exactly what we want 319 // Leverage the OnResize hook because it does exactly what we want
320 OnResize(front_surface_->size()); 320 OnResize(front_surface_->size());
321 }
322 break;
323 case RESOURCE_USAGE_LESS:
324 if (back_surface_.get() && front_surface_.get())
325 ReleaseSurface(&back_surface_);
326 break;
327 case RESOURCE_USAGE_NONE:
328 // TODO(mmocny): drop all the buffers
329 break;
321 } 330 }
322 } 331 }
323 332
324 void EGLImageTransportSurface::ReleaseSurface( 333 void EGLImageTransportSurface::ReleaseSurface(
325 scoped_refptr<EGLAcceleratedSurface>* surface) { 334 scoped_refptr<EGLAcceleratedSurface>* surface) {
326 if (surface->get()) { 335 if (surface->get()) {
327 GpuHostMsg_AcceleratedSurfaceRelease_Params params; 336 GpuHostMsg_AcceleratedSurfaceRelease_Params params;
328 params.identifier = (*surface)->pixmap(); 337 params.identifier = (*surface)->pixmap();
329 helper_->SendAcceleratedSurfaceRelease(params); 338 helper_->SendAcceleratedSurfaceRelease(params);
330 *surface = NULL; 339 *surface = NULL;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 } 511 }
503 512
504 void GLXImageTransportSurface::ReleaseSurface() { 513 void GLXImageTransportSurface::ReleaseSurface() {
505 DCHECK(bound_); 514 DCHECK(bound_);
506 GpuHostMsg_AcceleratedSurfaceRelease_Params params; 515 GpuHostMsg_AcceleratedSurfaceRelease_Params params;
507 params.identifier = window_; 516 params.identifier = window_;
508 helper_->SendAcceleratedSurfaceRelease(params); 517 helper_->SendAcceleratedSurfaceRelease(params);
509 bound_ = false; 518 bound_ = false;
510 } 519 }
511 520
512 void GLXImageTransportSurface::SetVisible(bool visible) { 521 void GLXImageTransportSurface::SetResourceUsage(ResourceUsage resourceUsage) {
513 Display* dpy = static_cast<Display*>(GetDisplay()); 522 Display* dpy = static_cast<Display*>(GetDisplay());
514 if (!visible) { 523 switch (resourceUsage) {
515 XResizeWindow(dpy, window_, 1, 1); 524 case RESOURCE_USAGE_FULL:
516 } else { 525 XResizeWindow(dpy, window_, size_.width(), size_.height());
517 XResizeWindow(dpy, window_, size_.width(), size_.height()); 526 needs_resize_ = true;
518 needs_resize_ = true; 527 break;
528 case RESOURCE_USAGE_LESS:
529 XResizeWindow(dpy, window_, 1, 1);
530 break;
531 case RESOURCE_USAGE_NONE:
532 // TODO(mmocny): drop all the buffers
533 break;
519 } 534 }
520 glXWaitX(); 535 glXWaitX();
521 } 536 }
522 537
523 void GLXImageTransportSurface::OnResize(gfx::Size size) { 538 void GLXImageTransportSurface::OnResize(gfx::Size size) {
524 TRACE_EVENT0("gpu", "GLXImageTransportSurface::OnResize"); 539 TRACE_EVENT0("gpu", "GLXImageTransportSurface::OnResize");
525 size_ = size; 540 size_ = size;
526 541
527 Display* dpy = static_cast<Display*>(GetDisplay()); 542 Display* dpy = static_cast<Display*>(GetDisplay());
528 XResizeWindow(dpy, window_, size_.width(), size_.height()); 543 XResizeWindow(dpy, window_, size_.width(), size_.height());
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 command_buffer_id, 848 command_buffer_id,
834 surface.get()); 849 surface.get());
835 #endif 850 #endif
836 if (surface->Initialize()) 851 if (surface->Initialize())
837 return surface; 852 return surface;
838 else 853 else
839 return NULL; 854 return NULL;
840 } 855 }
841 856
842 #endif // defined(USE_GPU) 857 #endif // defined(USE_GPU)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698