Skip to content

Commit

Permalink
ozone: Remove InitializeHardware / ShutdownHardware
Browse files Browse the repository at this point in the history
There's lots of places to run init code:

  1. On platform creation
  2. On window creation
  3. On surface creation
  4. LoadEGLGLES2Bindings
  5. InitializeHardware

InitializeHardware has the least clear contract of the above, and is
only used for one platform, so let's remove it. The documentation is
also misleading, as it's not actually always called when the comment
says it should (prior to StartSandbox).

In order to call InitializeHardware, you need to actually build a
SurfaceFactoryOzone, so let's move the call there, so that the factory
is fully initialized right after creation and so initialization is
internal to the platform code. ShutdownHardware is never actually
called, so that part is easy.

BUG=none
TEST=ran dri & gbm on link_freon
NOTRY=true
TBR=danakj

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284813 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
spang@chromium.org committed Jul 22, 2014
1 parent cf700d7 commit c7594ba
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 66 deletions.
3 changes: 0 additions & 3 deletions content/browser/compositor/software_output_device_ozone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ SoftwareOutputDeviceOzone::SoftwareOutputDeviceOzone(ui::Compositor* compositor)
: compositor_(compositor) {
ui::SurfaceFactoryOzone* factory = ui::SurfaceFactoryOzone::GetInstance();

if (factory->InitializeHardware() != ui::SurfaceFactoryOzone::INITIALIZED)
LOG(FATAL) << "Failed to initialize hardware in OZONE";

surface_ozone_ = factory->CreateCanvasForWidget(compositor_->widget());

if (!surface_ozone_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ class MockSurfaceFactoryOzone : public ui::SurfaceFactoryOzone {
MockSurfaceFactoryOzone() {}
virtual ~MockSurfaceFactoryOzone() {}

virtual HardwareState InitializeHardware() OVERRIDE {
return SurfaceFactoryOzone::INITIALIZED;
}

virtual void ShutdownHardware() OVERRIDE {}
virtual bool LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE {
Expand Down
6 changes: 0 additions & 6 deletions ui/gl/gl_surface_ozone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL {
bool GLSurface::InitializeOneOffInternal() {
switch (GetGLImplementation()) {
case kGLImplementationEGLGLES2:
if (ui::SurfaceFactoryOzone::GetInstance()->InitializeHardware() !=
ui::SurfaceFactoryOzone::INITIALIZED) {
LOG(ERROR) << "Ozone failed to initialize hardware";
return false;
}

if (!GLSurfaceEGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
return false;
Expand Down
7 changes: 0 additions & 7 deletions ui/ozone/platform/caca/caca_window_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,6 @@ void CacaWindowManager::RemoveWindow(int window_id, CacaWindow* window) {
CacaWindowManager::~CacaWindowManager() {
}

ui::SurfaceFactoryOzone::HardwareState CacaWindowManager::InitializeHardware() {
return INITIALIZED;
}

void CacaWindowManager::ShutdownHardware() {
}

bool CacaWindowManager::LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
Expand Down
2 changes: 0 additions & 2 deletions ui/ozone/platform/caca/caca_window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class CacaWindowManager : public SurfaceFactoryOzone {
void RemoveWindow(int32_t window_id, CacaWindow* window);

// ui::SurfaceFactoryOzone overrides:
virtual HardwareState InitializeHardware() OVERRIDE;
virtual void ShutdownHardware() OVERRIDE;
virtual bool LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE;
Expand Down
2 changes: 1 addition & 1 deletion ui/ozone/platform/dri/dri_surface_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ DriSurfaceFactory::~DriSurfaceFactory() {
ShutdownHardware();
}

ui::SurfaceFactoryOzone::HardwareState DriSurfaceFactory::InitializeHardware() {
DriSurfaceFactory::HardwareState DriSurfaceFactory::InitializeHardware() {
if (state_ != UNINITIALIZED)
return state_;

Expand Down
16 changes: 13 additions & 3 deletions ui/ozone/platform/dri/dri_surface_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,19 @@ class DriSurfaceFactory : public ui::SurfaceFactoryOzone,
DriSurfaceFactory(DriWrapper* drm, ScreenManager* screen_manager);
virtual ~DriSurfaceFactory();

// SurfaceFactoryOzone overrides:
virtual HardwareState InitializeHardware() OVERRIDE;
virtual void ShutdownHardware() OVERRIDE;
// Describes the state of the hardware after initialization.
enum HardwareState {
UNINITIALIZED,
INITIALIZED,
FAILED,
};

// Open the display device.
virtual HardwareState InitializeHardware();

// Close the display device.
virtual void ShutdownHardware();

virtual scoped_ptr<ui::SurfaceOzoneCanvas> CreateCanvasForWidget(
gfx::AcceleratedWidget w) OVERRIDE;
virtual bool LoadEGLGLES2Bindings(
Expand Down
8 changes: 4 additions & 4 deletions ui/ozone/platform/dri/dri_surface_factory_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ void DriSurfaceFactoryTest::TearDown() {

TEST_F(DriSurfaceFactoryTest, FailInitialization) {
dri_->fail_init();
EXPECT_EQ(ui::SurfaceFactoryOzone::FAILED, factory_->InitializeHardware());
EXPECT_EQ(ui::DriSurfaceFactory::FAILED, factory_->InitializeHardware());
}

TEST_F(DriSurfaceFactoryTest, SuccessfulInitialization) {
EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED,
EXPECT_EQ(ui::DriSurfaceFactory::INITIALIZED,
factory_->InitializeHardware());
}

TEST_F(DriSurfaceFactoryTest, SuccessfulWidgetRealization) {
EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED,
EXPECT_EQ(ui::DriSurfaceFactory::INITIALIZED,
factory_->InitializeHardware());

gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget();
Expand All @@ -99,7 +99,7 @@ TEST_F(DriSurfaceFactoryTest, SuccessfulWidgetRealization) {
}

TEST_F(DriSurfaceFactoryTest, SetCursorImage) {
EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED,
EXPECT_EQ(ui::DriSurfaceFactory::INITIALIZED,
factory_->InitializeHardware());

gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget();
Expand Down
4 changes: 4 additions & 0 deletions ui/ozone/platform/dri/ozone_platform_dri.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class OzonePlatformDri : public OzonePlatform {
new CursorFactoryEvdevDri(surface_factory_ozone_.get()));
event_factory_ozone_.reset(new EventFactoryEvdev(
cursor_factory_ozone_.get(), device_manager_.get()));
if (surface_factory_ozone_->InitializeHardware() !=
DriSurfaceFactory::INITIALIZED)
LOG(FATAL) << "failed to initialize display hardware";

}

virtual void InitializeGPU() OVERRIDE {}
Expand Down
4 changes: 3 additions & 1 deletion ui/ozone/platform/dri/ozone_platform_gbm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ class OzonePlatformGbm : public OzonePlatform {
surface_factory_ozone_->InitializeGpu(dri_.get(),
buffer_generator_->device(),
screen_manager_.get());

gpu_platform_support_.reset(
new GpuPlatformSupportGbm(surface_factory_ozone_.get()));
#if defined(OS_CHROMEOS)
Expand All @@ -148,6 +147,9 @@ class OzonePlatformGbm : public OzonePlatform {
screen_manager_.get(),
NULL)))));
#endif
if (surface_factory_ozone_->InitializeHardware() !=
DriSurfaceFactory::INITIALIZED)
LOG(FATAL) << "failed to initialize display hardware";
}

private:
Expand Down
10 changes: 0 additions & 10 deletions ui/ozone/platform/egltest/ozone_platform_egltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone {
virtual ~SurfaceFactoryEgltest() {}

// SurfaceFactoryOzone:
virtual HardwareState InitializeHardware() OVERRIDE;
virtual void ShutdownHardware() OVERRIDE;
virtual intptr_t GetNativeDisplay() OVERRIDE;
virtual scoped_ptr<SurfaceOzoneEGL> CreateEGLSurfaceForWidget(
gfx::AcceleratedWidget widget) OVERRIDE;
Expand All @@ -212,14 +210,6 @@ class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone {
LibeglplatformShimLoader* eglplatform_shim_;
};

SurfaceFactoryEgltest::HardwareState
SurfaceFactoryEgltest::InitializeHardware() {
return INITIALIZED;
}

void SurfaceFactoryEgltest::ShutdownHardware() {
}

intptr_t SurfaceFactoryEgltest::GetNativeDisplay() {
return eglplatform_shim_->ShimGetNativeDisplay();
}
Expand Down
7 changes: 0 additions & 7 deletions ui/ozone/platform/test/test_window_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ base::FilePath TestWindowManager::base_path() const {
return location_;
}

SurfaceFactoryOzone::HardwareState TestWindowManager::InitializeHardware() {
return INITIALIZED;
}

void TestWindowManager::ShutdownHardware() {
}

scoped_ptr<SurfaceOzoneCanvas> TestWindowManager::CreateCanvasForWidget(
gfx::AcceleratedWidget widget) {
TestWindow* window = windows_.Lookup(widget);
Expand Down
2 changes: 0 additions & 2 deletions ui/ozone/platform/test/test_window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class TestWindowManager : public SurfaceFactoryOzone {
base::FilePath base_path() const;

// SurfaceFactoryOzone:
virtual HardwareState InitializeHardware() OVERRIDE;
virtual void ShutdownHardware() OVERRIDE;
virtual scoped_ptr<SurfaceOzoneCanvas> CreateCanvasForWidget(
gfx::AcceleratedWidget w) OVERRIDE;
virtual bool LoadEGLGLES2Bindings(
Expand Down
15 changes: 0 additions & 15 deletions ui/ozone/public/surface_factory_ozone.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ class SurfaceOzoneEGL;
// modes (See comments bellow for descriptions).
class OZONE_BASE_EXPORT SurfaceFactoryOzone {
public:
// Describes the state of the hardware after initialization.
enum HardwareState {
UNINITIALIZED,
INITIALIZED,
FAILED,
};

// Describes overlay buffer format.
// TODO: this is a placeholder for now and will be populated with more
// formats once we know what sorts of content, video, etc. we can support.
Expand All @@ -85,14 +78,6 @@ class OZONE_BASE_EXPORT SurfaceFactoryOzone {
// Returns the singleton instance.
static SurfaceFactoryOzone* GetInstance();

// Configures the display hardware. Must be called from within the GPU
// process before the sandbox has been activated.
virtual HardwareState InitializeHardware() = 0;

// Cleans up display hardware state. Call this from within the GPU process.
// This method must be safe to run inside of the sandbox.
virtual void ShutdownHardware() = 0;

// Returns native platform display handle. This is used to obtain the EGL
// display connection for the native display.
virtual intptr_t GetNativeDisplay();
Expand Down

0 comments on commit c7594ba

Please sign in to comment.