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

Unified Diff: ui/gl/gl_surface_ozone.cc

Issue 205433002: ozone: Add OzoneSurface object that is owned by compositor, GLSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/SwapCanvas/PresentCanvas Created 6 years, 9 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
« ui/gfx/ozone/surface_ozone.cc ('K') | « ui/gfx/ozone/surface_ozone.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_surface_ozone.cc
diff --git a/ui/gl/gl_surface_ozone.cc b/ui/gl/gl_surface_ozone.cc
index 3e11e926387ba8350515b31e08b6ac2100913a36..c6af58f58b7fe9f74b614558a567dc36946b303f 100644
--- a/ui/gl/gl_surface_ozone.cc
+++ b/ui/gl/gl_surface_ozone.cc
@@ -8,6 +8,7 @@
#include "base/memory/ref_counted.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/ozone/surface_factory_ozone.h"
+#include "ui/gfx/ozone/surface_ozone.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/gl_surface_osmesa.h"
@@ -15,6 +16,28 @@
namespace gfx {
+namespace {
+
+// A thin wrapper around GLSurfaceEGL that owns the EGLNativeWindow
+class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL {
+ public:
+ GLSurfaceOzoneEGL(scoped_ptr<SurfaceOzone> ozone_surface)
+ : NativeViewGLSurfaceEGL(ozone_surface->GetEGLNativeWindow()),
+ ozone_surface_(ozone_surface.Pass()) {}
+
+ virtual ~GLSurfaceOzoneEGL() {
+ Destroy(); // EGL surface must be destroyed before SurfaceOzone
+ }
+
+ private:
+ // The native surface. Deleting this is allowed to free the EGLNativeWindow.
+ scoped_ptr<SurfaceOzone> ozone_surface_;
+
+ DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneEGL);
+};
+
+} // namespace
+
// static
bool GLSurface::InitializeOneOffInternal() {
switch (GetGLImplementation()) {
@@ -40,16 +63,15 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
}
DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2);
if (window != kNullAcceleratedWidget) {
- EGLNativeWindowType egl_window =
- gfx::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget(
- window);
- scoped_ptr<VSyncProvider> sync_provider =
- gfx::SurfaceFactoryOzone::GetInstance()->CreateVSyncProvider(
- egl_window);
- scoped_refptr<NativeViewGLSurfaceEGL> surface =
- new NativeViewGLSurfaceEGL(egl_window);
- if (surface->Initialize(sync_provider.Pass()))
- return surface;
+ scoped_ptr<SurfaceOzone> surface_ozone =
+ SurfaceFactoryOzone::GetInstance()->CreateSurfaceForWidget(window);
+ if (!surface_ozone->InitializeEGL())
+ return NULL;
+ scoped_refptr<GLSurfaceOzoneEGL> surface =
+ new GLSurfaceOzoneEGL(surface_ozone.Pass());
+ if (!surface->Initialize(surface_ozone->CreateVSyncProvider()))
+ return NULL;
+ return surface;
} else {
scoped_refptr<GLSurface> surface = new GLSurfaceStub();
if (surface->Initialize())
« ui/gfx/ozone/surface_ozone.cc ('K') | « ui/gfx/ozone/surface_ozone.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698