| 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/drm/gpu/gbm_buffer.h" | 5 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" |
| 6 | 6 |
| 7 #include <drm.h> | 7 #include <drm.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <gbm.h> | 9 #include <gbm.h> |
| 10 #include <xf86drm.h> | 10 #include <xf86drm.h> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 // static | 47 // static |
| 48 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( | 48 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( |
| 49 const scoped_refptr<GbmDevice>& gbm, | 49 const scoped_refptr<GbmDevice>& gbm, |
| 50 SurfaceFactoryOzone::BufferFormat format, | 50 SurfaceFactoryOzone::BufferFormat format, |
| 51 const gfx::Size& size, | 51 const gfx::Size& size, |
| 52 bool scanout) { | 52 bool scanout) { |
| 53 TRACE_EVENT2("drm", "GbmBuffer::CreateBuffer", "device", | 53 TRACE_EVENT2("drm", "GbmBuffer::CreateBuffer", "device", |
| 54 gbm->device_path().value(), "size", size.ToString()); | 54 gbm->device_path().value(), "size", size.ToString()); |
| 55 unsigned flags = GBM_BO_USE_RENDERING; | 55 unsigned flags = GBM_BO_USE_RENDERING; |
| 56 // GBM_BO_USE_SCANOUT is the hint of x-tiling. |
| 56 if (scanout) | 57 if (scanout) |
| 57 flags |= GBM_BO_USE_SCANOUT; | 58 flags |= GBM_BO_USE_SCANOUT; |
| 58 gbm_bo* bo = gbm_bo_create(gbm->device(), size.width(), size.height(), | 59 gbm_bo* bo = gbm_bo_create(gbm->device(), size.width(), size.height(), |
| 59 GetGbmFormatFromBufferFormat(format), flags); | 60 GetGbmFormatFromBufferFormat(format), flags); |
| 60 if (!bo) | 61 if (!bo) |
| 61 return NULL; | 62 return NULL; |
| 62 | 63 |
| 63 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, scanout)); | 64 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, scanout)); |
| 64 if (scanout && !buffer->GetFramebufferId()) | 65 if (scanout && !buffer->GetFramebufferId()) |
| 65 return NULL; | 66 return NULL; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 141 } |
| 141 | 142 |
| 142 gfx::Size pixmap_size = buffer_->GetSize(); | 143 gfx::Size pixmap_size = buffer_->GetSize(); |
| 143 // If the required size is not integer-sized, round it to the next integer. | 144 // If the required size is not integer-sized, round it to the next integer. |
| 144 *required_size = gfx::ToCeiledSize( | 145 *required_size = gfx::ToCeiledSize( |
| 145 gfx::SizeF(display_bounds.width() / crop_rect.width(), | 146 gfx::SizeF(display_bounds.width() / crop_rect.width(), |
| 146 display_bounds.height() / crop_rect.height())); | 147 display_bounds.height() / crop_rect.height())); |
| 147 return pixmap_size != *required_size; | 148 return pixmap_size != *required_size; |
| 148 } | 149 } |
| 149 | 150 |
| 151 NativePixmap::BufferUsage GbmPixmap::GetBufferUsage() const { |
| 152 return buffer_->GetFramebufferId() ? SCANOUT : MAP; |
| 153 } |
| 154 |
| 155 void* GbmPixmap::Map() { |
| 156 NOTREACHED(); |
| 157 return nullptr; |
| 158 } |
| 159 |
| 160 void GbmPixmap::Unmap() { |
| 161 NOTREACHED(); |
| 162 } |
| 163 |
| 150 } // namespace ui | 164 } // namespace ui |
| OLD | NEW |