Chromium Code Reviews| 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_factory.h" | 5 #include "ui/ozone/platform/dri/gbm_surface_factory.h" |
| 6 | 6 |
| 7 #include <EGL/egl.h> | 7 #include <EGL/egl.h> |
| 8 #include <gbm.h> | 8 #include <gbm.h> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "ui/ozone/platform/dri/buffer_data.h" | 11 #include "ui/ozone/platform/dri/buffer_data.h" |
| 12 #include "ui/ozone/platform/dri/dri_vsync_provider.h" | 12 #include "ui/ozone/platform/dri/dri_vsync_provider.h" |
| 13 #include "ui/ozone/platform/dri/gbm_buffer.h" | 13 #include "ui/ozone/platform/dri/gbm_buffer.h" |
| 14 #include "ui/ozone/platform/dri/gbm_surface.h" | 14 #include "ui/ozone/platform/dri/gbm_surface.h" |
| 15 #include "ui/ozone/platform/dri/hardware_display_controller.h" | 15 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
| 16 #include "ui/ozone/platform/dri/scanout_surface.h" | 16 #include "ui/ozone/platform/dri/scanout_surface.h" |
| 17 #include "ui/ozone/platform/dri/screen_manager.h" | 17 #include "ui/ozone/platform/dri/screen_manager.h" |
| 18 #include "ui/ozone/public/native_pixmap.h" | |
| 18 #include "ui/ozone/public/surface_ozone_egl.h" | 19 #include "ui/ozone/public/surface_ozone_egl.h" |
| 19 | 20 |
| 20 namespace ui { | 21 namespace ui { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 class GbmSurfaceAdapter : public ui::SurfaceOzoneEGL { | 25 class GbmSurfaceAdapter : public ui::SurfaceOzoneEGL { |
| 25 public: | 26 public: |
| 26 GbmSurfaceAdapter(const base::WeakPtr<HardwareDisplayController>& controller); | 27 GbmSurfaceAdapter(const base::WeakPtr<HardwareDisplayController>& controller); |
| 27 virtual ~GbmSurfaceAdapter(); | 28 virtual ~GbmSurfaceAdapter(); |
| 28 | 29 |
| 29 // SurfaceOzoneEGL: | 30 // SurfaceOzoneEGL: |
| 30 virtual intptr_t GetNativeWindow() OVERRIDE; | 31 virtual intptr_t GetNativeWindow() OVERRIDE; |
| 31 virtual bool ResizeNativeWindow(const gfx::Size& viewport_size) OVERRIDE; | 32 virtual bool ResizeNativeWindow(const gfx::Size& viewport_size) OVERRIDE; |
| 32 virtual bool OnSwapBuffers() OVERRIDE; | 33 virtual bool OnSwapBuffers() OVERRIDE; |
| 33 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE; | 34 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE; |
| 34 virtual bool ScheduleOverlayPlane(int plane_z_order, | 35 virtual bool ScheduleOverlayPlane(int plane_z_order, |
| 35 gfx::OverlayTransform plane_transform, | 36 gfx::OverlayTransform plane_transform, |
| 36 scoped_refptr<ui::NativePixmap> buffer, | 37 scoped_refptr<ui::NativePixmap> buffer, |
| 37 const gfx::Rect& display_bounds, | 38 const gfx::Rect& display_bounds, |
| 38 const gfx::RectF& crop_rect) OVERRIDE; | 39 const gfx::RectF& crop_rect) OVERRIDE; |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 base::WeakPtr<HardwareDisplayController> controller_; | 42 base::WeakPtr<HardwareDisplayController> controller_; |
| 43 std::vector<scoped_refptr<NativePixmap> > overlay_refs_; | |
| 44 std::vector<scoped_refptr<NativePixmap> > old_overlay_refs_; | |
| 45 std::vector<OzoneOverlayPlane> overlays_; | |
| 42 | 46 |
| 43 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceAdapter); | 47 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceAdapter); |
| 44 }; | 48 }; |
| 45 | 49 |
| 46 GbmSurfaceAdapter::GbmSurfaceAdapter( | 50 GbmSurfaceAdapter::GbmSurfaceAdapter( |
| 47 const base::WeakPtr<HardwareDisplayController>& controller) | 51 const base::WeakPtr<HardwareDisplayController>& controller) |
| 48 : controller_(controller) {} | 52 : controller_(controller) {} |
| 49 | 53 |
| 50 GbmSurfaceAdapter::~GbmSurfaceAdapter() {} | 54 GbmSurfaceAdapter::~GbmSurfaceAdapter() {} |
| 51 | 55 |
| 52 intptr_t GbmSurfaceAdapter::GetNativeWindow() { | 56 intptr_t GbmSurfaceAdapter::GetNativeWindow() { |
| 53 if (!controller_) | 57 if (!controller_) |
| 54 return 0; | 58 return 0; |
| 55 | 59 |
| 56 return reinterpret_cast<intptr_t>( | 60 return reinterpret_cast<intptr_t>( |
| 57 static_cast<GbmSurface*>(controller_->surface())->native_surface()); | 61 static_cast<GbmSurface*>(controller_->surface())->native_surface()); |
| 58 } | 62 } |
| 59 | 63 |
| 60 bool GbmSurfaceAdapter::ResizeNativeWindow(const gfx::Size& viewport_size) { | 64 bool GbmSurfaceAdapter::ResizeNativeWindow(const gfx::Size& viewport_size) { |
| 61 NOTIMPLEMENTED(); | 65 NOTIMPLEMENTED(); |
| 62 return false; | 66 return false; |
| 63 } | 67 } |
| 64 | 68 |
| 65 bool GbmSurfaceAdapter::OnSwapBuffers() { | 69 bool GbmSurfaceAdapter::OnSwapBuffers() { |
| 66 if (!controller_) | 70 if (!controller_) |
| 67 return false; | 71 return false; |
| 72 bool ret = controller_->SchedulePageFlip(&overlays_); | |
|
dnicoara
2014/07/07 19:17:54
I think it would be better if HDC takes a referenc
achaulk
2014/07/07 20:18:04
Done.
| |
| 73 overlays_.clear(); | |
| 74 old_overlay_refs_.clear(); | |
| 75 old_overlay_refs_.swap(overlay_refs_); | |
| 68 | 76 |
| 69 static_cast<GbmSurface*>(controller_->surface())->LockCurrentDrawable(); | 77 if (ret) |
| 70 if (controller_->SchedulePageFlip()) { | |
| 71 controller_->WaitForPageFlipEvent(); | 78 controller_->WaitForPageFlipEvent(); |
| 72 return true; | |
| 73 } | |
| 74 | 79 |
| 75 return false; | 80 return ret; |
| 76 } | 81 } |
| 77 | 82 |
| 78 bool GbmSurfaceAdapter::ScheduleOverlayPlane( | 83 bool GbmSurfaceAdapter::ScheduleOverlayPlane( |
| 79 int plane_z_order, | 84 int plane_z_order, |
| 80 gfx::OverlayTransform plane_transform, | 85 gfx::OverlayTransform plane_transform, |
| 81 scoped_refptr<ui::NativePixmap> buffer, | 86 scoped_refptr<NativePixmap> buffer, |
| 82 const gfx::Rect& display_bounds, | 87 const gfx::Rect& display_bounds, |
| 83 const gfx::RectF& crop_rect) { | 88 const gfx::RectF& crop_rect) { |
| 84 NOTIMPLEMENTED(); | 89 GbmBuffer* gbm_buffer = static_cast<GbmBuffer*>(buffer.get()); |
| 85 return false; | 90 if (!gbm_buffer) { |
| 91 LOG(ERROR) << "ScheduleOverlayPlane passed NULL buffer"; | |
| 92 return false; | |
| 93 } | |
| 94 overlays_.push_back(OzoneOverlayPlane( | |
| 95 gbm_buffer, plane_z_order, plane_transform, display_bounds, crop_rect)); | |
| 96 overlay_refs_.push_back(buffer); | |
| 97 return true; | |
| 86 } | 98 } |
| 87 | 99 |
| 88 scoped_ptr<gfx::VSyncProvider> GbmSurfaceAdapter::CreateVSyncProvider() { | 100 scoped_ptr<gfx::VSyncProvider> GbmSurfaceAdapter::CreateVSyncProvider() { |
| 89 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(controller_)); | 101 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(controller_)); |
| 90 } | 102 } |
| 91 | 103 |
| 92 } // namespace | 104 } // namespace |
| 93 | 105 |
| 94 GbmSurfaceFactory::GbmSurfaceFactory() | 106 GbmSurfaceFactory::GbmSurfaceFactory() |
| 95 : DriSurfaceFactory(NULL, NULL), | 107 : DriSurfaceFactory(NULL, NULL), |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( | 188 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( |
| 177 gfx::Size size, | 189 gfx::Size size, |
| 178 BufferFormat format) { | 190 BufferFormat format) { |
| 179 scoped_refptr<GbmBuffer> buf = new GbmBuffer(device_, drm_, size); | 191 scoped_refptr<GbmBuffer> buf = new GbmBuffer(device_, drm_, size); |
| 180 if (!buf->InitializeBuffer(format, true)) { | 192 if (!buf->InitializeBuffer(format, true)) { |
| 181 return NULL; | 193 return NULL; |
| 182 } | 194 } |
| 183 return buf; | 195 return buf; |
| 184 } | 196 } |
| 185 | 197 |
| 198 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { | |
| 199 return false; | |
| 200 } | |
| 201 | |
| 186 } // namespace ui | 202 } // namespace ui |
| OLD | NEW |