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

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: Added image_transport_surface_win changes 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
« no previous file with comments | « content/common/gpu/gpu_messages.h ('k') | content/common/gpu/image_transport_surface_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // gfx::GLSurface implementation 82 // gfx::GLSurface implementation
83 virtual bool Initialize() OVERRIDE; 83 virtual bool Initialize() OVERRIDE;
84 virtual void Destroy() OVERRIDE; 84 virtual void Destroy() OVERRIDE;
85 virtual bool IsOffscreen() OVERRIDE; 85 virtual bool IsOffscreen() OVERRIDE;
86 virtual bool SwapBuffers() OVERRIDE; 86 virtual bool SwapBuffers() OVERRIDE;
87 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; 87 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
88 virtual std::string GetExtensions() OVERRIDE; 88 virtual std::string GetExtensions() OVERRIDE;
89 virtual gfx::Size GetSize() OVERRIDE; 89 virtual gfx::Size GetSize() OVERRIDE;
90 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; 90 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
91 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; 91 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE;
92 virtual void SetVisible(bool visible) OVERRIDE; 92 virtual void SetResourceUsage(ResourceUsage resourceUsage) OVERRIDE;
93 93
94 protected: 94 protected:
95 // ImageTransportSurface implementation 95 // ImageTransportSurface implementation
96 virtual void OnNewSurfaceACK( 96 virtual void OnNewSurfaceACK(
97 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; 97 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE;
98 virtual void OnBuffersSwappedACK() OVERRIDE; 98 virtual void OnBuffersSwappedACK() OVERRIDE;
99 virtual void OnPostSubBufferACK() OVERRIDE; 99 virtual void OnPostSubBufferACK() OVERRIDE;
100 virtual void OnResizeViewACK() OVERRIDE; 100 virtual void OnResizeViewACK() OVERRIDE;
101 virtual void OnResize(gfx::Size size) OVERRIDE; 101 virtual void OnResize(gfx::Size size) OVERRIDE;
102 102
(...skipping 26 matching lines...) Expand all
129 GpuCommandBufferStub* stub); 129 GpuCommandBufferStub* stub);
130 130
131 // gfx::GLSurface implementation: 131 // gfx::GLSurface implementation:
132 virtual bool Initialize() OVERRIDE; 132 virtual bool Initialize() OVERRIDE;
133 virtual void Destroy() OVERRIDE; 133 virtual void Destroy() OVERRIDE;
134 virtual bool SwapBuffers() OVERRIDE; 134 virtual bool SwapBuffers() OVERRIDE;
135 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; 135 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
136 virtual std::string GetExtensions(); 136 virtual std::string GetExtensions();
137 virtual gfx::Size GetSize() OVERRIDE; 137 virtual gfx::Size GetSize() OVERRIDE;
138 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; 138 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
139 virtual void SetVisible(bool visible) OVERRIDE; 139 virtual void SetResourceUsage(ResourceUsage resourceUsage) OVERRIDE;
140 140
141 protected: 141 protected:
142 // ImageTransportSurface implementation: 142 // ImageTransportSurface implementation:
143 virtual void OnNewSurfaceACK( 143 virtual void OnNewSurfaceACK(
144 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; 144 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE;
145 virtual void OnBuffersSwappedACK() OVERRIDE; 145 virtual void OnBuffersSwappedACK() OVERRIDE;
146 virtual void OnPostSubBufferACK() OVERRIDE; 146 virtual void OnPostSubBufferACK() OVERRIDE;
147 virtual void OnResizeViewACK() OVERRIDE; 147 virtual void OnResizeViewACK() OVERRIDE;
148 virtual void OnResize(gfx::Size size) OVERRIDE; 148 virtual void OnResize(gfx::Size size) OVERRIDE;
149 149
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 311 }
312 312
313 made_current_ = true; 313 made_current_ = true;
314 return true; 314 return true;
315 } 315 }
316 316
317 unsigned int EGLImageTransportSurface::GetBackingFrameBufferObject() { 317 unsigned int EGLImageTransportSurface::GetBackingFrameBufferObject() {
318 return fbo_id_; 318 return fbo_id_;
319 } 319 }
320 320
321 void EGLImageTransportSurface::SetVisible(bool visible) { 321 void EGLImageTransportSurface::SetResourceUsage(ResourceUsage resourceUsage) {
322 if (!visible && back_surface_.get() && front_surface_.get()) { 322 switch (resourceUsage) {
323 ReleaseSurface(&back_surface_); 323 case RESOURCE_USAGE_FULL:
324 } else if (visible && !back_surface_.get() && front_surface_.get()) { 324 if (!back_surface_.get() && front_surface_.get()) {
325 // Leverage the OnResize hook because it does exactly what we want 325 // Leverage the OnResize hook because it does exactly what we want
326 OnResize(front_surface_->size()); 326 OnResize(front_surface_->size());
327 }
328 break;
329 case RESOURCE_USAGE_LESS:
330 if (back_surface_.get() && front_surface_.get())
331 ReleaseSurface(&back_surface_);
332 break;
333 case RESOURCE_USAGE_NONE:
334 // TODO(mmocny): drop all the buffers
335 break;
327 } 336 }
328 } 337 }
329 338
330 void EGLImageTransportSurface::ReleaseSurface( 339 void EGLImageTransportSurface::ReleaseSurface(
331 scoped_refptr<EGLAcceleratedSurface>* surface) { 340 scoped_refptr<EGLAcceleratedSurface>* surface) {
332 if (surface->get()) { 341 if (surface->get()) {
333 GpuHostMsg_AcceleratedSurfaceRelease_Params params; 342 GpuHostMsg_AcceleratedSurfaceRelease_Params params;
334 params.identifier = (*surface)->pixmap(); 343 params.identifier = (*surface)->pixmap();
335 helper_->SendAcceleratedSurfaceRelease(params); 344 helper_->SendAcceleratedSurfaceRelease(params);
336 *surface = NULL; 345 *surface = NULL;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 } 516 }
508 517
509 void GLXImageTransportSurface::ReleaseSurface() { 518 void GLXImageTransportSurface::ReleaseSurface() {
510 DCHECK(bound_); 519 DCHECK(bound_);
511 GpuHostMsg_AcceleratedSurfaceRelease_Params params; 520 GpuHostMsg_AcceleratedSurfaceRelease_Params params;
512 params.identifier = window_; 521 params.identifier = window_;
513 helper_->SendAcceleratedSurfaceRelease(params); 522 helper_->SendAcceleratedSurfaceRelease(params);
514 bound_ = false; 523 bound_ = false;
515 } 524 }
516 525
517 void GLXImageTransportSurface::SetVisible(bool visible) { 526 void GLXImageTransportSurface::SetResourceUsage(ResourceUsage resourceUsage) {
518 Display* dpy = static_cast<Display*>(GetDisplay()); 527 Display* dpy = static_cast<Display*>(GetDisplay());
519 if (!visible) { 528 switch (resourceUsage) {
520 XResizeWindow(dpy, window_, 1, 1); 529 case RESOURCE_USAGE_FULL:
521 } else { 530 XResizeWindow(dpy, window_, size_.width(), size_.height());
522 XResizeWindow(dpy, window_, size_.width(), size_.height()); 531 needs_resize_ = true;
523 needs_resize_ = true; 532 break;
533 case RESOURCE_USAGE_LESS:
534 XResizeWindow(dpy, window_, 1, 1);
535 break;
536 case RESOURCE_USAGE_NONE:
537 // TODO(mmocny): drop all the buffers
538 break;
524 } 539 }
525 glXWaitX(); 540 glXWaitX();
526 } 541 }
527 542
528 void GLXImageTransportSurface::OnResize(gfx::Size size) { 543 void GLXImageTransportSurface::OnResize(gfx::Size size) {
529 TRACE_EVENT0("gpu", "GLXImageTransportSurface::OnResize"); 544 TRACE_EVENT0("gpu", "GLXImageTransportSurface::OnResize");
530 size_ = size; 545 size_ = size;
531 546
532 Display* dpy = static_cast<Display*>(GetDisplay()); 547 Display* dpy = static_cast<Display*>(GetDisplay());
533 XResizeWindow(dpy, window_, size_.width(), size_.height()); 548 XResizeWindow(dpy, window_, size_.width(), size_.height());
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 834
820 surface = new PassThroughImageTransportSurface(manager, stub, surface.get()); 835 surface = new PassThroughImageTransportSurface(manager, stub, surface.get());
821 #endif 836 #endif
822 if (surface->Initialize()) 837 if (surface->Initialize())
823 return surface; 838 return surface;
824 else 839 else
825 return NULL; 840 return NULL;
826 } 841 }
827 842
828 #endif // defined(USE_GPU) 843 #endif // defined(USE_GPU)
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_messages.h ('k') | content/common/gpu/image_transport_surface_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698