Commit 95517b89 authored by dongseong.hwang's avatar dongseong.hwang Committed by Commit bot

ozone: Clarify All SurfaceFactoryOzone APIs except for CreateNativePixmap()...

ozone: Clarify All SurfaceFactoryOzone APIs except for CreateNativePixmap() must be used on the main thread in Gpu process

CreateNativePixmap() can be used in IO thread because IO thread creates GpuMemoryBuffer for low latency.

BUG=472610

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

Cr-Commit-Position: refs/heads/master@{#330142}
parent ab348a32
...@@ -118,16 +118,19 @@ void CacaWindowManager::RemoveWindow(int window_id, CacaWindow* window) { ...@@ -118,16 +118,19 @@ void CacaWindowManager::RemoveWindow(int window_id, CacaWindow* window) {
} }
CacaWindowManager::~CacaWindowManager() { CacaWindowManager::~CacaWindowManager() {
DCHECK(thread_checker_.CalledOnValidThread());
} }
bool CacaWindowManager::LoadEGLGLES2Bindings( bool CacaWindowManager::LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library, AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) { SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
DCHECK(thread_checker_.CalledOnValidThread());
return false; return false;
} }
scoped_ptr<ui::SurfaceOzoneCanvas> CacaWindowManager::CreateCanvasForWidget( scoped_ptr<ui::SurfaceOzoneCanvas> CacaWindowManager::CreateCanvasForWidget(
gfx::AcceleratedWidget widget) { gfx::AcceleratedWidget widget) {
DCHECK(thread_checker_.CalledOnValidThread());
CacaWindow* window = windows_.Lookup(widget); CacaWindow* window = windows_.Lookup(widget);
DCHECK(window); DCHECK(window);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/id_map.h" #include "base/id_map.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "ui/ozone/public/surface_factory_ozone.h" #include "ui/ozone/public/surface_factory_ozone.h"
namespace gfx { namespace gfx {
...@@ -37,6 +38,7 @@ class CacaWindowManager : public SurfaceFactoryOzone { ...@@ -37,6 +38,7 @@ class CacaWindowManager : public SurfaceFactoryOzone {
private: private:
IDMap<CacaWindow> windows_; IDMap<CacaWindow> windows_;
base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(CacaWindowManager); DISALLOW_COPY_AND_ASSIGN(CacaWindowManager);
}; };
......
...@@ -25,12 +25,14 @@ DrmSurfaceFactory::~DrmSurfaceFactory() { ...@@ -25,12 +25,14 @@ DrmSurfaceFactory::~DrmSurfaceFactory() {
scoped_ptr<ui::SurfaceOzoneCanvas> DrmSurfaceFactory::CreateCanvasForWidget( scoped_ptr<ui::SurfaceOzoneCanvas> DrmSurfaceFactory::CreateCanvasForWidget(
gfx::AcceleratedWidget widget) { gfx::AcceleratedWidget widget) {
DCHECK(thread_checker_.CalledOnValidThread());
return make_scoped_ptr(new DrmSurface(screen_manager_->GetWindow(widget))); return make_scoped_ptr(new DrmSurface(screen_manager_->GetWindow(widget)));
} }
bool DrmSurfaceFactory::LoadEGLGLES2Bindings( bool DrmSurfaceFactory::LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library, AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) { SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
DCHECK(thread_checker_.CalledOnValidThread());
return false; return false;
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define UI_OZONE_PLATFORM_DRM_DRM_SURFACE_FACTORY_H_ #define UI_OZONE_PLATFORM_DRM_DRM_SURFACE_FACTORY_H_
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "ui/ozone/public/surface_factory_ozone.h" #include "ui/ozone/public/surface_factory_ozone.h"
namespace ui { namespace ui {
...@@ -30,6 +31,7 @@ class DrmSurfaceFactory : public SurfaceFactoryOzone { ...@@ -30,6 +31,7 @@ class DrmSurfaceFactory : public SurfaceFactoryOzone {
protected: protected:
ScreenManager* screen_manager_; // Not owned. ScreenManager* screen_manager_; // Not owned.
base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(DrmSurfaceFactory); DISALLOW_COPY_AND_ASSIGN(DrmSurfaceFactory);
}; };
......
...@@ -78,6 +78,7 @@ GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless) ...@@ -78,6 +78,7 @@ GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless)
} }
GbmSurfaceFactory::~GbmSurfaceFactory() { GbmSurfaceFactory::~GbmSurfaceFactory() {
DCHECK(thread_checker_.CalledOnValidThread());
} }
void GbmSurfaceFactory::InitializeGpu(DrmDeviceManager* drm_device_manager, void GbmSurfaceFactory::InitializeGpu(DrmDeviceManager* drm_device_manager,
...@@ -87,11 +88,13 @@ void GbmSurfaceFactory::InitializeGpu(DrmDeviceManager* drm_device_manager, ...@@ -87,11 +88,13 @@ void GbmSurfaceFactory::InitializeGpu(DrmDeviceManager* drm_device_manager,
} }
intptr_t GbmSurfaceFactory::GetNativeDisplay() { intptr_t GbmSurfaceFactory::GetNativeDisplay() {
DCHECK(thread_checker_.CalledOnValidThread());
return EGL_DEFAULT_DISPLAY; return EGL_DEFAULT_DISPLAY;
} }
const int32* GbmSurfaceFactory::GetEGLSurfaceProperties( const int32* GbmSurfaceFactory::GetEGLSurfaceProperties(
const int32* desired_list) { const int32* desired_list) {
DCHECK(thread_checker_.CalledOnValidThread());
static const int32 kConfigAttribs[] = {EGL_BUFFER_SIZE, static const int32 kConfigAttribs[] = {EGL_BUFFER_SIZE,
32, 32,
EGL_ALPHA_SIZE, EGL_ALPHA_SIZE,
...@@ -114,17 +117,20 @@ const int32* GbmSurfaceFactory::GetEGLSurfaceProperties( ...@@ -114,17 +117,20 @@ const int32* GbmSurfaceFactory::GetEGLSurfaceProperties(
bool GbmSurfaceFactory::LoadEGLGLES2Bindings( bool GbmSurfaceFactory::LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library, AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) { SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
DCHECK(thread_checker_.CalledOnValidThread());
return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address); return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address);
} }
scoped_ptr<SurfaceOzoneCanvas> GbmSurfaceFactory::CreateCanvasForWidget( scoped_ptr<SurfaceOzoneCanvas> GbmSurfaceFactory::CreateCanvasForWidget(
gfx::AcceleratedWidget widget) { gfx::AcceleratedWidget widget) {
DCHECK(thread_checker_.CalledOnValidThread());
LOG(FATAL) << "Software rendering mode is not supported with GBM platform"; LOG(FATAL) << "Software rendering mode is not supported with GBM platform";
return nullptr; return nullptr;
} }
scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget(
gfx::AcceleratedWidget widget) { gfx::AcceleratedWidget widget) {
DCHECK(thread_checker_.CalledOnValidThread());
scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget);
DCHECK(gbm); DCHECK(gbm);
...@@ -139,6 +145,7 @@ scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( ...@@ -139,6 +145,7 @@ scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget(
scoped_ptr<SurfaceOzoneEGL> scoped_ptr<SurfaceOzoneEGL>
GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget(
gfx::AcceleratedWidget widget) { gfx::AcceleratedWidget widget) {
DCHECK(thread_checker_.CalledOnValidThread());
if (!allow_surfaceless_) if (!allow_surfaceless_)
return nullptr; return nullptr;
...@@ -171,6 +178,7 @@ scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( ...@@ -171,6 +178,7 @@ scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
OverlayCandidatesOzone* GbmSurfaceFactory::GetOverlayCandidates( OverlayCandidatesOzone* GbmSurfaceFactory::GetOverlayCandidates(
gfx::AcceleratedWidget w) { gfx::AcceleratedWidget w) {
DCHECK(thread_checker_.CalledOnValidThread());
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kOzoneTestSingleOverlaySupport)) switches::kOzoneTestSingleOverlaySupport))
return new SingleOverlay(); return new SingleOverlay();
...@@ -184,6 +192,7 @@ bool GbmSurfaceFactory::ScheduleOverlayPlane( ...@@ -184,6 +192,7 @@ bool GbmSurfaceFactory::ScheduleOverlayPlane(
scoped_refptr<NativePixmap> buffer, scoped_refptr<NativePixmap> buffer,
const gfx::Rect& display_bounds, const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect) { const gfx::RectF& crop_rect) {
DCHECK(thread_checker_.CalledOnValidThread());
scoped_refptr<GbmPixmap> pixmap = static_cast<GbmPixmap*>(buffer.get()); scoped_refptr<GbmPixmap> pixmap = static_cast<GbmPixmap*>(buffer.get());
if (!pixmap.get()) { if (!pixmap.get()) {
LOG(ERROR) << "ScheduleOverlayPlane passed NULL buffer."; LOG(ERROR) << "ScheduleOverlayPlane passed NULL buffer.";
...@@ -196,10 +205,12 @@ bool GbmSurfaceFactory::ScheduleOverlayPlane( ...@@ -196,10 +205,12 @@ bool GbmSurfaceFactory::ScheduleOverlayPlane(
} }
bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() {
DCHECK(thread_checker_.CalledOnValidThread());
return allow_surfaceless_; return allow_surfaceless_;
} }
bool GbmSurfaceFactory::CanCreateNativePixmap(BufferUsage usage) { bool GbmSurfaceFactory::CanCreateNativePixmap(BufferUsage usage) {
DCHECK(thread_checker_.CalledOnValidThread());
switch (usage) { switch (usage) {
case MAP: case MAP:
return false; return false;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/environment.h" #include "base/environment.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/threading/thread_checker.h"
#include "library_loaders/libeglplatform_shim.h" #include "library_loaders/libeglplatform_shim.h"
#include "third_party/khronos/EGL/egl.h" #include "third_party/khronos/EGL/egl.h"
#include "ui/events/devices/device_data_manager.h" #include "ui/events/devices/device_data_manager.h"
...@@ -240,7 +241,9 @@ class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone { ...@@ -240,7 +241,9 @@ class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone {
public: public:
SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim) SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim)
: eglplatform_shim_(eglplatform_shim) {} : eglplatform_shim_(eglplatform_shim) {}
~SurfaceFactoryEgltest() override {} ~SurfaceFactoryEgltest() override {
DCHECK(thread_checker_.CalledOnValidThread());
}
// SurfaceFactoryOzone: // SurfaceFactoryOzone:
intptr_t GetNativeDisplay() override; intptr_t GetNativeDisplay() override;
...@@ -253,14 +256,17 @@ class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone { ...@@ -253,14 +256,17 @@ class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone {
private: private:
LibeglplatformShimLoader* eglplatform_shim_; LibeglplatformShimLoader* eglplatform_shim_;
base::ThreadChecker thread_checker_;
}; };
intptr_t SurfaceFactoryEgltest::GetNativeDisplay() { intptr_t SurfaceFactoryEgltest::GetNativeDisplay() {
DCHECK(thread_checker_.CalledOnValidThread());
return eglplatform_shim_->ShimGetNativeDisplay(); return eglplatform_shim_->ShimGetNativeDisplay();
} }
scoped_ptr<SurfaceOzoneEGL> SurfaceFactoryEgltest::CreateEGLSurfaceForWidget( scoped_ptr<SurfaceOzoneEGL> SurfaceFactoryEgltest::CreateEGLSurfaceForWidget(
gfx::AcceleratedWidget widget) { gfx::AcceleratedWidget widget) {
DCHECK(thread_checker_.CalledOnValidThread());
return make_scoped_ptr<SurfaceOzoneEGL>( return make_scoped_ptr<SurfaceOzoneEGL>(
new SurfaceOzoneEgltest(widget, eglplatform_shim_)); new SurfaceOzoneEgltest(widget, eglplatform_shim_));
} }
...@@ -268,6 +274,7 @@ scoped_ptr<SurfaceOzoneEGL> SurfaceFactoryEgltest::CreateEGLSurfaceForWidget( ...@@ -268,6 +274,7 @@ scoped_ptr<SurfaceOzoneEGL> SurfaceFactoryEgltest::CreateEGLSurfaceForWidget(
bool SurfaceFactoryEgltest::LoadEGLGLES2Bindings( bool SurfaceFactoryEgltest::LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library, AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) { SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
DCHECK(thread_checker_.CalledOnValidThread());
const char* egl_soname = eglplatform_shim_->ShimQueryString(SHIM_EGL_LIBRARY); const char* egl_soname = eglplatform_shim_->ShimQueryString(SHIM_EGL_LIBRARY);
const char* gles_soname = const char* gles_soname =
eglplatform_shim_->ShimQueryString(SHIM_GLES_LIBRARY); eglplatform_shim_->ShimQueryString(SHIM_GLES_LIBRARY);
...@@ -282,6 +289,7 @@ bool SurfaceFactoryEgltest::LoadEGLGLES2Bindings( ...@@ -282,6 +289,7 @@ bool SurfaceFactoryEgltest::LoadEGLGLES2Bindings(
const int32* SurfaceFactoryEgltest::GetEGLSurfaceProperties( const int32* SurfaceFactoryEgltest::GetEGLSurfaceProperties(
const int32* desired_list) { const int32* desired_list) {
DCHECK(thread_checker_.CalledOnValidThread());
static const int32 broken_props[] = { static const int32 broken_props[] = {
EGL_RENDERABLE_TYPE, EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES2_BIT, EGL_OPENGL_ES2_BIT,
......
...@@ -69,6 +69,7 @@ TestWindowManager::TestWindowManager(const base::FilePath& dump_location) ...@@ -69,6 +69,7 @@ TestWindowManager::TestWindowManager(const base::FilePath& dump_location)
} }
TestWindowManager::~TestWindowManager() { TestWindowManager::~TestWindowManager() {
DCHECK(thread_checker_.CalledOnValidThread());
} }
void TestWindowManager::Initialize() { void TestWindowManager::Initialize() {
...@@ -96,6 +97,7 @@ base::FilePath TestWindowManager::base_path() const { ...@@ -96,6 +97,7 @@ base::FilePath TestWindowManager::base_path() const {
scoped_ptr<SurfaceOzoneCanvas> TestWindowManager::CreateCanvasForWidget( scoped_ptr<SurfaceOzoneCanvas> TestWindowManager::CreateCanvasForWidget(
gfx::AcceleratedWidget widget) { gfx::AcceleratedWidget widget) {
DCHECK(thread_checker_.CalledOnValidThread());
TestWindow* window = windows_.Lookup(widget); TestWindow* window = windows_.Lookup(widget);
DCHECK(window); DCHECK(window);
return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(window->path())); return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(window->path()));
...@@ -104,6 +106,7 @@ scoped_ptr<SurfaceOzoneCanvas> TestWindowManager::CreateCanvasForWidget( ...@@ -104,6 +106,7 @@ scoped_ptr<SurfaceOzoneCanvas> TestWindowManager::CreateCanvasForWidget(
bool TestWindowManager::LoadEGLGLES2Bindings( bool TestWindowManager::LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library, AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) { SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
DCHECK(thread_checker_.CalledOnValidThread());
return false; return false;
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/id_map.h" #include "base/id_map.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/test/test_window.h" #include "ui/ozone/platform/test/test_window.h"
#include "ui/ozone/public/surface_factory_ozone.h" #include "ui/ozone/public/surface_factory_ozone.h"
...@@ -42,6 +43,7 @@ class TestWindowManager : public SurfaceFactoryOzone { ...@@ -42,6 +43,7 @@ class TestWindowManager : public SurfaceFactoryOzone {
base::FilePath location_; base::FilePath location_;
IDMap<TestWindow> windows_; IDMap<TestWindow> windows_;
base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(TestWindowManager); DISALLOW_COPY_AND_ASSIGN(TestWindowManager);
}; };
......
...@@ -129,6 +129,7 @@ class OZONE_BASE_EXPORT SurfaceFactoryOzone { ...@@ -129,6 +129,7 @@ class OZONE_BASE_EXPORT SurfaceFactoryOzone {
// Create a single native buffer to be used for overlay planes or zero copy // Create a single native buffer to be used for overlay planes or zero copy
// for |widget| representing a particular display controller or default // for |widget| representing a particular display controller or default
// display controller for kNullAcceleratedWidget. // display controller for kNullAcceleratedWidget.
// It can be called on any thread.
virtual scoped_refptr<NativePixmap> CreateNativePixmap( virtual scoped_refptr<NativePixmap> CreateNativePixmap(
gfx::AcceleratedWidget widget, gfx::AcceleratedWidget widget,
gfx::Size size, gfx::Size size,
......
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