Commit 2941af41 authored by dnicoara's avatar dnicoara Committed by Commit bot

[Ozone-Dri] Merge the DriWindowDelegate with the implementation

Simplify code by removing an interface only used in testing.

BUG=none

Review URL: https://codereview.chromium.org/981583005

Cr-Commit-Position: refs/heads/master@{#319160}
parent 88fe77f9
...@@ -45,9 +45,8 @@ source_set("dri_common") { ...@@ -45,9 +45,8 @@ source_set("dri_common") {
"dri_vsync_provider.h", "dri_vsync_provider.h",
"dri_window.cc", "dri_window.cc",
"dri_window.h", "dri_window.h",
"dri_window_delegate.cc",
"dri_window_delegate.h", "dri_window_delegate.h",
"dri_window_delegate_impl.cc",
"dri_window_delegate_impl.h",
"dri_window_delegate_manager.cc", "dri_window_delegate_manager.cc",
"dri_window_delegate_manager.h", "dri_window_delegate_manager.h",
"dri_window_manager.cc", "dri_window_manager.cc",
...@@ -120,7 +119,7 @@ if (ozone_platform_dri) { ...@@ -120,7 +119,7 @@ if (ozone_platform_dri) {
testonly = true testonly = true
sources = [ sources = [
"dri_surface_unittest.cc", "dri_surface_unittest.cc",
"dri_window_delegate_impl_unittest.cc", "dri_window_delegate_unittest.cc",
"hardware_display_controller_unittest.cc", "hardware_display_controller_unittest.cc",
"hardware_display_plane_manager_unittest.cc", "hardware_display_plane_manager_unittest.cc",
"screen_manager_unittest.cc", "screen_manager_unittest.cc",
......
...@@ -67,9 +67,8 @@ ...@@ -67,9 +67,8 @@
'dri_vsync_provider.h', 'dri_vsync_provider.h',
'dri_window.cc', 'dri_window.cc',
'dri_window.h', 'dri_window.h',
'dri_window_delegate.cc',
'dri_window_delegate.h', 'dri_window_delegate.h',
'dri_window_delegate_impl.cc',
'dri_window_delegate_impl.h',
'dri_window_delegate_manager.cc', 'dri_window_delegate_manager.cc',
'dri_window_delegate_manager.h', 'dri_window_delegate_manager.h',
'dri_window_manager.cc', 'dri_window_manager.cc',
...@@ -120,7 +119,7 @@ ...@@ -120,7 +119,7 @@
'direct_dependent_settings': { 'direct_dependent_settings': {
'sources': [ 'sources': [
'dri_surface_unittest.cc', 'dri_surface_unittest.cc',
'dri_window_delegate_impl_unittest.cc', 'dri_window_delegate_unittest.cc',
'hardware_display_controller_unittest.cc', 'hardware_display_controller_unittest.cc',
'hardware_display_plane_manager_unittest.cc', 'hardware_display_plane_manager_unittest.cc',
'screen_manager_unittest.cc', 'screen_manager_unittest.cc',
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h" #include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/common/gpu/ozone_gpu_messages.h" #include "ui/ozone/common/gpu/ozone_gpu_messages.h"
#include "ui/ozone/platform/dri/dri_window_delegate_impl.h" #include "ui/ozone/platform/dri/dri_window_delegate.h"
#include "ui/ozone/platform/dri/dri_window_delegate_manager.h" #include "ui/ozone/platform/dri/dri_window_delegate_manager.h"
#include "ui/ozone/platform/dri/drm_device.h" #include "ui/ozone/platform/dri/drm_device.h"
#include "ui/ozone/platform/dri/native_display_delegate_dri.h" #include "ui/ozone/platform/dri/native_display_delegate_dri.h"
...@@ -229,7 +229,7 @@ bool DriGpuPlatformSupport::OnMessageReceived(const IPC::Message& message) { ...@@ -229,7 +229,7 @@ bool DriGpuPlatformSupport::OnMessageReceived(const IPC::Message& message) {
void DriGpuPlatformSupport::OnCreateWindowDelegate( void DriGpuPlatformSupport::OnCreateWindowDelegate(
gfx::AcceleratedWidget widget) { gfx::AcceleratedWidget widget) {
scoped_ptr<DriWindowDelegate> delegate( scoped_ptr<DriWindowDelegate> delegate(
new DriWindowDelegateImpl(widget, drm_device_manager_, screen_manager_)); new DriWindowDelegate(widget, drm_device_manager_, screen_manager_));
delegate->Initialize(); delegate->Initialize();
window_manager_->AddWindowDelegate(widget, delegate.Pass()); window_manager_->AddWindowDelegate(widget, delegate.Pass());
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
#include "ui/ozone/platform/dri/dri_buffer.h" #include "ui/ozone/platform/dri/dri_buffer.h"
#include "ui/ozone/platform/dri/dri_vsync_provider.h" #include "ui/ozone/platform/dri/dri_vsync_provider.h"
#include "ui/ozone/platform/dri/dri_window_delegate_impl.h" #include "ui/ozone/platform/dri/dri_window_delegate.h"
#include "ui/ozone/platform/dri/drm_device.h" #include "ui/ozone/platform/dri/drm_device.h"
#include "ui/ozone/platform/dri/hardware_display_controller.h" #include "ui/ozone/platform/dri/hardware_display_controller.h"
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/dri/dri_surface.h" #include "ui/ozone/platform/dri/dri_surface.h"
#include "ui/ozone/platform/dri/dri_util.h" #include "ui/ozone/platform/dri/dri_util.h"
#include "ui/ozone/platform/dri/dri_window_delegate_impl.h" #include "ui/ozone/platform/dri/dri_window_delegate.h"
#include "ui/ozone/platform/dri/dri_window_delegate_manager.h" #include "ui/ozone/platform/dri/dri_window_delegate_manager.h"
#include "ui/ozone/platform/dri/hardware_display_controller.h" #include "ui/ozone/platform/dri/hardware_display_controller.h"
#include "ui/ozone/public/surface_ozone_canvas.h" #include "ui/ozone/public/surface_ozone_canvas.h"
......
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
#include "ui/ozone/platform/dri/dri_buffer.h" #include "ui/ozone/platform/dri/dri_buffer.h"
#include "ui/ozone/platform/dri/dri_surface.h" #include "ui/ozone/platform/dri/dri_surface.h"
#include "ui/ozone/platform/dri/dri_window_delegate.h" #include "ui/ozone/platform/dri/dri_window_delegate.h"
#include "ui/ozone/platform/dri/drm_device_manager.h"
#include "ui/ozone/platform/dri/hardware_display_controller.h" #include "ui/ozone/platform/dri/hardware_display_controller.h"
#include "ui/ozone/platform/dri/screen_manager.h"
#include "ui/ozone/platform/dri/test/mock_drm_device.h" #include "ui/ozone/platform/dri/test/mock_drm_device.h"
namespace { namespace {
...@@ -20,43 +22,11 @@ namespace { ...@@ -20,43 +22,11 @@ namespace {
const drmModeModeInfo kDefaultMode = const drmModeModeInfo kDefaultMode =
{0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}};
const gfx::AcceleratedWidget kDefaultWidgetHandle = 1;
const uint32_t kDefaultCrtc = 1; const uint32_t kDefaultCrtc = 1;
const uint32_t kDefaultConnector = 2; const uint32_t kDefaultConnector = 2;
const size_t kPlanesPerCrtc = 1; const size_t kPlanesPerCrtc = 1;
const uint32_t kDefaultCursorSize = 64;
class MockDriWindowDelegate : public ui::DriWindowDelegate {
public:
MockDriWindowDelegate(ui::DrmDevice* drm) {
controller_.reset(new ui::HardwareDisplayController(make_scoped_ptr(
new ui::CrtcController(drm, kDefaultCrtc, kDefaultConnector))));
scoped_refptr<ui::DriBuffer> buffer(new ui::DriBuffer(drm));
SkImageInfo info = SkImageInfo::MakeN32Premul(kDefaultMode.hdisplay,
kDefaultMode.vdisplay);
EXPECT_TRUE(buffer->Initialize(info, true));
EXPECT_TRUE(controller_->Modeset(ui::OverlayPlane(buffer), kDefaultMode));
}
~MockDriWindowDelegate() override {}
// DriWindowDelegate:
void Initialize() override {}
void Shutdown() override {}
gfx::AcceleratedWidget GetAcceleratedWidget() override { return 1; }
ui::HardwareDisplayController* GetController() override {
return controller_.get();
}
void OnBoundsChanged(const gfx::Rect& bounds) override {}
void SetCursor(const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location,
int frame_delay_ms) override {}
void SetCursorWithoutAnimations(const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location) override {}
void MoveCursor(const gfx::Point& location) override {}
private:
scoped_ptr<ui::HardwareDisplayController> controller_;
DISALLOW_COPY_AND_ASSIGN(MockDriWindowDelegate);
};
} // namespace } // namespace
...@@ -70,7 +40,10 @@ class DriSurfaceTest : public testing::Test { ...@@ -70,7 +40,10 @@ class DriSurfaceTest : public testing::Test {
protected: protected:
scoped_ptr<base::MessageLoop> message_loop_; scoped_ptr<base::MessageLoop> message_loop_;
scoped_refptr<ui::MockDrmDevice> drm_; scoped_refptr<ui::MockDrmDevice> drm_;
scoped_ptr<MockDriWindowDelegate> window_delegate_; scoped_ptr<ui::DriBufferGenerator> buffer_generator_;
scoped_ptr<ui::ScreenManager> screen_manager_;
scoped_ptr<ui::DrmDeviceManager> drm_device_manager_;
scoped_ptr<ui::DriWindowDelegate> window_delegate_;
scoped_ptr<ui::DriSurface> surface_; scoped_ptr<ui::DriSurface> surface_;
private: private:
...@@ -82,7 +55,19 @@ void DriSurfaceTest::SetUp() { ...@@ -82,7 +55,19 @@ void DriSurfaceTest::SetUp() {
std::vector<uint32_t> crtcs; std::vector<uint32_t> crtcs;
crtcs.push_back(kDefaultCrtc); crtcs.push_back(kDefaultCrtc);
drm_ = new ui::MockDrmDevice(true, crtcs, kPlanesPerCrtc); drm_ = new ui::MockDrmDevice(true, crtcs, kPlanesPerCrtc);
window_delegate_.reset(new MockDriWindowDelegate(drm_.get())); buffer_generator_.reset(new ui::DriBufferGenerator());
screen_manager_.reset(new ui::ScreenManager(buffer_generator_.get()));
screen_manager_->AddDisplayController(drm_, kDefaultCrtc, kDefaultConnector);
screen_manager_->ConfigureDisplayController(
drm_, kDefaultCrtc, kDefaultConnector, gfx::Point(), kDefaultMode);
drm_device_manager_.reset(new ui::DrmDeviceManager(drm_));
window_delegate_.reset(new ui::DriWindowDelegate(
kDefaultWidgetHandle, drm_device_manager_.get(), screen_manager_.get()));
window_delegate_->Initialize();
window_delegate_->OnBoundsChanged(
gfx::Rect(gfx::Size(kDefaultMode.hdisplay, kDefaultMode.vdisplay)));
surface_.reset(new ui::DriSurface(window_delegate_.get())); surface_.reset(new ui::DriSurface(window_delegate_.get()));
surface_->ResizeCanvas(gfx::Size(kDefaultMode.hdisplay, surface_->ResizeCanvas(gfx::Size(kDefaultMode.hdisplay,
kDefaultMode.vdisplay)); kDefaultMode.vdisplay));
...@@ -90,7 +75,7 @@ void DriSurfaceTest::SetUp() { ...@@ -90,7 +75,7 @@ void DriSurfaceTest::SetUp() {
void DriSurfaceTest::TearDown() { void DriSurfaceTest::TearDown() {
surface_.reset(); surface_.reset();
window_delegate_.reset(); window_delegate_->Shutdown();
drm_ = nullptr; drm_ = nullptr;
message_loop_.reset(); message_loop_.reset();
} }
...@@ -113,12 +98,22 @@ TEST_F(DriSurfaceTest, CheckSurfaceContents) { ...@@ -113,12 +98,22 @@ TEST_F(DriSurfaceTest, CheckSurfaceContents) {
gfx::Rect(0, 0, kDefaultMode.hdisplay / 2, kDefaultMode.vdisplay / 2)); gfx::Rect(0, 0, kDefaultMode.hdisplay / 2, kDefaultMode.vdisplay / 2));
SkBitmap image; SkBitmap image;
// Buffer 0 is the buffer used in SetUp for modesetting and buffer 1 is the std::vector<skia::RefPtr<SkSurface>> framebuffers;
// frontbuffer. for (const auto& buffer : drm_->buffers()) {
// Buffer 2 is the backbuffer we just painted in, so we want to make sure its // Skip cursor buffers.
// contents are correct. if (buffer->width() == kDefaultCursorSize &&
image.setInfo(drm_->buffers()[2]->getCanvas()->imageInfo()); buffer->height() == kDefaultCursorSize)
EXPECT_TRUE(drm_->buffers()[2]->getCanvas()->readPixels(&image, 0, 0)); continue;
framebuffers.push_back(buffer);
}
// Buffer 0 is the modesetting buffer, buffer 1 is the frontbuffer and buffer
// 2 is the backbuffer.
EXPECT_EQ(3u, framebuffers.size());
image.setInfo(framebuffers[2]->getCanvas()->imageInfo());
EXPECT_TRUE(framebuffers[2]->getCanvas()->readPixels(&image, 0, 0));
EXPECT_EQ(kDefaultMode.hdisplay, image.width()); EXPECT_EQ(kDefaultMode.hdisplay, image.width());
EXPECT_EQ(kDefaultMode.vdisplay, image.height()); EXPECT_EQ(kDefaultMode.vdisplay, image.height());
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/ozone/platform/dri/dri_window_delegate_impl.h" #include "ui/ozone/platform/dri/dri_window_delegate.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
...@@ -42,8 +42,7 @@ void UpdateCursorImage(DriBuffer* cursor, const SkBitmap& image) { ...@@ -42,8 +42,7 @@ void UpdateCursorImage(DriBuffer* cursor, const SkBitmap& image) {
} // namespace } // namespace
DriWindowDelegateImpl::DriWindowDelegateImpl( DriWindowDelegate::DriWindowDelegate(gfx::AcceleratedWidget widget,
gfx::AcceleratedWidget widget,
DrmDeviceManager* device_manager, DrmDeviceManager* device_manager,
ScreenManager* screen_manager) ScreenManager* screen_manager)
: widget_(widget), : widget_(widget),
...@@ -55,40 +54,40 @@ DriWindowDelegateImpl::DriWindowDelegateImpl( ...@@ -55,40 +54,40 @@ DriWindowDelegateImpl::DriWindowDelegateImpl(
cursor_frame_delay_ms_(0) { cursor_frame_delay_ms_(0) {
} }
DriWindowDelegateImpl::~DriWindowDelegateImpl() { DriWindowDelegate::~DriWindowDelegate() {
} }
void DriWindowDelegateImpl::Initialize() { void DriWindowDelegate::Initialize() {
TRACE_EVENT1("dri", "DriWindowDelegateImpl::Initialize", "widget", widget_); TRACE_EVENT1("dri", "DriWindowDelegate::Initialize", "widget", widget_);
device_manager_->UpdateDrmDevice(widget_, nullptr); device_manager_->UpdateDrmDevice(widget_, nullptr);
screen_manager_->AddObserver(this); screen_manager_->AddObserver(this);
} }
void DriWindowDelegateImpl::Shutdown() { void DriWindowDelegate::Shutdown() {
TRACE_EVENT1("dri", "DriWindowDelegateImpl::Shutdown", "widget", widget_); TRACE_EVENT1("dri", "DriWindowDelegate::Shutdown", "widget", widget_);
screen_manager_->RemoveObserver(this); screen_manager_->RemoveObserver(this);
device_manager_->RemoveDrmDevice(widget_); device_manager_->RemoveDrmDevice(widget_);
} }
gfx::AcceleratedWidget DriWindowDelegateImpl::GetAcceleratedWidget() { gfx::AcceleratedWidget DriWindowDelegate::GetAcceleratedWidget() {
return widget_; return widget_;
} }
HardwareDisplayController* DriWindowDelegateImpl::GetController() { HardwareDisplayController* DriWindowDelegate::GetController() {
return controller_; return controller_;
} }
void DriWindowDelegateImpl::OnBoundsChanged(const gfx::Rect& bounds) { void DriWindowDelegate::OnBoundsChanged(const gfx::Rect& bounds) {
TRACE_EVENT2("dri", "DriWindowDelegateImpl::OnBoundsChanged", "widget", TRACE_EVENT2("dri", "DriWindowDelegate::OnBoundsChanged", "widget", widget_,
widget_, "bounds", bounds.ToString()); "bounds", bounds.ToString());
bounds_ = bounds; bounds_ = bounds;
controller_ = screen_manager_->GetDisplayController(bounds); controller_ = screen_manager_->GetDisplayController(bounds);
UpdateWidgetToDrmDeviceMapping(); UpdateWidgetToDrmDeviceMapping();
UpdateCursorBuffers(); UpdateCursorBuffers();
} }
void DriWindowDelegateImpl::SetCursor(const std::vector<SkBitmap>& bitmaps, void DriWindowDelegate::SetCursor(const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location, const gfx::Point& location,
int frame_delay_ms) { int frame_delay_ms) {
cursor_bitmaps_ = bitmaps; cursor_bitmaps_ = bitmaps;
...@@ -100,12 +99,12 @@ void DriWindowDelegateImpl::SetCursor(const std::vector<SkBitmap>& bitmaps, ...@@ -100,12 +99,12 @@ void DriWindowDelegateImpl::SetCursor(const std::vector<SkBitmap>& bitmaps,
if (cursor_frame_delay_ms_) if (cursor_frame_delay_ms_)
cursor_timer_.Start( cursor_timer_.Start(
FROM_HERE, base::TimeDelta::FromMilliseconds(cursor_frame_delay_ms_), FROM_HERE, base::TimeDelta::FromMilliseconds(cursor_frame_delay_ms_),
this, &DriWindowDelegateImpl::OnCursorAnimationTimeout); this, &DriWindowDelegate::OnCursorAnimationTimeout);
ResetCursor(false); ResetCursor(false);
} }
void DriWindowDelegateImpl::SetCursorWithoutAnimations( void DriWindowDelegate::SetCursorWithoutAnimations(
const std::vector<SkBitmap>& bitmaps, const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location) { const gfx::Point& location) {
cursor_bitmaps_ = bitmaps; cursor_bitmaps_ = bitmaps;
...@@ -115,14 +114,14 @@ void DriWindowDelegateImpl::SetCursorWithoutAnimations( ...@@ -115,14 +114,14 @@ void DriWindowDelegateImpl::SetCursorWithoutAnimations(
ResetCursor(false); ResetCursor(false);
} }
void DriWindowDelegateImpl::MoveCursor(const gfx::Point& location) { void DriWindowDelegate::MoveCursor(const gfx::Point& location) {
cursor_location_ = location; cursor_location_ = location;
if (controller_) if (controller_)
controller_->MoveCursor(location); controller_->MoveCursor(location);
} }
void DriWindowDelegateImpl::OnDisplayChanged( void DriWindowDelegate::OnDisplayChanged(
HardwareDisplayController* controller) { HardwareDisplayController* controller) {
DCHECK(controller); DCHECK(controller);
...@@ -147,13 +146,13 @@ void DriWindowDelegateImpl::OnDisplayChanged( ...@@ -147,13 +146,13 @@ void DriWindowDelegateImpl::OnDisplayChanged(
UpdateCursorBuffers(); UpdateCursorBuffers();
} }
void DriWindowDelegateImpl::OnDisplayRemoved( void DriWindowDelegate::OnDisplayRemoved(
HardwareDisplayController* controller) { HardwareDisplayController* controller) {
if (controller_ == controller) if (controller_ == controller)
controller_ = nullptr; controller_ = nullptr;
} }
void DriWindowDelegateImpl::ResetCursor(bool bitmap_only) { void DriWindowDelegate::ResetCursor(bool bitmap_only) {
if (!controller_) if (!controller_)
return; return;
...@@ -173,14 +172,14 @@ void DriWindowDelegateImpl::ResetCursor(bool bitmap_only) { ...@@ -173,14 +172,14 @@ void DriWindowDelegateImpl::ResetCursor(bool bitmap_only) {
} }
} }
void DriWindowDelegateImpl::OnCursorAnimationTimeout() { void DriWindowDelegate::OnCursorAnimationTimeout() {
cursor_frame_++; cursor_frame_++;
cursor_frame_ %= cursor_bitmaps_.size(); cursor_frame_ %= cursor_bitmaps_.size();
ResetCursor(true); ResetCursor(true);
} }
void DriWindowDelegateImpl::UpdateWidgetToDrmDeviceMapping() { void DriWindowDelegate::UpdateWidgetToDrmDeviceMapping() {
scoped_refptr<DrmDevice> drm = nullptr; scoped_refptr<DrmDevice> drm = nullptr;
if (controller_) if (controller_)
drm = controller_->GetAllocationDrmDevice(); drm = controller_->GetAllocationDrmDevice();
...@@ -188,7 +187,7 @@ void DriWindowDelegateImpl::UpdateWidgetToDrmDeviceMapping() { ...@@ -188,7 +187,7 @@ void DriWindowDelegateImpl::UpdateWidgetToDrmDeviceMapping() {
device_manager_->UpdateDrmDevice(widget_, drm); device_manager_->UpdateDrmDevice(widget_, drm);
} }
void DriWindowDelegateImpl::UpdateCursorBuffers() { void DriWindowDelegate::UpdateCursorBuffers() {
if (!controller_) { if (!controller_) {
for (size_t i = 0; i < arraysize(cursor_buffers_); ++i) { for (size_t i = 0; i < arraysize(cursor_buffers_); ++i) {
cursor_buffers_[i] = nullptr; cursor_buffers_[i] = nullptr;
......
...@@ -7,7 +7,12 @@ ...@@ -7,7 +7,12 @@
#include <vector> #include <vector>
#include "base/timer/timer.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/ozone/ozone_export.h"
#include "ui/ozone/platform/dri/display_change_observer.h"
class SkBitmap; class SkBitmap;
...@@ -18,52 +23,93 @@ class Rect; ...@@ -18,52 +23,93 @@ class Rect;
namespace ui { namespace ui {
class DriBuffer;
class DrmDeviceManager;
class HardwareDisplayController; class HardwareDisplayController;
class ScreenManager;
// Interface for the display-server half of a DriWindow.
// // A delegate of the platform window (DriWindow) on the GPU process. This is
// The main implementation of this lives in the process that owns the display // used to keep track of window state changes such that each platform window is
// connection (usually the GPU process) and associates a platform window // correctly associated with a display.
// (DriWindow) with a display. A window is associated with the display whose // A window is associated with the display whose bounds contains the window
// bounds contains the window bounds. If there's no suitable display, the window // bounds. If there's no suitable display, the window is disconnected and its
// is disconnected and its contents will not be visible. // contents will not be visible.
// class OZONE_EXPORT DriWindowDelegate : public DisplayChangeObserver {
// In software mode, this is owned directly on DriWindow because the display
// controller object is in the same process.
//
// In accelerated mode, there's a proxy implementation and calls are forwarded
// to the real object in the GPU process via IPC.
class DriWindowDelegate {
public: public:
virtual ~DriWindowDelegate() {} DriWindowDelegate(gfx::AcceleratedWidget widget,
DrmDeviceManager* device_manager,
ScreenManager* screen_manager);
~DriWindowDelegate() override;
virtual void Initialize() = 0; void Initialize();
virtual void Shutdown() = 0; void Shutdown();
// Returns the accelerated widget associated with the delegate. // Returns the accelerated widget associated with the delegate.
virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0; gfx::AcceleratedWidget GetAcceleratedWidget();
// Returns the current controller the window is displaying on. Callers should // Returns the current controller the window is displaying on. Callers should
// not cache the result as the controller may change as the window is moved. // not cache the result as the controller may change as the window is moved.
virtual HardwareDisplayController* GetController() = 0; HardwareDisplayController* GetController();
// Called when the window is resized/moved. // Called when the window is resized/moved.
virtual void OnBoundsChanged(const gfx::Rect& bounds) = 0; void OnBoundsChanged(const gfx::Rect& bounds);
// Update the HW cursor bitmap & move to specified location. If // Update the HW cursor bitmap & move to specified location. If
// the bitmap is empty, the cursor is hidden. // the bitmap is empty, the cursor is hidden.
virtual void SetCursor(const std::vector<SkBitmap>& bitmaps, void SetCursor(const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location, const gfx::Point& location,
int frame_delay_ms) = 0; int frame_delay_ms);
// Update the HW cursor bitmap & move to specified location. If // Update the HW cursor bitmap & move to specified location. If
// the bitmap is empty, the cursor is hidden. // the bitmap is empty, the cursor is hidden.
virtual void SetCursorWithoutAnimations(const std::vector<SkBitmap>& bitmaps, void SetCursorWithoutAnimations(const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location) = 0; const gfx::Point& location);
// Move the HW cursor to the specified location. // Move the HW cursor to the specified location.
virtual void MoveCursor(const gfx::Point& location) = 0; void MoveCursor(const gfx::Point& location);
// DisplayChangeObserver:
void OnDisplayChanged(HardwareDisplayController* controller) override;
void OnDisplayRemoved(HardwareDisplayController* controller) override;
private:
// Draw the last set cursor & update the cursor plane.
void ResetCursor(bool bitmap_only);
// Draw next frame in an animated cursor.
void OnCursorAnimationTimeout();
void UpdateWidgetToDrmDeviceMapping();
// When |controller_| changes this is called to reallocate the cursor buffers
// since the allocation DRM device may have changed.
void UpdateCursorBuffers();
gfx::AcceleratedWidget widget_;
DrmDeviceManager* device_manager_; // Not owned.
ScreenManager* screen_manager_; // Not owned.
// The current bounds of the window.
gfx::Rect bounds_;
// The controller associated with the current window. This may be nullptr if
// the window isn't over an active display.
HardwareDisplayController* controller_;
base::RepeatingTimer<DriWindowDelegate> cursor_timer_;
scoped_refptr<DriBuffer> cursor_buffers_[2];
int cursor_frontbuffer_;
std::vector<SkBitmap> cursor_bitmaps_;
gfx::Point cursor_location_;
int cursor_frame_;
int cursor_frame_delay_ms_;
DISALLOW_COPY_AND_ASSIGN(DriWindowDelegate);
}; };
} // namespace ui } // namespace ui
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_DRI_DRI_WINDOW_DELEGATE_IMPL_H_
#define UI_OZONE_PLATFORM_DRI_DRI_WINDOW_DELEGATE_IMPL_H_
#include "base/timer/timer.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/ozone_export.h"
#include "ui/ozone/platform/dri/display_change_observer.h"
#include "ui/ozone/platform/dri/dri_window_delegate.h"
namespace ui {
class DriBuffer;
class DrmDeviceManager;
class HardwareDisplayController;
class ScreenManager;
class OZONE_EXPORT DriWindowDelegateImpl : public DriWindowDelegate,
public DisplayChangeObserver {
public:
DriWindowDelegateImpl(gfx::AcceleratedWidget widget,
DrmDeviceManager* device_manager,
ScreenManager* screen_manager);
~DriWindowDelegateImpl() override;
// DriWindowDelegate:
void Initialize() override;
void Shutdown() override;
gfx::AcceleratedWidget GetAcceleratedWidget() override;
HardwareDisplayController* GetController() override;
void OnBoundsChanged(const gfx::Rect& bounds) override;
void SetCursor(const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location,
int frame_delay_ms) override;
void SetCursorWithoutAnimations(const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location) override;
void MoveCursor(const gfx::Point& location) override;
// DisplayChangeObserver:
void OnDisplayChanged(HardwareDisplayController* controller) override;
void OnDisplayRemoved(HardwareDisplayController* controller) override;
private:
// Draw the last set cursor & update the cursor plane.
void ResetCursor(bool bitmap_only);
// Draw next frame in an animated cursor.
void OnCursorAnimationTimeout();
void UpdateWidgetToDrmDeviceMapping();
// When |controller_| changes this is called to reallocate the cursor buffers
// since the allocation DRM device may have changed.
void UpdateCursorBuffers();
gfx::AcceleratedWidget widget_;
DrmDeviceManager* device_manager_; // Not owned.
ScreenManager* screen_manager_; // Not owned.
// The current bounds of the window.
gfx::Rect bounds_;
// The controller associated with the current window. This may be nullptr if
// the window isn't over an active display.
HardwareDisplayController* controller_;
base::RepeatingTimer<DriWindowDelegateImpl> cursor_timer_;
scoped_refptr<DriBuffer> cursor_buffers_[2];
int cursor_frontbuffer_;
std::vector<SkBitmap> cursor_bitmaps_;
gfx::Point cursor_location_;
int cursor_frame_;
int cursor_frame_delay_ms_;
DISALLOW_COPY_AND_ASSIGN(DriWindowDelegateImpl);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRI_DRI_WINDOW_DELEGATE_IMPL_H_
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "ui/ozone/platform/dri/dri_buffer.h" #include "ui/ozone/platform/dri/dri_buffer.h"
#include "ui/ozone/platform/dri/dri_surface.h" #include "ui/ozone/platform/dri/dri_surface.h"
#include "ui/ozone/platform/dri/dri_surface_factory.h" #include "ui/ozone/platform/dri/dri_surface_factory.h"
#include "ui/ozone/platform/dri/dri_window_delegate_impl.h" #include "ui/ozone/platform/dri/dri_window_delegate.h"
#include "ui/ozone/platform/dri/dri_window_delegate_manager.h" #include "ui/ozone/platform/dri/dri_window_delegate_manager.h"
#include "ui/ozone/platform/dri/drm_device_manager.h" #include "ui/ozone/platform/dri/drm_device_manager.h"
#include "ui/ozone/platform/dri/hardware_display_controller.h" #include "ui/ozone/platform/dri/hardware_display_controller.h"
...@@ -47,9 +47,9 @@ std::vector<skia::RefPtr<SkSurface>> GetCursorBuffers( ...@@ -47,9 +47,9 @@ std::vector<skia::RefPtr<SkSurface>> GetCursorBuffers(
} // namespace } // namespace
class DriWindowDelegateImplTest : public testing::Test { class DriWindowDelegateTest : public testing::Test {
public: public:
DriWindowDelegateImplTest() {} DriWindowDelegateTest() {}
void SetUp() override; void SetUp() override;
void TearDown() override; void TearDown() override;
...@@ -63,10 +63,10 @@ class DriWindowDelegateImplTest : public testing::Test { ...@@ -63,10 +63,10 @@ class DriWindowDelegateImplTest : public testing::Test {
scoped_ptr<ui::DriWindowDelegateManager> window_delegate_manager_; scoped_ptr<ui::DriWindowDelegateManager> window_delegate_manager_;
private: private:
DISALLOW_COPY_AND_ASSIGN(DriWindowDelegateImplTest); DISALLOW_COPY_AND_ASSIGN(DriWindowDelegateTest);
}; };
void DriWindowDelegateImplTest::SetUp() { void DriWindowDelegateTest::SetUp() {
message_loop_.reset(new base::MessageLoopForUI); message_loop_.reset(new base::MessageLoopForUI);
drm_ = new ui::MockDrmDevice(); drm_ = new ui::MockDrmDevice();
buffer_generator_.reset(new ui::DriBufferGenerator()); buffer_generator_.reset(new ui::DriBufferGenerator());
...@@ -78,10 +78,8 @@ void DriWindowDelegateImplTest::SetUp() { ...@@ -78,10 +78,8 @@ void DriWindowDelegateImplTest::SetUp() {
drm_device_manager_.reset(new ui::DrmDeviceManager(drm_)); drm_device_manager_.reset(new ui::DrmDeviceManager(drm_));
window_delegate_manager_.reset(new ui::DriWindowDelegateManager()); window_delegate_manager_.reset(new ui::DriWindowDelegateManager());
scoped_ptr<ui::DriWindowDelegate> window_delegate( scoped_ptr<ui::DriWindowDelegate> window_delegate(new ui::DriWindowDelegate(
new ui::DriWindowDelegateImpl(kDefaultWidgetHandle, kDefaultWidgetHandle, drm_device_manager_.get(), screen_manager_.get()));
drm_device_manager_.get(),
screen_manager_.get()));
window_delegate->Initialize(); window_delegate->Initialize();
window_delegate->OnBoundsChanged( window_delegate->OnBoundsChanged(
gfx::Rect(gfx::Size(kDefaultMode.hdisplay, kDefaultMode.vdisplay))); gfx::Rect(gfx::Size(kDefaultMode.hdisplay, kDefaultMode.vdisplay)));
...@@ -89,14 +87,14 @@ void DriWindowDelegateImplTest::SetUp() { ...@@ -89,14 +87,14 @@ void DriWindowDelegateImplTest::SetUp() {
window_delegate.Pass()); window_delegate.Pass());
} }
void DriWindowDelegateImplTest::TearDown() { void DriWindowDelegateTest::TearDown() {
scoped_ptr<ui::DriWindowDelegate> delegate = scoped_ptr<ui::DriWindowDelegate> delegate =
window_delegate_manager_->RemoveWindowDelegate(kDefaultWidgetHandle); window_delegate_manager_->RemoveWindowDelegate(kDefaultWidgetHandle);
delegate->Shutdown(); delegate->Shutdown();
message_loop_.reset(); message_loop_.reset();
} }
TEST_F(DriWindowDelegateImplTest, SetCursorImage) { TEST_F(DriWindowDelegateTest, SetCursorImage) {
SkBitmap image; SkBitmap image;
SkImageInfo info = SkImageInfo info =
SkImageInfo::Make(6, 4, kN32_SkColorType, kPremul_SkAlphaType); SkImageInfo::Make(6, 4, kN32_SkColorType, kPremul_SkAlphaType);
...@@ -128,7 +126,7 @@ TEST_F(DriWindowDelegateImplTest, SetCursorImage) { ...@@ -128,7 +126,7 @@ TEST_F(DriWindowDelegateImplTest, SetCursorImage) {
} }
} }
TEST_F(DriWindowDelegateImplTest, CheckCursorSurfaceAfterChangingDevice) { TEST_F(DriWindowDelegateTest, CheckCursorSurfaceAfterChangingDevice) {
// Add another device. // Add another device.
scoped_refptr<ui::MockDrmDevice> drm = new ui::MockDrmDevice(); scoped_refptr<ui::MockDrmDevice> drm = new ui::MockDrmDevice();
screen_manager_->AddDisplayController(drm, kDefaultCrtc, kDefaultConnector); screen_manager_->AddDisplayController(drm, kDefaultCrtc, kDefaultConnector);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "third_party/khronos/EGL/egl.h" #include "third_party/khronos/EGL/egl.h"
#include "ui/ozone/common/egl_util.h" #include "ui/ozone/common/egl_util.h"
#include "ui/ozone/platform/dri/dri_window_delegate_impl.h" #include "ui/ozone/platform/dri/dri_window_delegate.h"
#include "ui/ozone/platform/dri/dri_window_delegate_manager.h" #include "ui/ozone/platform/dri/dri_window_delegate_manager.h"
#include "ui/ozone/platform/dri/drm_device_manager.h" #include "ui/ozone/platform/dri/drm_device_manager.h"
#include "ui/ozone/platform/dri/gbm_buffer.h" #include "ui/ozone/platform/dri/gbm_buffer.h"
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "ui/ozone/platform/dri/dri_surface_factory.h" #include "ui/ozone/platform/dri/dri_surface_factory.h"
#include "ui/ozone/platform/dri/dri_util.h" #include "ui/ozone/platform/dri/dri_util.h"
#include "ui/ozone/platform/dri/dri_window.h" #include "ui/ozone/platform/dri/dri_window.h"
#include "ui/ozone/platform/dri/dri_window_delegate_impl.h" #include "ui/ozone/platform/dri/dri_window_delegate.h"
#include "ui/ozone/platform/dri/dri_window_delegate_manager.h" #include "ui/ozone/platform/dri/dri_window_delegate_manager.h"
#include "ui/ozone/platform/dri/dri_window_manager.h" #include "ui/ozone/platform/dri/dri_window_manager.h"
#include "ui/ozone/platform/dri/drm_device.h" #include "ui/ozone/platform/dri/drm_device.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment