| 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, float scale_factor) OVERRIDE; | 62 virtual void OnResize(gfx::Size size, float scale_factor) 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 16 matching lines...) Expand all Loading... |
| 90 | 90 |
| 91 // Whether or not we've successfully made the surface current once. | 91 // Whether or not we've successfully made the surface current once. |
| 92 bool made_current_; | 92 bool made_current_; |
| 93 | 93 |
| 94 // Whether a SwapBuffers is pending. | 94 // Whether a SwapBuffers is pending. |
| 95 bool is_swap_buffers_pending_; | 95 bool is_swap_buffers_pending_; |
| 96 | 96 |
| 97 // Whether we unscheduled command buffer because of pending SwapBuffers. | 97 // Whether we unscheduled command buffer because of pending SwapBuffers. |
| 98 bool did_unschedule_; | 98 bool did_unschedule_; |
| 99 | 99 |
| 100 cc::LatencyInfo latency_info_; | 100 ui::LatencyInfo latency_info_; |
| 101 | 101 |
| 102 scoped_ptr<ImageTransportHelper> helper_; | 102 scoped_ptr<ImageTransportHelper> helper_; |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(IOSurfaceImageTransportSurface); | 104 DISALLOW_COPY_AND_ASSIGN(IOSurfaceImageTransportSurface); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 void AddBooleanValue(CFMutableDictionaryRef dictionary, | 107 void AddBooleanValue(CFMutableDictionaryRef dictionary, |
| 108 const CFStringRef key, | 108 const CFStringRef key, |
| 109 bool value) { | 109 bool value) { |
| 110 CFDictionaryAddValue(dictionary, key, | 110 CFDictionaryAddValue(dictionary, key, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 // Caching |context_| from OnMakeCurrent. It should still be current. | 302 // Caching |context_| from OnMakeCurrent. It should still be current. |
| 303 DCHECK(context_->IsCurrent(this)); | 303 DCHECK(context_->IsCurrent(this)); |
| 304 | 304 |
| 305 size_ = size; | 305 size_ = size; |
| 306 scale_factor_ = scale_factor; | 306 scale_factor_ = scale_factor; |
| 307 | 307 |
| 308 CreateIOSurface(); | 308 CreateIOSurface(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 void IOSurfaceImageTransportSurface::SetLatencyInfo( | 311 void IOSurfaceImageTransportSurface::SetLatencyInfo( |
| 312 const cc::LatencyInfo& latency_info) { | 312 const ui::LatencyInfo& latency_info) { |
| 313 latency_info_ = latency_info; | 313 latency_info_ = latency_info; |
| 314 } | 314 } |
| 315 | 315 |
| 316 void IOSurfaceImageTransportSurface::UnrefIOSurface() { | 316 void IOSurfaceImageTransportSurface::UnrefIOSurface() { |
| 317 // If we have resources to destroy, then make sure that we have a current | 317 // If we have resources to destroy, then make sure that we have a current |
| 318 // context which we can use to delete the resources. | 318 // context which we can use to delete the resources. |
| 319 if (context_ || fbo_id_ || texture_id_) { | 319 if (context_ || fbo_id_ || texture_id_) { |
| 320 DCHECK(gfx::GLContext::GetCurrent() == context_); | 320 DCHECK(gfx::GLContext::GetCurrent() == context_); |
| 321 DCHECK(context_->IsCurrent(this)); | 321 DCHECK(context_->IsCurrent(this)); |
| 322 DCHECK(CGLGetCurrentContext()); | 322 DCHECK(CGLGetCurrentContext()); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 manager, stub, surface.get(), false)); | 484 manager, stub, surface.get(), false)); |
| 485 } | 485 } |
| 486 } | 486 } |
| 487 | 487 |
| 488 // static | 488 // static |
| 489 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) { | 489 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) { |
| 490 g_allow_os_mesa = allow; | 490 g_allow_os_mesa = allow; |
| 491 } | 491 } |
| 492 | 492 |
| 493 } // namespace content | 493 } // namespace content |
| OLD | NEW |