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