Commit b5b7198a authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

[ozone/common/drm] Avoid forward declaration on not declared deps.

Make sure forward declaration is not used to just avoid
declaring dependencies in the common/BUILD.gn.

That is, DrmDevice is a drm platform's class, which shouldn't be known
by the ozone/common.

To fix this, return GbmDeviceLinux instead and add AsGbmDeviceLinux method
to the DrmDevice class to return downcasted pointer to self, and move
ScanoutBufferGenerator to drm/gpu as long as it's not needed by the
Wayland with dmabuf approach at this stage.

Bug: 820047
Change-Id: I25703db41234275e0c0cb5aaefe0e61964a50e83
Reviewed-on: https://chromium-review.googlesource.com/1088690Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#565574}
parent 3425b297
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
namespace ui { namespace ui {
class DrmDevice; class GbmDeviceLinux;
// Abstraction for a DRM buffer that can be scanned-out of. // Abstraction for a DRM buffer that can be scanned-out of.
class ScanoutBuffer : public base::RefCountedThreadSafe<ScanoutBuffer> { class ScanoutBuffer : public base::RefCountedThreadSafe<ScanoutBuffer> {
...@@ -44,7 +44,7 @@ class ScanoutBuffer : public base::RefCountedThreadSafe<ScanoutBuffer> { ...@@ -44,7 +44,7 @@ class ScanoutBuffer : public base::RefCountedThreadSafe<ScanoutBuffer> {
virtual gfx::Size GetSize() const = 0; virtual gfx::Size GetSize() const = 0;
// Device on which the buffer was created. // Device on which the buffer was created.
virtual const DrmDevice* GetDrmDevice() const = 0; virtual const GbmDeviceLinux* GetGbmDeviceLinux() const = 0;
virtual bool RequiresGlFinish() const = 0; virtual bool RequiresGlFinish() const = 0;
...@@ -54,17 +54,6 @@ class ScanoutBuffer : public base::RefCountedThreadSafe<ScanoutBuffer> { ...@@ -54,17 +54,6 @@ class ScanoutBuffer : public base::RefCountedThreadSafe<ScanoutBuffer> {
friend class base::RefCountedThreadSafe<ScanoutBuffer>; friend class base::RefCountedThreadSafe<ScanoutBuffer>;
}; };
class ScanoutBufferGenerator {
public:
virtual ~ScanoutBufferGenerator() {}
virtual scoped_refptr<ScanoutBuffer> Create(
const scoped_refptr<DrmDevice>& drm,
uint32_t format,
const std::vector<uint64_t>& modifiers,
const gfx::Size& size) = 0;
};
} // namespace ui } // namespace ui
#endif // UI_OZONE_COMMON_LINUX_SCANOUT_BUFFER_H_ #endif // UI_OZONE_COMMON_LINUX_SCANOUT_BUFFER_H_
...@@ -78,6 +78,7 @@ source_set("gbm") { ...@@ -78,6 +78,7 @@ source_set("gbm") {
"gpu/page_flip_request.h", "gpu/page_flip_request.h",
"gpu/proxy_helpers.cc", "gpu/proxy_helpers.cc",
"gpu/proxy_helpers.h", "gpu/proxy_helpers.h",
"gpu/scanout_buffer_generator.h",
"gpu/screen_manager.cc", "gpu/screen_manager.cc",
"gpu/screen_manager.h", "gpu/screen_manager.h",
"host/drm_cursor.cc", "host/drm_cursor.cc",
......
...@@ -117,8 +117,8 @@ gfx::Size DrmBuffer::GetSize() const { ...@@ -117,8 +117,8 @@ gfx::Size DrmBuffer::GetSize() const {
return gfx::Size(surface_->width(), surface_->height()); return gfx::Size(surface_->width(), surface_->height());
} }
const DrmDevice* DrmBuffer::GetDrmDevice() const { const GbmDeviceLinux* DrmBuffer::GetGbmDeviceLinux() const {
return drm_.get(); return drm_->AsGbmDeviceLinux();
} }
bool DrmBuffer::RequiresGlFinish() const { bool DrmBuffer::RequiresGlFinish() const {
......
...@@ -19,6 +19,7 @@ class SkSurface; ...@@ -19,6 +19,7 @@ class SkSurface;
namespace ui { namespace ui {
class DrmDevice; class DrmDevice;
class GbmDeviceLinux;
// Wrapper for a DRM allocated buffer. Keeps track of the native properties of // Wrapper for a DRM allocated buffer. Keeps track of the native properties of
// the buffer and wraps the pixel memory into a SkSurface which can be used to // the buffer and wraps the pixel memory into a SkSurface which can be used to
...@@ -43,7 +44,7 @@ class DrmBuffer : public ScanoutBuffer { ...@@ -43,7 +44,7 @@ class DrmBuffer : public ScanoutBuffer {
uint64_t GetFormatModifier() const override; uint64_t GetFormatModifier() const override;
uint32_t GetHandle() const override; uint32_t GetHandle() const override;
gfx::Size GetSize() const override; gfx::Size GetSize() const override;
const DrmDevice* GetDrmDevice() const override; const GbmDeviceLinux* GetGbmDeviceLinux() const override;
bool RequiresGlFinish() const override; bool RequiresGlFinish() const override;
protected: protected:
......
...@@ -79,6 +79,8 @@ class DrmDevice : public GbmDeviceLinux, ...@@ -79,6 +79,8 @@ class DrmDevice : public GbmDeviceLinux,
bool allow_addfb2_modifiers() const { return allow_addfb2_modifiers_; } bool allow_addfb2_modifiers() const { return allow_addfb2_modifiers_; }
const GbmDeviceLinux* AsGbmDeviceLinux() const { return this; }
// Open device. // Open device.
virtual bool Initialize(); virtual bool Initialize();
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ui/ozone/platform/drm/gpu/drm_device.h" #include "ui/ozone/platform/drm/gpu/drm_device.h"
#include "ui/ozone/platform/drm/gpu/drm_window.h" #include "ui/ozone/platform/drm/gpu/drm_window.h"
#include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
#include "ui/ozone/platform/drm/gpu/scanout_buffer_generator.h"
namespace ui { namespace ui {
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "ui/ozone/platform/drm/gpu/gbm_device.h" #include "ui/ozone/platform/drm/gpu/gbm_device.h"
#include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h"
#include "ui/ozone/platform/drm/gpu/proxy_helpers.h" #include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
#include "ui/ozone/platform/drm/gpu/scanout_buffer_generator.h"
#include "ui/ozone/platform/drm/gpu/screen_manager.h" #include "ui/ozone/platform/drm/gpu/screen_manager.h"
#include "ui/ozone/public/ozone_switches.h" #include "ui/ozone/public/ozone_switches.h"
......
...@@ -119,7 +119,8 @@ bool DrmWindow::SchedulePageFlip(const std::vector<OverlayPlane>& planes, ...@@ -119,7 +119,8 @@ bool DrmWindow::SchedulePageFlip(const std::vector<OverlayPlane>& planes,
if (controller_) { if (controller_) {
const DrmDevice* drm = controller_->GetAllocationDrmDevice().get(); const DrmDevice* drm = controller_->GetAllocationDrmDevice().get();
for (const auto& plane : planes) { for (const auto& plane : planes) {
if (plane.buffer && plane.buffer->GetDrmDevice() != drm) { if (plane.buffer &&
plane.buffer->GetGbmDeviceLinux() != drm->AsGbmDeviceLinux()) {
// Although |force_buffer_reallocation_| is set to true during window // Although |force_buffer_reallocation_| is set to true during window
// bounds update, this may still be needed because of in-flight buffers. // bounds update, this may still be needed because of in-flight buffers.
force_buffer_reallocation_ = true; force_buffer_reallocation_ = true;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "third_party/skia/include/core/SkImageInfo.h" #include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/core/SkSurface.h"
#include "ui/gfx/presentation_feedback.h" #include "ui/gfx/presentation_feedback.h"
#include "ui/ozone/common/linux/scanout_buffer.h"
#include "ui/ozone/platform/drm/gpu/drm_device_generator.h" #include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
#include "ui/ozone/platform/drm/gpu/drm_device_manager.h" #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
#include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
......
...@@ -164,8 +164,8 @@ uint64_t GbmBuffer::GetFormatModifier() const { ...@@ -164,8 +164,8 @@ uint64_t GbmBuffer::GetFormatModifier() const {
return format_modifier_; return format_modifier_;
} }
const DrmDevice* GbmBuffer::GetDrmDevice() const { const GbmDeviceLinux* GbmBuffer::GetGbmDeviceLinux() const {
return drm_.get(); return drm_->AsGbmDeviceLinux();
} }
bool GbmBuffer::RequiresGlFinish() const { bool GbmBuffer::RequiresGlFinish() const {
......
...@@ -60,7 +60,7 @@ class GbmBuffer : public ScanoutBuffer { ...@@ -60,7 +60,7 @@ class GbmBuffer : public ScanoutBuffer {
uint32_t GetFramebufferPixelFormat() const override; uint32_t GetFramebufferPixelFormat() const override;
uint32_t GetOpaqueFramebufferPixelFormat() const override; uint32_t GetOpaqueFramebufferPixelFormat() const override;
uint64_t GetFormatModifier() const override; uint64_t GetFormatModifier() const override;
const DrmDevice* GetDrmDevice() const override; const GbmDeviceLinux* GetGbmDeviceLinux() const override;
bool RequiresGlFinish() const override; bool RequiresGlFinish() const override;
private: private:
......
...@@ -7,10 +7,12 @@ ...@@ -7,10 +7,12 @@
#include "base/macros.h" #include "base/macros.h"
#include "ui/ozone/common/linux/scanout_buffer.h" #include "ui/ozone/platform/drm/gpu/scanout_buffer_generator.h"
namespace ui { namespace ui {
class ScanoutBuffer;
class MockDumbBufferGenerator : public ScanoutBufferGenerator { class MockDumbBufferGenerator : public ScanoutBufferGenerator {
public: public:
MockDumbBufferGenerator(); MockDumbBufferGenerator();
......
...@@ -54,8 +54,8 @@ uint64_t MockScanoutBuffer::GetFormatModifier() const { ...@@ -54,8 +54,8 @@ uint64_t MockScanoutBuffer::GetFormatModifier() const {
return modifier_; return modifier_;
} }
const DrmDevice* MockScanoutBuffer::GetDrmDevice() const { const GbmDeviceLinux* MockScanoutBuffer::GetGbmDeviceLinux() const {
return drm_.get(); return drm_->AsGbmDeviceLinux();
} }
bool MockScanoutBuffer::RequiresGlFinish() const { bool MockScanoutBuffer::RequiresGlFinish() const {
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
namespace ui { namespace ui {
class DrmDevice;
class MockScanoutBuffer : public ScanoutBuffer { class MockScanoutBuffer : public ScanoutBuffer {
public: public:
MockScanoutBuffer(const gfx::Size& size, MockScanoutBuffer(const gfx::Size& size,
...@@ -28,7 +30,7 @@ class MockScanoutBuffer : public ScanoutBuffer { ...@@ -28,7 +30,7 @@ class MockScanoutBuffer : public ScanoutBuffer {
uint32_t GetFramebufferPixelFormat() const override; uint32_t GetFramebufferPixelFormat() const override;
uint32_t GetOpaqueFramebufferPixelFormat() const override; uint32_t GetOpaqueFramebufferPixelFormat() const override;
uint64_t GetFormatModifier() const override; uint64_t GetFormatModifier() const override;
const DrmDevice* GetDrmDevice() const override; const GbmDeviceLinux* GetGbmDeviceLinux() const override;
bool RequiresGlFinish() const override; bool RequiresGlFinish() const override;
private: private:
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "ui/ozone/common/linux/scanout_buffer.h" #include "ui/ozone/platform/drm/gpu/scanout_buffer_generator.h"
namespace ui { namespace ui {
......
// Copyright 2018 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_DRM_GPU_SCANOUT_BUFFER_GENERATOR_H_
#define UI_OZONE_PLATFORM_DRM_GPU_SCANOUT_BUFFER_GENERATOR_H_
#include <vector>
#include "base/memory/scoped_refptr.h"
#include "ui/gfx/geometry/size.h"
namespace ui {
class DrmDevice;
class ScanoutBuffer;
class ScanoutBufferGenerator {
public:
virtual ~ScanoutBufferGenerator() {}
virtual scoped_refptr<ScanoutBuffer> Create(
const scoped_refptr<DrmDevice>& drm,
uint32_t format,
const std::vector<uint64_t>& modifiers,
const gfx::Size& size) = 0;
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRM_GPU_SCANOUT_BUFFER_GENERATOR_H_
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "ui/ozone/platform/drm/gpu/drm_device.h" #include "ui/ozone/platform/drm/gpu/drm_device.h"
#include "ui/ozone/platform/drm/gpu/drm_window.h" #include "ui/ozone/platform/drm/gpu/drm_window.h"
#include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
#include "ui/ozone/platform/drm/gpu/scanout_buffer_generator.h"
namespace ui { namespace ui {
...@@ -356,7 +357,7 @@ OverlayPlane ScreenManager::GetModesetBuffer( ...@@ -356,7 +357,7 @@ OverlayPlane ScreenManager::GetModesetBuffer(
const OverlayPlane* primary = window->GetLastModesetBuffer(); const OverlayPlane* primary = window->GetLastModesetBuffer();
const DrmDevice* drm = controller->GetAllocationDrmDevice().get(); const DrmDevice* drm = controller->GetAllocationDrmDevice().get();
if (primary && primary->buffer->GetSize() == bounds.size() && if (primary && primary->buffer->GetSize() == bounds.size() &&
primary->buffer->GetDrmDevice() == drm) { primary->buffer->GetGbmDeviceLinux() == drm->AsGbmDeviceLinux()) {
// If the controller doesn't advertise modifiers, wont have a // If the controller doesn't advertise modifiers, wont have a
// modifier either and we can reuse the buffer. Otherwise, check // modifier either and we can reuse the buffer. Otherwise, check
// to see if the controller supports the buffers format // to see if the controller supports the buffers format
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/files/platform_file.h" #include "base/files/platform_file.h"
#include "base/macros.h" #include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/ozone/common/linux/scanout_buffer.h"
#include "ui/ozone/platform/drm/gpu/crtc_controller.h" #include "ui/ozone/platform/drm/gpu/crtc_controller.h"
#include "ui/ozone/platform/drm/gpu/drm_device_generator.h" #include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
#include "ui/ozone/platform/drm/gpu/drm_device_manager.h" #include "ui/ozone/platform/drm/gpu/drm_device_manager.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