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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 86 } |
87 | 87 |
88 void GbmPixmap::SetProcessingCallback( | 88 void GbmPixmap::SetProcessingCallback( |
89 const ProcessingCallback& processing_callback) { | 89 const ProcessingCallback& processing_callback) { |
90 processing_callback_ = processing_callback; | 90 processing_callback_ = processing_callback; |
91 } | 91 } |
92 | 92 |
93 scoped_refptr<NativePixmap> GbmPixmap::GetProcessedPixmap( | 93 scoped_refptr<NativePixmap> GbmPixmap::GetProcessedPixmap( |
94 gfx::Size target_size, | 94 gfx::Size target_size, |
95 gfx::BufferFormat target_format) { | 95 gfx::BufferFormat target_format) { |
96 return processing_callback_.Run(target_size, target_format); | 96 return processing_callback_.Run(this, target_size, target_format); |
97 } | 97 } |
98 | 98 |
99 gfx::NativePixmapHandle GbmPixmap::ExportHandle() { | 99 gfx::NativePixmapHandle GbmPixmap::ExportHandle() { |
100 gfx::NativePixmapHandle handle; | 100 gfx::NativePixmapHandle handle; |
101 | 101 |
102 base::ScopedFD dmabuf_fd(HANDLE_EINTR(dup(dma_buf_.get()))); | 102 base::ScopedFD dmabuf_fd(HANDLE_EINTR(dup(dma_buf_.get()))); |
103 if (!dmabuf_fd.is_valid()) { | 103 if (!dmabuf_fd.is_valid()) { |
104 PLOG(ERROR) << "dup"; | 104 PLOG(ERROR) << "dup"; |
105 return handle; | 105 return handle; |
106 } | 106 } |
(...skipping 15 matching lines...) Expand all Loading... |
122 } | 122 } |
123 | 123 |
124 int GbmPixmap::GetDmaBufPitch() { | 124 int GbmPixmap::GetDmaBufPitch() { |
125 return dma_buf_pitch_; | 125 return dma_buf_pitch_; |
126 } | 126 } |
127 | 127 |
128 gfx::BufferFormat GbmPixmap::GetBufferFormat() { | 128 gfx::BufferFormat GbmPixmap::GetBufferFormat() { |
129 return GetBufferFormatFromFourCCFormat(buffer_->GetFramebufferPixelFormat()); | 129 return GetBufferFormatFromFourCCFormat(buffer_->GetFramebufferPixelFormat()); |
130 } | 130 } |
131 | 131 |
| 132 gfx::Size GbmPixmap::GetBufferSize() const { |
| 133 return buffer_->GetSize(); |
| 134 } |
| 135 |
132 bool GbmPixmap::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 136 bool GbmPixmap::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
133 int plane_z_order, | 137 int plane_z_order, |
134 gfx::OverlayTransform plane_transform, | 138 gfx::OverlayTransform plane_transform, |
135 const gfx::Rect& display_bounds, | 139 const gfx::Rect& display_bounds, |
136 const gfx::RectF& crop_rect) { | 140 const gfx::RectF& crop_rect) { |
137 gfx::Size target_size; | 141 gfx::Size target_size; |
138 gfx::BufferFormat target_format; | 142 gfx::BufferFormat target_format; |
139 if (plane_z_order && ShouldApplyProcessing(display_bounds, crop_rect, | 143 if (plane_z_order && ShouldApplyProcessing(display_bounds, crop_rect, |
140 &target_size, &target_format)) { | 144 &target_size, &target_format)) { |
141 scoped_refptr<NativePixmap> processed_pixmap = | 145 scoped_refptr<NativePixmap> processed_pixmap = |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 gfx::Size pixmap_size = buffer_->GetSize(); | 184 gfx::Size pixmap_size = buffer_->GetSize(); |
181 // If the required size is not integer-sized, round it to the next integer. | 185 // If the required size is not integer-sized, round it to the next integer. |
182 *target_size = gfx::ToCeiledSize( | 186 *target_size = gfx::ToCeiledSize( |
183 gfx::SizeF(display_bounds.width() / crop_rect.width(), | 187 gfx::SizeF(display_bounds.width() / crop_rect.width(), |
184 display_bounds.height() / crop_rect.height())); | 188 display_bounds.height() / crop_rect.height())); |
185 | 189 |
186 return pixmap_size != *target_size || GetBufferFormat() != *target_format; | 190 return pixmap_size != *target_size || GetBufferFormat() != *target_format; |
187 } | 191 } |
188 | 192 |
189 } // namespace ui | 193 } // namespace ui |
OLD | NEW |