| 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 "ui/accelerated_widget_mac/surface_handle_types.h" | 8 #include "ui/accelerated_widget_mac/surface_handle_types.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 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) | 44 ImageTransportSurfaceFBO* transport_surface) |
| 45 : transport_surface_(transport_surface) {} | 45 : transport_surface_(transport_surface), |
| 46 frame_scale_factor_(1) {} |
| 46 | 47 |
| 47 IOSurfaceStorageProvider::~IOSurfaceStorageProvider() { | 48 IOSurfaceStorageProvider::~IOSurfaceStorageProvider() { |
| 48 DCHECK(!io_surface_); | 49 DCHECK(!io_surface_); |
| 49 } | 50 } |
| 50 | 51 |
| 51 gfx::Size IOSurfaceStorageProvider::GetRoundedSize(gfx::Size size) { | 52 gfx::Size IOSurfaceStorageProvider::GetRoundedSize(gfx::Size size) { |
| 52 return gfx::Size(RoundUpSurfaceDimension(size.width()), | 53 return gfx::Size(RoundUpSurfaceDimension(size.width()), |
| 53 RoundUpSurfaceDimension(size.height())); | 54 RoundUpSurfaceDimension(size.height())); |
| 54 } | 55 } |
| 55 | 56 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 99 |
| 99 glFlush(); | 100 glFlush(); |
| 100 return true; | 101 return true; |
| 101 } | 102 } |
| 102 | 103 |
| 103 void IOSurfaceStorageProvider::FreeColorBufferStorage() { | 104 void IOSurfaceStorageProvider::FreeColorBufferStorage() { |
| 104 io_surface_.reset(); | 105 io_surface_.reset(); |
| 105 io_surface_id_ = 0; | 106 io_surface_id_ = 0; |
| 106 } | 107 } |
| 107 | 108 |
| 108 void IOSurfaceStorageProvider::SwapBuffers( | 109 void IOSurfaceStorageProvider::FrameSizeChanged(const gfx::Size& pixel_size, |
| 109 const gfx::Size& size, float scale_factor) { | 110 float scale_factor) { |
| 111 frame_pixel_size_ = pixel_size; |
| 112 frame_scale_factor_ = scale_factor; |
| 113 } |
| 114 |
| 115 void IOSurfaceStorageProvider::SwapBuffers() { |
| 110 // The browser compositor will throttle itself, so we are free to unblock the | 116 // The browser compositor will throttle itself, so we are free to unblock the |
| 111 // context immediately. Make sure that the browser is doing its throttling | 117 // context immediately. Make sure that the browser is doing its throttling |
| 112 // appropriately by ensuring that the previous swap was acknowledged before | 118 // appropriately by ensuring that the previous swap was acknowledged before |
| 113 // we get another swap. | 119 // we get another swap. |
| 114 DCHECK(pending_swapped_surfaces_.empty()); | 120 DCHECK(pending_swapped_surfaces_.empty()); |
| 115 pending_swapped_surfaces_.push_back(io_surface_); | 121 pending_swapped_surfaces_.push_back(io_surface_); |
| 116 | 122 |
| 117 transport_surface_->SendSwapBuffers( | 123 transport_surface_->SendSwapBuffers( |
| 118 ui::SurfaceHandleFromIOSurfaceID(io_surface_id_), size, scale_factor); | 124 ui::SurfaceHandleFromIOSurfaceID(io_surface_id_), |
| 125 frame_pixel_size_, |
| 126 frame_scale_factor_); |
| 119 } | 127 } |
| 120 | 128 |
| 121 void IOSurfaceStorageProvider::WillWriteToBackbuffer() { | 129 void IOSurfaceStorageProvider::WillWriteToBackbuffer() { |
| 122 } | 130 } |
| 123 | 131 |
| 124 void IOSurfaceStorageProvider::DiscardBackbuffer() { | 132 void IOSurfaceStorageProvider::DiscardBackbuffer() { |
| 125 } | 133 } |
| 126 | 134 |
| 127 void IOSurfaceStorageProvider::SwapBuffersAckedByBrowser( | 135 void IOSurfaceStorageProvider::SwapBuffersAckedByBrowser( |
| 128 bool disable_throttling) { | 136 bool disable_throttling) { |
| 129 DCHECK(!pending_swapped_surfaces_.empty()); | 137 DCHECK(!pending_swapped_surfaces_.empty()); |
| 130 pending_swapped_surfaces_.pop_front(); | 138 pending_swapped_surfaces_.pop_front(); |
| 131 } | 139 } |
| 132 | 140 |
| 133 } // namespace content | 141 } // namespace content |
| OLD | NEW |