| 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/bind.h" | 9 #include "base/bind.h" | 
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 33   PbufferImageTransportSurface(GpuChannelManager* manager, | 33   PbufferImageTransportSurface(GpuChannelManager* manager, | 
| 34                                GpuCommandBufferStub* stub); | 34                                GpuCommandBufferStub* stub); | 
| 35 | 35 | 
| 36   // gfx::GLSurface implementation | 36   // gfx::GLSurface implementation | 
| 37   virtual bool Initialize() OVERRIDE; | 37   virtual bool Initialize() OVERRIDE; | 
| 38   virtual void Destroy() OVERRIDE; | 38   virtual void Destroy() OVERRIDE; | 
| 39   virtual bool IsOffscreen() OVERRIDE; | 39   virtual bool IsOffscreen() OVERRIDE; | 
| 40   virtual bool SwapBuffers() OVERRIDE; | 40   virtual bool SwapBuffers() OVERRIDE; | 
| 41   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; | 
| 42   virtual std::string GetExtensions() OVERRIDE; | 42   virtual std::string GetExtensions() OVERRIDE; | 
| 43   virtual void SetVisible(bool visible) OVERRIDE; | 43   virtual void SetResourceUsage(ResourceUsage resourceUsage) OVERRIDE; | 
| 44 | 44 | 
| 45  protected: | 45  protected: | 
| 46   // ImageTransportSurface implementation | 46   // ImageTransportSurface implementation | 
| 47   virtual void OnNewSurfaceACK(uint64 surface_handle, | 47   virtual void OnNewSurfaceACK(uint64 surface_handle, | 
| 48                                TransportDIB::Handle shm_handle) OVERRIDE; | 48                                TransportDIB::Handle shm_handle) OVERRIDE; | 
| 49   virtual void OnBuffersSwappedACK() OVERRIDE; | 49   virtual void OnBuffersSwappedACK() OVERRIDE; | 
| 50   virtual void OnPostSubBufferACK() OVERRIDE; | 50   virtual void OnPostSubBufferACK() OVERRIDE; | 
| 51   virtual void OnResizeViewACK() OVERRIDE; | 51   virtual void OnResizeViewACK() OVERRIDE; | 
| 52   virtual void OnResize(gfx::Size size) OVERRIDE; | 52   virtual void OnResize(gfx::Size size) OVERRIDE; | 
| 53 | 53 | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 114 | 114 | 
| 115   return true; | 115   return true; | 
| 116 } | 116 } | 
| 117 | 117 | 
| 118 bool PbufferImageTransportSurface::PostSubBuffer( | 118 bool PbufferImageTransportSurface::PostSubBuffer( | 
| 119     int x, int y, int width, int height) { | 119     int x, int y, int width, int height) { | 
| 120   NOTREACHED(); | 120   NOTREACHED(); | 
| 121   return false; | 121   return false; | 
| 122 } | 122 } | 
| 123 | 123 | 
| 124 void PbufferImageTransportSurface::SetVisible(bool visible) { | 124 void PbufferImageTransportSurface::SetResourceUsage( | 
| 125   if (visible == is_visible_) | 125     ResourceUsage resourceUsage) { | 
| 126     return; | 126   switch (resourceUsage) { | 
| 127 | 127     case RESOURCE_USAGE_FULL: | 
| 128   is_visible_ = visible; | 128       Resize(visible_size_); | 
| 129 | 129       is_visible_ = true; | 
| 130   if (visible) | 130       break; | 
| 131     Resize(visible_size_); | 131     case RESOURCE_USAGE_LESS: | 
| 132   else | 132       Resize(gfx::Size(1, 1)); | 
| 133     Resize(gfx::Size(1, 1)); | 133       is_visible_ = false; | 
|  | 134       break; | 
|  | 135     case RESOURCE_USAGE_NONE: | 
|  | 136       // TODO(mmocny): drop all the buffers | 
|  | 137       break; | 
|  | 138   } | 
| 134 } | 139 } | 
| 135 | 140 | 
| 136 std::string PbufferImageTransportSurface::GetExtensions() { | 141 std::string PbufferImageTransportSurface::GetExtensions() { | 
| 137   std::string extensions = gfx::GLSurface::GetExtensions(); | 142   std::string extensions = gfx::GLSurface::GetExtensions(); | 
| 138   extensions += extensions.empty() ? "" : " "; | 143   extensions += extensions.empty() ? "" : " "; | 
| 139   extensions += "GL_CHROMIUM_front_buffer_cached"; | 144   extensions += "GL_CHROMIUM_front_buffer_cached"; | 
| 140   return extensions; | 145   return extensions; | 
| 141 } | 146 } | 
| 142 | 147 | 
| 143 void PbufferImageTransportSurface::SendBuffersSwapped() { | 148 void PbufferImageTransportSurface::SendBuffersSwapped() { | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 204                                                    surface.get()); | 209                                                    surface.get()); | 
| 205   } | 210   } | 
| 206 | 211 | 
| 207   if (surface->Initialize()) | 212   if (surface->Initialize()) | 
| 208     return surface; | 213     return surface; | 
| 209   else | 214   else | 
| 210     return NULL; | 215     return NULL; | 
| 211 } | 216 } | 
| 212 | 217 | 
| 213 #endif  // ENABLE_GPU | 218 #endif  // ENABLE_GPU | 
| OLD | NEW | 
|---|