| 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 "ui/ozone/platform/dri/gbm_surface.h" | 5 #include "ui/ozone/platform/dri/gbm_surface.h" |
| 6 | 6 |
| 7 #include <gbm.h> | 7 #include <gbm.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/ozone/platform/dri/dri_buffer.h" | 10 #include "ui/ozone/platform/dri/dri_buffer.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 return false; | 129 return false; |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool GbmSurface::OnSwapBuffers() { | 132 bool GbmSurface::OnSwapBuffers() { |
| 133 DCHECK(native_surface_); | 133 DCHECK(native_surface_); |
| 134 | 134 |
| 135 gbm_bo* pending_buffer = gbm_surface_lock_front_buffer(native_surface_); | 135 gbm_bo* pending_buffer = gbm_surface_lock_front_buffer(native_surface_); |
| 136 scoped_refptr<GbmSurfaceBuffer> primary = | 136 scoped_refptr<GbmSurfaceBuffer> primary = |
| 137 GbmSurfaceBuffer::GetBuffer(pending_buffer); | 137 GbmSurfaceBuffer::GetBuffer(pending_buffer); |
| 138 if (!primary) { | 138 if (!primary.get()) { |
| 139 primary = GbmSurfaceBuffer::CreateBuffer(dri_, pending_buffer); | 139 primary = GbmSurfaceBuffer::CreateBuffer(dri_, pending_buffer); |
| 140 if (!primary) { | 140 if (!primary.get()) { |
| 141 LOG(ERROR) << "Failed to associate the buffer with the controller"; | 141 LOG(ERROR) << "Failed to associate the buffer with the controller"; |
| 142 return false; | 142 return false; |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 | 145 |
| 146 // The primary buffer is a special case. | 146 // The primary buffer is a special case. |
| 147 if (window_delegate_->GetController()) | 147 if (window_delegate_->GetController()) |
| 148 window_delegate_->GetController()->QueueOverlayPlane(OverlayPlane(primary)); | 148 window_delegate_->GetController()->QueueOverlayPlane(OverlayPlane(primary)); |
| 149 | 149 |
| 150 if (!GbmSurfaceless::OnSwapBuffers()) | 150 if (!GbmSurfaceless::OnSwapBuffers()) |
| 151 return false; | 151 return false; |
| 152 | 152 |
| 153 // If there was a frontbuffer, it is no longer active. Release it back to GBM. | 153 // If there was a frontbuffer, it is no longer active. Release it back to GBM. |
| 154 if (current_buffer_) | 154 if (current_buffer_) |
| 155 gbm_surface_release_buffer(native_surface_, current_buffer_); | 155 gbm_surface_release_buffer(native_surface_, current_buffer_); |
| 156 | 156 |
| 157 current_buffer_ = pending_buffer; | 157 current_buffer_ = pending_buffer; |
| 158 return true; | 158 return true; |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace ui | 161 } // namespace ui |
| OLD | NEW |