OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_iosurface_mac.h" | 5 #include "content/common/gpu/image_transport_surface_iosurface_mac.h" |
6 | 6 |
7 #include "content/common/gpu/gpu_messages.h" | 7 #include "content/common/gpu/gpu_messages.h" |
8 #include "content/common/gpu/surface_handle_types_mac.h" | 8 #include "content/common/gpu/surface_handle_types_mac.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
(...skipping 22 matching lines...) Expand all Loading... |
33 void AddIntegerValue(CFMutableDictionaryRef dictionary, | 33 void AddIntegerValue(CFMutableDictionaryRef dictionary, |
34 const CFStringRef key, | 34 const CFStringRef key, |
35 int32 value) { | 35 int32 value) { |
36 base::ScopedCFTypeRef<CFNumberRef> number( | 36 base::ScopedCFTypeRef<CFNumberRef> number( |
37 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); | 37 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); |
38 CFDictionaryAddValue(dictionary, key, number.get()); | 38 CFDictionaryAddValue(dictionary, key, number.get()); |
39 } | 39 } |
40 | 40 |
41 } // namespace | 41 } // namespace |
42 | 42 |
43 IOSurfaceStorageProvider::IOSurfaceStorageProvider() {} | 43 IOSurfaceStorageProvider::IOSurfaceStorageProvider( |
| 44 ImageTransportSurfaceFBO* transport_surface) |
| 45 : transport_surface_(transport_surface) {} |
44 | 46 |
45 IOSurfaceStorageProvider::~IOSurfaceStorageProvider() { | 47 IOSurfaceStorageProvider::~IOSurfaceStorageProvider() { |
46 DCHECK(!io_surface_); | 48 DCHECK(!io_surface_); |
47 } | 49 } |
48 | 50 |
49 gfx::Size IOSurfaceStorageProvider::GetRoundedSize(gfx::Size size) { | 51 gfx::Size IOSurfaceStorageProvider::GetRoundedSize(gfx::Size size) { |
50 return gfx::Size(RoundUpSurfaceDimension(size.width()), | 52 return gfx::Size(RoundUpSurfaceDimension(size.width()), |
51 RoundUpSurfaceDimension(size.height())); | 53 RoundUpSurfaceDimension(size.height())); |
52 } | 54 } |
53 | 55 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 void IOSurfaceStorageProvider::FreeColorBufferStorage() { | 103 void IOSurfaceStorageProvider::FreeColorBufferStorage() { |
102 io_surface_.reset(); | 104 io_surface_.reset(); |
103 io_surface_id_ = 0; | 105 io_surface_id_ = 0; |
104 } | 106 } |
105 | 107 |
106 uint64 IOSurfaceStorageProvider::GetSurfaceHandle() const { | 108 uint64 IOSurfaceStorageProvider::GetSurfaceHandle() const { |
107 return SurfaceHandleFromIOSurfaceID(io_surface_id_); | 109 return SurfaceHandleFromIOSurfaceID(io_surface_id_); |
108 } | 110 } |
109 | 111 |
110 void IOSurfaceStorageProvider::WillSwapBuffers() { | 112 void IOSurfaceStorageProvider::WillSwapBuffers() { |
| 113 // The browser compositor will throttle itself, so we are free to unblock the |
| 114 // context immediately. Make sure that the browser is doing its throttling |
| 115 // appropriately by ensuring that the previous swap was acknowledged before |
| 116 // we get another swap. |
| 117 DCHECK(pending_swapped_surfaces_.empty()); |
| 118 pending_swapped_surfaces_.push_back(io_surface_); |
| 119 transport_surface_->UnblockContextAfterPendingSwap(); |
| 120 } |
| 121 |
| 122 void IOSurfaceStorageProvider::CanFreeSwappedBuffer() { |
| 123 DCHECK(!pending_swapped_surfaces_.empty()); |
| 124 pending_swapped_surfaces_.pop_front(); |
111 } | 125 } |
112 | 126 |
113 } // namespace content | 127 } // namespace content |
OLD | NEW |