Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: ui/ozone/platform/dri/gbm_surface_factory.cc

Issue 371813004: ozone: gbm: Add overlay support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_;
alexst (slow to review) 2014/07/08 17:22:32 nit: these vector declarations are re-used in a bu
achaulk 2014/07/08 18:16:37 Sure
44 std::vector<OzoneOverlayPlane> overlays_;
42 45
43 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceAdapter); 46 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceAdapter);
44 }; 47 };
45 48
46 GbmSurfaceAdapter::GbmSurfaceAdapter( 49 GbmSurfaceAdapter::GbmSurfaceAdapter(
47 const base::WeakPtr<HardwareDisplayController>& controller) 50 const base::WeakPtr<HardwareDisplayController>& controller)
48 : controller_(controller) {} 51 : controller_(controller) {}
49 52
50 GbmSurfaceAdapter::~GbmSurfaceAdapter() {} 53 GbmSurfaceAdapter::~GbmSurfaceAdapter() {}
51 54
52 intptr_t GbmSurfaceAdapter::GetNativeWindow() { 55 intptr_t GbmSurfaceAdapter::GetNativeWindow() {
53 if (!controller_) 56 if (!controller_)
54 return 0; 57 return 0;
55 58
56 return reinterpret_cast<intptr_t>( 59 return reinterpret_cast<intptr_t>(
57 static_cast<GbmSurface*>(controller_->surface())->native_surface()); 60 static_cast<GbmSurface*>(controller_->surface())->native_surface());
58 } 61 }
59 62
60 bool GbmSurfaceAdapter::ResizeNativeWindow(const gfx::Size& viewport_size) { 63 bool GbmSurfaceAdapter::ResizeNativeWindow(const gfx::Size& viewport_size) {
61 NOTIMPLEMENTED(); 64 NOTIMPLEMENTED();
62 return false; 65 return false;
63 } 66 }
64 67
65 bool GbmSurfaceAdapter::OnSwapBuffers() { 68 bool GbmSurfaceAdapter::OnSwapBuffers() {
66 if (!controller_) 69 if (!controller_)
67 return false; 70 return false;
71 bool ret = controller_->SchedulePageFlip(&overlays_, &overlay_refs_);
alexst (slow to review) 2014/07/08 17:22:32 this is hard to read without context, please renam
achaulk 2014/07/08 18:16:37 Done.
72 overlays_.clear();
68 73
69 static_cast<GbmSurface*>(controller_->surface())->LockCurrentDrawable(); 74 if (ret)
70 if (controller_->SchedulePageFlip()) {
71 controller_->WaitForPageFlipEvent(); 75 controller_->WaitForPageFlipEvent();
72 return true;
73 }
74 76
75 return false; 77 return ret;
76 } 78 }
77 79
78 bool GbmSurfaceAdapter::ScheduleOverlayPlane( 80 bool GbmSurfaceAdapter::ScheduleOverlayPlane(
79 int plane_z_order, 81 int plane_z_order,
80 gfx::OverlayTransform plane_transform, 82 gfx::OverlayTransform plane_transform,
81 scoped_refptr<ui::NativePixmap> buffer, 83 scoped_refptr<NativePixmap> buffer,
82 const gfx::Rect& display_bounds, 84 const gfx::Rect& display_bounds,
83 const gfx::RectF& crop_rect) { 85 const gfx::RectF& crop_rect) {
84 NOTIMPLEMENTED(); 86 GbmBuffer* gbm_buffer = static_cast<GbmBuffer*>(buffer.get());
85 return false; 87 if (!gbm_buffer) {
88 LOG(ERROR) << "ScheduleOverlayPlane passed NULL buffer";
89 return false;
90 }
91 overlays_.push_back(OzoneOverlayPlane(
92 gbm_buffer, plane_z_order, plane_transform, display_bounds, crop_rect));
93 overlay_refs_.push_back(buffer);
94 return true;
86 } 95 }
87 96
88 scoped_ptr<gfx::VSyncProvider> GbmSurfaceAdapter::CreateVSyncProvider() { 97 scoped_ptr<gfx::VSyncProvider> GbmSurfaceAdapter::CreateVSyncProvider() {
89 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(controller_)); 98 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(controller_));
90 } 99 }
91 100
92 } // namespace 101 } // namespace
93 102
94 GbmSurfaceFactory::GbmSurfaceFactory() 103 GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless)
95 : DriSurfaceFactory(NULL, NULL), 104 : DriSurfaceFactory(NULL, NULL),
96 device_(NULL) {} 105 device_(NULL),
106 allow_surfaceless_(allow_surfaceless) {
107 }
97 108
98 GbmSurfaceFactory::~GbmSurfaceFactory() {} 109 GbmSurfaceFactory::~GbmSurfaceFactory() {}
99 110
100 void GbmSurfaceFactory::InitializeGpu( 111 void GbmSurfaceFactory::InitializeGpu(
101 DriWrapper* dri, gbm_device* device, ScreenManager* screen_manager) { 112 DriWrapper* dri, gbm_device* device, ScreenManager* screen_manager) {
102 drm_ = dri; 113 drm_ = dri;
103 device_ = device; 114 device_ = device;
104 screen_manager_ = screen_manager; 115 screen_manager_ = screen_manager;
105 } 116 }
106 117
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( 187 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
177 gfx::Size size, 188 gfx::Size size,
178 BufferFormat format) { 189 BufferFormat format) {
179 scoped_refptr<GbmBuffer> buf = new GbmBuffer(device_, drm_, size); 190 scoped_refptr<GbmBuffer> buf = new GbmBuffer(device_, drm_, size);
180 if (!buf->InitializeBuffer(format, true)) { 191 if (!buf->InitializeBuffer(format, true)) {
181 return NULL; 192 return NULL;
182 } 193 }
183 return buf; 194 return buf;
184 } 195 }
185 196
197 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() {
198 return allow_surfaceless_;
199 }
200
186 } // namespace ui 201 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698