| 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 #include "content/common/gpu/image_transport_surface.h" | 5 #include "content/common/gpu/image_transport_surface.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_cftyperef.h" | 7 #include "base/mac/scoped_cftyperef.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/common/gpu/gpu_messages.h" | 9 #include "content/common/gpu/gpu_messages.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 53 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
| 54 virtual bool SetBackbufferAllocation(bool allocated) OVERRIDE; | 54 virtual bool SetBackbufferAllocation(bool allocated) OVERRIDE; |
| 55 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; | 55 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 // ImageTransportSurface implementation | 58 // ImageTransportSurface implementation |
| 59 virtual void OnBufferPresented( | 59 virtual void OnBufferPresented( |
| 60 const AcceleratedSurfaceMsg_BufferPresented_Params& params) OVERRIDE; | 60 const AcceleratedSurfaceMsg_BufferPresented_Params& params) OVERRIDE; |
| 61 virtual void OnResizeViewACK() OVERRIDE; | 61 virtual void OnResizeViewACK() OVERRIDE; |
| 62 virtual void OnResize(gfx::Size size) OVERRIDE; | 62 virtual void OnResize(gfx::Size size) OVERRIDE; |
| 63 virtual void SetLatencyInfo(const cc::LatencyInfo&) OVERRIDE; | 63 virtual void SetLatencyInfo(const ui::LatencyInfo&) OVERRIDE; |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 virtual ~IOSurfaceImageTransportSurface() OVERRIDE; | 66 virtual ~IOSurfaceImageTransportSurface() OVERRIDE; |
| 67 | 67 |
| 68 void AdjustBufferAllocation(); | 68 void AdjustBufferAllocation(); |
| 69 void UnrefIOSurface(); | 69 void UnrefIOSurface(); |
| 70 void CreateIOSurface(); | 70 void CreateIOSurface(); |
| 71 | 71 |
| 72 // Tracks the current buffer allocation state. | 72 // Tracks the current buffer allocation state. |
| 73 bool backbuffer_suggested_allocation_; | 73 bool backbuffer_suggested_allocation_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 89 | 89 |
| 90 // Whether or not we've successfully made the surface current once. | 90 // Whether or not we've successfully made the surface current once. |
| 91 bool made_current_; | 91 bool made_current_; |
| 92 | 92 |
| 93 // Whether a SwapBuffers is pending. | 93 // Whether a SwapBuffers is pending. |
| 94 bool is_swap_buffers_pending_; | 94 bool is_swap_buffers_pending_; |
| 95 | 95 |
| 96 // Whether we unscheduled command buffer because of pending SwapBuffers. | 96 // Whether we unscheduled command buffer because of pending SwapBuffers. |
| 97 bool did_unschedule_; | 97 bool did_unschedule_; |
| 98 | 98 |
| 99 cc::LatencyInfo latency_info_; | 99 ui::LatencyInfo latency_info_; |
| 100 | 100 |
| 101 scoped_ptr<ImageTransportHelper> helper_; | 101 scoped_ptr<ImageTransportHelper> helper_; |
| 102 | 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(IOSurfaceImageTransportSurface); | 103 DISALLOW_COPY_AND_ASSIGN(IOSurfaceImageTransportSurface); |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 void AddBooleanValue(CFMutableDictionaryRef dictionary, | 106 void AddBooleanValue(CFMutableDictionaryRef dictionary, |
| 107 const CFStringRef key, | 107 const CFStringRef key, |
| 108 bool value) { | 108 bool value) { |
| 109 CFDictionaryAddValue(dictionary, key, | 109 CFDictionaryAddValue(dictionary, key, |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 "old_width", size_.width(), "new_width", size.width()); | 296 "old_width", size_.width(), "new_width", size.width()); |
| 297 // Caching |context_| from OnMakeCurrent. It should still be current. | 297 // Caching |context_| from OnMakeCurrent. It should still be current. |
| 298 DCHECK(context_->IsCurrent(this)); | 298 DCHECK(context_->IsCurrent(this)); |
| 299 | 299 |
| 300 size_ = size; | 300 size_ = size; |
| 301 | 301 |
| 302 CreateIOSurface(); | 302 CreateIOSurface(); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void IOSurfaceImageTransportSurface::SetLatencyInfo( | 305 void IOSurfaceImageTransportSurface::SetLatencyInfo( |
| 306 const cc::LatencyInfo& latency_info) { | 306 const ui::LatencyInfo& latency_info) { |
| 307 latency_info_ = latency_info; | 307 latency_info_ = latency_info; |
| 308 } | 308 } |
| 309 | 309 |
| 310 void IOSurfaceImageTransportSurface::UnrefIOSurface() { | 310 void IOSurfaceImageTransportSurface::UnrefIOSurface() { |
| 311 // If we have resources to destroy, then make sure that we have a current | 311 // If we have resources to destroy, then make sure that we have a current |
| 312 // context which we can use to delete the resources. | 312 // context which we can use to delete the resources. |
| 313 if (context_ || fbo_id_ || texture_id_) { | 313 if (context_ || fbo_id_ || texture_id_) { |
| 314 DCHECK(gfx::GLContext::GetCurrent() == context_); | 314 DCHECK(gfx::GLContext::GetCurrent() == context_); |
| 315 DCHECK(context_->IsCurrent(this)); | 315 DCHECK(context_->IsCurrent(this)); |
| 316 DCHECK(CGLGetCurrentContext()); | 316 DCHECK(CGLGetCurrentContext()); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 manager, stub, surface.get(), false)); | 478 manager, stub, surface.get(), false)); |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 | 481 |
| 482 // static | 482 // static |
| 483 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) { | 483 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) { |
| 484 g_allow_os_mesa = allow; | 484 g_allow_os_mesa = allow; |
| 485 } | 485 } |
| 486 | 486 |
| 487 } // namespace content | 487 } // namespace content |
| OLD | NEW |