Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: ui/ozone/public/surface_factory_ozone.cc

Issue 1050923003: zero-copy: Clarify to allocate/destroy GpuMemoryBuffer on any thread and use it on the main thread o (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: just add thread check Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/ozone/public/surface_factory_ozone.cc
diff --git a/ui/ozone/public/surface_factory_ozone.cc b/ui/ozone/public/surface_factory_ozone.cc
index 1c57038d32452d9eecc4bea34178b9b65e8265af..615395fc756599549e95e911e56cb05b4ab9bafb 100644
--- a/ui/ozone/public/surface_factory_ozone.cc
+++ b/ui/ozone/public/surface_factory_ozone.cc
@@ -7,28 +7,33 @@
#include <stdlib.h>
#include "base/command_line.h"
+#include "base/lazy_instance.h"
#include "ui/ozone/public/native_pixmap.h"
#include "ui/ozone/public/surface_ozone_canvas.h"
#include "ui/ozone/public/surface_ozone_egl.h"
namespace ui {
-// static
-SurfaceFactoryOzone* SurfaceFactoryOzone::impl_ = NULL;
+namespace {
+
+base::LazyInstance<SurfaceFactoryOzone*>::Leaky g_impl =
+ LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
SurfaceFactoryOzone::SurfaceFactoryOzone() {
- DCHECK(!impl_) << "There should only be a single SurfaceFactoryOzone.";
- impl_ = this;
+ DCHECK(!g_impl.Get()) << "There should only be a single SurfaceFactoryOzone.";
+ *g_impl.Pointer() = this;
}
SurfaceFactoryOzone::~SurfaceFactoryOzone() {
- DCHECK_EQ(impl_, this);
- impl_ = NULL;
+ DCHECK_EQ(g_impl.Get(), this);
+ *g_impl.Pointer() = nullptr;
}
SurfaceFactoryOzone* SurfaceFactoryOzone::GetInstance() {
- DCHECK(impl_) << "No SurfaceFactoryOzone implementation set.";
- return impl_;
+ DCHECK(g_impl.Get()) << "No SurfaceFactoryOzone implementation set.";
+ return g_impl.Get();
}
intptr_t SurfaceFactoryOzone::GetNativeDisplay() {
@@ -65,7 +70,7 @@ const int32* SurfaceFactoryOzone::GetEGLSurfaceProperties(
ui::OverlayCandidatesOzone* SurfaceFactoryOzone::GetOverlayCandidates(
gfx::AcceleratedWidget w) {
- return NULL;
+ return nullptr;
}
scoped_refptr<ui::NativePixmap> SurfaceFactoryOzone::CreateNativePixmap(
@@ -73,7 +78,7 @@ scoped_refptr<ui::NativePixmap> SurfaceFactoryOzone::CreateNativePixmap(
gfx::Size size,
BufferFormat format,
BufferUsage usage) {
- return NULL;
+ return nullptr;
}
bool SurfaceFactoryOzone::ScheduleOverlayPlane(
« ui/ozone/platform/drm/drm_surface_factory.cc ('K') | « ui/ozone/public/surface_factory_ozone.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698