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

Side by Side 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: rebase Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/ozone/surface_ozone_base.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_surface.h" 5 #include "ui/gl/gl_surface.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "ui/gfx/native_widget_types.h" 9 #include "ui/gfx/native_widget_types.h"
10 #include "ui/gfx/ozone/surface_factory_ozone.h" 10 #include "ui/gfx/ozone/surface_factory_ozone.h"
11 #include "ui/gfx/ozone/surface_ozone.h"
11 #include "ui/gl/gl_implementation.h" 12 #include "ui/gl/gl_implementation.h"
12 #include "ui/gl/gl_surface_egl.h" 13 #include "ui/gl/gl_surface_egl.h"
13 #include "ui/gl/gl_surface_osmesa.h" 14 #include "ui/gl/gl_surface_osmesa.h"
14 #include "ui/gl/gl_surface_stub.h" 15 #include "ui/gl/gl_surface_stub.h"
15 16
16 namespace gfx { 17 namespace gfx {
17 18
19 namespace {
20
21 // A thin wrapper around GLSurfaceEGL that owns the EGLNativeWindow
22 class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL {
23 public:
24 GLSurfaceOzoneEGL(scoped_ptr<SurfaceOzone> ozone_surface)
25 : NativeViewGLSurfaceEGL(ozone_surface->GetEGLNativeWindow()),
26 ozone_surface_(ozone_surface.Pass()) {}
27
28 virtual ~GLSurfaceOzoneEGL() {
29 Destroy(); // EGL surface must be destroyed before SurfaceOzone
30 }
31
32 private:
33 // The native surface. Deleting this is allowed to free the EGLNativeWindow.
34 scoped_ptr<SurfaceOzone> ozone_surface_;
35
36 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneEGL);
37 };
38
39 } // namespace
40
18 // static 41 // static
19 bool GLSurface::InitializeOneOffInternal() { 42 bool GLSurface::InitializeOneOffInternal() {
20 switch (GetGLImplementation()) { 43 switch (GetGLImplementation()) {
21 case kGLImplementationEGLGLES2: 44 case kGLImplementationEGLGLES2:
22 if (gfx::SurfaceFactoryOzone::GetInstance()->InitializeHardware() != 45 if (gfx::SurfaceFactoryOzone::GetInstance()->InitializeHardware() !=
23 gfx::SurfaceFactoryOzone::INITIALIZED) { 46 gfx::SurfaceFactoryOzone::INITIALIZED) {
24 LOG(ERROR) << "Ozone failed to initialize hardware"; 47 LOG(ERROR) << "Ozone failed to initialize hardware";
25 return false; 48 return false;
26 } 49 }
27 50
(...skipping 11 matching lines...) Expand all
39 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( 62 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
40 gfx::AcceleratedWidget window) { 63 gfx::AcceleratedWidget window) {
41 if (GetGLImplementation() == kGLImplementationOSMesaGL) { 64 if (GetGLImplementation() == kGLImplementationOSMesaGL) {
42 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless()); 65 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless());
43 if (!surface->Initialize()) 66 if (!surface->Initialize())
44 return NULL; 67 return NULL;
45 return surface; 68 return surface;
46 } 69 }
47 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); 70 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2);
48 if (window != kNullAcceleratedWidget) { 71 if (window != kNullAcceleratedWidget) {
49 EGLNativeWindowType egl_window = 72 scoped_ptr<SurfaceOzone> surface_ozone =
50 gfx::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget( 73 SurfaceFactoryOzone::GetInstance()->CreateSurfaceForWidget(window);
51 window); 74 if (!surface_ozone->InitializeEGL())
52 scoped_ptr<VSyncProvider> sync_provider = 75 return NULL;
53 gfx::SurfaceFactoryOzone::GetInstance()->CreateVSyncProvider( 76 scoped_refptr<GLSurfaceOzoneEGL> surface =
54 egl_window); 77 new GLSurfaceOzoneEGL(surface_ozone.Pass());
55 scoped_refptr<NativeViewGLSurfaceEGL> surface = 78 if (!surface->Initialize(surface_ozone->CreateVSyncProvider()))
56 new NativeViewGLSurfaceEGL(egl_window); 79 return NULL;
57 if (surface->Initialize(sync_provider.Pass())) 80 return surface;
58 return surface;
59 } else { 81 } else {
60 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); 82 scoped_refptr<GLSurface> surface = new GLSurfaceStub();
61 if (surface->Initialize()) 83 if (surface->Initialize())
62 return surface; 84 return surface;
63 } 85 }
64 return NULL; 86 return NULL;
65 } 87 }
66 88
67 // static 89 // static
68 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( 90 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
(...skipping 22 matching lines...) Expand all
91 NOTREACHED(); 113 NOTREACHED();
92 return NULL; 114 return NULL;
93 } 115 }
94 } 116 }
95 117
96 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { 118 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() {
97 return SurfaceFactoryOzone::GetInstance()->GetNativeDisplay(); 119 return SurfaceFactoryOzone::GetInstance()->GetNativeDisplay();
98 } 120 }
99 121
100 } // namespace gfx 122 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/ozone/surface_ozone_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698