summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorzea <zea@chromium.org>2015-06-04 13:27:32 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-04 20:28:01 +0000
commitde77023ebd80bf7f55fc470cb325a7feffd4e2b2 (patch)
tree260954921c7af41f583a1cfd0a6713f166e26a85 /ui
parent15db234366e75e9e3c708f47092c3a3fb3cccbdb (diff)
downloadchromium_src-de77023ebd80bf7f55fc470cb325a7feffd4e2b2.zip
chromium_src-de77023ebd80bf7f55fc470cb325a7feffd4e2b2.tar.gz
chromium_src-de77023ebd80bf7f55fc470cb325a7feffd4e2b2.tar.bz2
Revert of ozone: Remove singleton pattern for SurfaceFactoryOzone. (patchset #1 id:1 of https://codereview.chromium.org/1159493010/)
Reason for revert: Broke Linux ChromiumOS compile. http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Ozone%20Builder/builds/17764/steps/compile/logs/stdio#error1 Original issue's description: > ozone: Remove singleton pattern for SurfaceFactoryOzone. > > OzonePlatform is sigleton already, so it's not necessary for > SurfaceFactoryOzone to be singleton. > > Committed: https://crrev.com/48b0a7165bd6c9d889fc6d6959a6e59cf7ef9dc6 > Cr-Commit-Position: refs/heads/master@{#332889} TBR=spang@chromium.org,sievers@chromium.org,alexst@chromium.org,dongseong.hwang@intel.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1167533007 Cr-Commit-Position: refs/heads/master@{#332899}
Diffstat (limited to 'ui')
-rw-r--r--ui/gl/gl_implementation_ozone.cc7
-rw-r--r--ui/gl/gl_surface_egl.cc7
-rw-r--r--ui/gl/gl_surface_ozone.cc40
-rw-r--r--ui/ozone/demo/software_renderer.cc5
-rw-r--r--ui/ozone/gpu/BUILD.gn2
-rw-r--r--ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc20
-rw-r--r--ui/ozone/gpu/ozone_gpu.gyp2
-rw-r--r--ui/ozone/public/surface_factory_ozone.cc12
-rw-r--r--ui/ozone/public/surface_factory_ozone.h17
9 files changed, 54 insertions, 58 deletions
diff --git a/ui/gl/gl_implementation_ozone.cc b/ui/gl/gl_implementation_ozone.cc
index 715084f..2a85720 100644
--- a/ui/gl/gl_implementation_ozone.cc
+++ b/ui/gl/gl_implementation_ozone.cc
@@ -44,10 +44,9 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {
case kGLImplementationOSMesaGL:
return InitializeStaticGLBindingsOSMesaGL();
case kGLImplementationEGLGLES2:
- if (!ui::OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
- ->LoadEGLGLES2Bindings(base::Bind(&AddGLNativeLibrary),
- base::Bind(&SetGLGetProcAddressProc)))
+ if (!ui::SurfaceFactoryOzone::GetInstance()->LoadEGLGLES2Bindings(
+ base::Bind(&AddGLNativeLibrary),
+ base::Bind(&SetGLGetProcAddressProc)))
return false;
SetGLImplementation(kGLImplementationEGLGLES2);
InitializeStaticGLBindingsGL();
diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc
index 2e193a5..4d64da7 100644
--- a/ui/gl/gl_surface_egl.cc
+++ b/ui/gl/gl_surface_egl.cc
@@ -30,7 +30,6 @@ extern "C" {
#endif
#if defined (USE_OZONE)
-#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
#endif
@@ -306,9 +305,9 @@ bool GLSurfaceEGL::InitializeOneOff() {
};
#if defined(USE_OZONE)
- const EGLint* config_attribs = ui::OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
- ->GetEGLSurfaceProperties(kConfigAttribs);
+ const EGLint* config_attribs =
+ ui::SurfaceFactoryOzone::GetInstance()->GetEGLSurfaceProperties(
+ kConfigAttribs);
#else
const EGLint* config_attribs = kConfigAttribs;
#endif
diff --git a/ui/gl/gl_surface_ozone.cc b/ui/gl/gl_surface_ozone.cc
index c778358..3b2e76a 100644
--- a/ui/gl/gl_surface_ozone.cc
+++ b/ui/gl/gl_surface_ozone.cc
@@ -23,7 +23,6 @@
#include "ui/gl/scoped_binders.h"
#include "ui/gl/scoped_make_current.h"
#include "ui/ozone/public/native_pixmap.h"
-#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
#include "ui/ozone/public/surface_ozone_egl.h"
@@ -119,8 +118,7 @@ bool GLSurfaceOzoneEGL::ReinitializeNativeSurface() {
}
Destroy();
- ozone_surface_ = ui::OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
+ ozone_surface_ = ui::SurfaceFactoryOzone::GetInstance()
->CreateEGLSurfaceForWidget(widget_)
.Pass();
if (!ozone_surface_) {
@@ -480,10 +478,8 @@ bool GLSurfaceOzoneSurfacelessSurfaceImpl::SurfaceImage::ScheduleOverlayPlane(
gfx::OverlayTransform transform,
const gfx::Rect& bounds_rect,
const gfx::RectF& crop_rect) {
- return ui::OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
- ->ScheduleOverlayPlane(widget, z_order, transform, pixmap_, bounds_rect,
- crop_rect);
+ return ui::SurfaceFactoryOzone::GetInstance()->ScheduleOverlayPlane(
+ widget, z_order, transform, pixmap_, bounds_rect, crop_rect);
}
GLSurfaceOzoneSurfacelessSurfaceImpl::SurfaceImage::~SurfaceImage() {
@@ -588,11 +584,9 @@ bool GLSurfaceOzoneSurfacelessSurfaceImpl::CreatePixmaps() {
return true;
for (size_t i = 0; i < arraysize(textures_); i++) {
scoped_refptr<ui::NativePixmap> pixmap =
- ui::OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
- ->CreateNativePixmap(widget_, GetSize(),
- ui::SurfaceFactoryOzone::BGRA_8888,
- ui::SurfaceFactoryOzone::SCANOUT);
+ ui::SurfaceFactoryOzone::GetInstance()->CreateNativePixmap(
+ widget_, GetSize(), ui::SurfaceFactoryOzone::BGRA_8888,
+ ui::SurfaceFactoryOzone::SCANOUT);
if (!pixmap)
return false;
scoped_refptr<SurfaceImage> image =
@@ -634,12 +628,9 @@ scoped_refptr<GLSurface> GLSurface::CreateSurfacelessViewGLSurface(
if (GetGLImplementation() == kGLImplementationEGLGLES2 &&
window != kNullAcceleratedWidget &&
GLSurfaceEGL::IsEGLSurfacelessContextSupported() &&
- ui::OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
- ->CanShowPrimaryPlaneAsOverlay()) {
+ ui::SurfaceFactoryOzone::GetInstance()->CanShowPrimaryPlaneAsOverlay()) {
scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone =
- ui::OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
+ ui::SurfaceFactoryOzone::GetInstance()
->CreateSurfacelessEGLSurfaceForWidget(window);
if (!surface_ozone)
return nullptr;
@@ -665,12 +656,10 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
if (window != kNullAcceleratedWidget) {
scoped_refptr<GLSurface> surface;
if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() &&
- ui::OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
+ ui::SurfaceFactoryOzone::GetInstance()
->CanShowPrimaryPlaneAsOverlay()) {
scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone =
- ui::OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
+ ui::SurfaceFactoryOzone::GetInstance()
->CreateSurfacelessEGLSurfaceForWidget(window);
if (!surface_ozone)
return NULL;
@@ -678,9 +667,8 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
window);
} else {
scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone =
- ui::OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
- ->CreateEGLSurfaceForWidget(window);
+ ui::SurfaceFactoryOzone::GetInstance()->CreateEGLSurfaceForWidget(
+ window);
if (!surface_ozone)
return NULL;
@@ -730,9 +718,7 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
}
EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() {
- return ui::OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
- ->GetNativeDisplay();
+ return ui::SurfaceFactoryOzone::GetInstance()->GetNativeDisplay();
}
} // namespace gfx
diff --git a/ui/ozone/demo/software_renderer.cc b/ui/ozone/demo/software_renderer.cc
index 6687559..45cbd7c 100644
--- a/ui/ozone/demo/software_renderer.cc
+++ b/ui/ozone/demo/software_renderer.cc
@@ -28,9 +28,8 @@ SoftwareRenderer::~SoftwareRenderer() {
}
bool SoftwareRenderer::Initialize() {
- software_surface_ = ui::OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
- ->CreateCanvasForWidget(widget_);
+ software_surface_ =
+ ui::SurfaceFactoryOzone::GetInstance()->CreateCanvasForWidget(widget_);
if (!software_surface_) {
LOG(ERROR) << "Failed to create software surface";
return false;
diff --git a/ui/ozone/gpu/BUILD.gn b/ui/ozone/gpu/BUILD.gn
index 43fd615..b59bf37 100644
--- a/ui/ozone/gpu/BUILD.gn
+++ b/ui/ozone/gpu/BUILD.gn
@@ -17,6 +17,6 @@ component("gpu") {
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/gl",
- "//ui/ozone:ozone",
+ "//ui/ozone:ozone_base",
]
}
diff --git a/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc b/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
index babdc67..df7fca4 100644
--- a/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
+++ b/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
@@ -8,7 +8,6 @@
#include "ui/gl/gl_image_egl.h"
#include "ui/gl/gl_image_linux_dma_buffer.h"
#include "ui/ozone/public/native_pixmap.h"
-#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
#include "ui/ozone/public/surface_ozone_egl.h"
@@ -36,10 +35,8 @@ class GLImageOzoneNativePixmap : public gfx::GLImageEGL {
gfx::OverlayTransform transform,
const gfx::Rect& bounds_rect,
const gfx::RectF& crop_rect) override {
- return OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
- ->ScheduleOverlayPlane(widget, z_order, transform, pixmap_, bounds_rect,
- crop_rect);
+ return SurfaceFactoryOzone::GetInstance()->ScheduleOverlayPlane(
+ widget, z_order, transform, pixmap_, bounds_rect, crop_rect);
}
protected:
@@ -75,10 +72,8 @@ class GLImageOzoneNativePixmapDmaBuf : public gfx::GLImageLinuxDMABuffer {
gfx::OverlayTransform transform,
const gfx::Rect& bounds_rect,
const gfx::RectF& crop_rect) override {
- return OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
- ->ScheduleOverlayPlane(widget, z_order, transform, pixmap_, bounds_rect,
- crop_rect);
+ return SurfaceFactoryOzone::GetInstance()->ScheduleOverlayPlane(
+ widget, z_order, transform, pixmap_, bounds_rect, crop_rect);
}
protected:
@@ -149,10 +144,9 @@ bool GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer(
int client_id,
gfx::PluginWindowHandle surface_handle) {
scoped_refptr<NativePixmap> pixmap =
- OzonePlatform::GetInstance()
- ->GetSurfaceFactoryOzone()
- ->CreateNativePixmap(surface_handle, size, GetOzoneFormatFor(format),
- GetOzoneUsageFor(usage));
+ SurfaceFactoryOzone::GetInstance()->CreateNativePixmap(
+ surface_handle, size, GetOzoneFormatFor(format),
+ GetOzoneUsageFor(usage));
if (!pixmap.get()) {
LOG(ERROR) << "Failed to create pixmap " << size.width() << "x"
<< size.height() << " format " << format << ", usage " << usage;
diff --git a/ui/ozone/gpu/ozone_gpu.gyp b/ui/ozone/gpu/ozone_gpu.gyp
index e6e2b65..cbc895d 100644
--- a/ui/ozone/gpu/ozone_gpu.gyp
+++ b/ui/ozone/gpu/ozone_gpu.gyp
@@ -15,7 +15,7 @@
'../../gfx/gfx.gyp:gfx',
'../../gfx/gfx.gyp:gfx_geometry',
'../../gl/gl.gyp:gl',
- '../ozone.gyp:ozone',
+ '../ozone.gyp:ozone_base',
],
'defines': [
'OZONE_GPU_IMPLEMENTATION',
diff --git a/ui/ozone/public/surface_factory_ozone.cc b/ui/ozone/public/surface_factory_ozone.cc
index 09344c4..c4efc06 100644
--- a/ui/ozone/public/surface_factory_ozone.cc
+++ b/ui/ozone/public/surface_factory_ozone.cc
@@ -13,10 +13,22 @@
namespace ui {
+// static
+SurfaceFactoryOzone* SurfaceFactoryOzone::impl_ = NULL;
+
SurfaceFactoryOzone::SurfaceFactoryOzone() {
+ DCHECK(!impl_) << "There should only be a single SurfaceFactoryOzone.";
+ impl_ = this;
}
SurfaceFactoryOzone::~SurfaceFactoryOzone() {
+ DCHECK_EQ(impl_, this);
+ impl_ = NULL;
+}
+
+SurfaceFactoryOzone* SurfaceFactoryOzone::GetInstance() {
+ DCHECK(impl_) << "No SurfaceFactoryOzone implementation set.";
+ return impl_;
}
intptr_t SurfaceFactoryOzone::GetNativeDisplay() {
diff --git a/ui/ozone/public/surface_factory_ozone.h b/ui/ozone/public/surface_factory_ozone.h
index 678976b..3a50996 100644
--- a/ui/ozone/public/surface_factory_ozone.h
+++ b/ui/ozone/public/surface_factory_ozone.h
@@ -8,11 +8,16 @@
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/native_library.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/overlay_transform.h"
#include "ui/ozone/ozone_base_export.h"
+class SkBitmap;
+class SkCanvas;
+
namespace ui {
class NativePixmap;
@@ -73,6 +78,12 @@ class OZONE_BASE_EXPORT SurfaceFactoryOzone {
typedef base::Callback<void(GLGetProcAddressProc)>
SetGLGetProcAddressProcCallback;
+ SurfaceFactoryOzone();
+ virtual ~SurfaceFactoryOzone();
+
+ // Returns the singleton instance.
+ static SurfaceFactoryOzone* GetInstance();
+
// Returns native platform display handle. This is used to obtain the EGL
// display connection for the native display.
virtual intptr_t GetNativeDisplay();
@@ -148,12 +159,8 @@ class OZONE_BASE_EXPORT SurfaceFactoryOzone {
// such as MAP for zero copy or SCANOUT for display controller.
virtual bool CanCreateNativePixmap(BufferUsage usage);
- protected:
- SurfaceFactoryOzone();
- virtual ~SurfaceFactoryOzone();
-
private:
- DISALLOW_COPY_AND_ASSIGN(SurfaceFactoryOzone);
+ static SurfaceFactoryOzone* impl_; // not owned
};
} // namespace ui