OLD | NEW |
---|---|
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/gl/gl_context.h" | 10 #include "ui/gl/gl_context.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 scoped_ptr<VSyncProvider> vsync_provider = | 82 scoped_ptr<VSyncProvider> vsync_provider = |
83 ozone_surface_->CreateVSyncProvider(); | 83 ozone_surface_->CreateVSyncProvider(); |
84 if (!Initialize(vsync_provider.Pass())) { | 84 if (!Initialize(vsync_provider.Pass())) { |
85 LOG(ERROR) << "Failed to initialize."; | 85 LOG(ERROR) << "Failed to initialize."; |
86 return false; | 86 return false; |
87 } | 87 } |
88 | 88 |
89 return true; | 89 return true; |
90 } | 90 } |
91 | 91 |
92 | |
93 // The native surface. Deleting this is allowed to free the EGLNativeWindow. | 92 // The native surface. Deleting this is allowed to free the EGLNativeWindow. |
94 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; | 93 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; |
95 AcceleratedWidget widget_; | 94 AcceleratedWidget widget_; |
96 | 95 |
97 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneEGL); | 96 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneEGL); |
98 }; | 97 }; |
99 | 98 |
99 class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL { | |
100 public: | |
101 GLSurfaceOzoneSurfaceless(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | |
102 AcceleratedWidget widget, | |
103 const gfx::Size& size) | |
dnicoara
2014/08/26 00:59:15
Drop the size arg and pass in the default value in
| |
104 : SurfacelessEGL(size), | |
105 ozone_surface_(ozone_surface.Pass()), | |
106 widget_(widget) {} | |
107 | |
108 virtual bool Resize(const gfx::Size& size) OVERRIDE { | |
109 if (!ozone_surface_->ResizeNativeWindow(size)) | |
110 return false; | |
111 | |
112 return SurfacelessEGL::Resize(size); | |
113 } | |
114 virtual bool SwapBuffers() OVERRIDE { | |
115 return ozone_surface_->OnSwapBuffers(); | |
116 } | |
117 virtual bool ScheduleOverlayPlane(int z_order, | |
118 OverlayTransform transform, | |
119 GLImage* image, | |
120 const Rect& bounds_rect, | |
121 const RectF& crop_rect) OVERRIDE { | |
122 return image->ScheduleOverlayPlane( | |
123 widget_, z_order, transform, bounds_rect, crop_rect); | |
124 } | |
125 virtual bool IsOffscreen() OVERRIDE { return false; } | |
126 | |
127 private: | |
128 // The native surface. Deleting this is allowed to free the EGLNativeWindow. | |
129 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; | |
130 AcceleratedWidget widget_; | |
131 | |
132 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneSurfaceless); | |
133 }; | |
134 | |
100 } // namespace | 135 } // namespace |
101 | 136 |
102 // static | 137 // static |
103 bool GLSurface::InitializeOneOffInternal() { | 138 bool GLSurface::InitializeOneOffInternal() { |
104 switch (GetGLImplementation()) { | 139 switch (GetGLImplementation()) { |
105 case kGLImplementationEGLGLES2: | 140 case kGLImplementationEGLGLES2: |
106 if (!GLSurfaceEGL::InitializeOneOff()) { | 141 if (!GLSurfaceEGL::InitializeOneOff()) { |
107 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; | 142 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; |
108 return false; | 143 return false; |
109 } | 144 } |
(...skipping 11 matching lines...) Expand all Loading... | |
121 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( | 156 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( |
122 gfx::AcceleratedWidget window) { | 157 gfx::AcceleratedWidget window) { |
123 if (GetGLImplementation() == kGLImplementationOSMesaGL) { | 158 if (GetGLImplementation() == kGLImplementationOSMesaGL) { |
124 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless()); | 159 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless()); |
125 if (!surface->Initialize()) | 160 if (!surface->Initialize()) |
126 return NULL; | 161 return NULL; |
127 return surface; | 162 return surface; |
128 } | 163 } |
129 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); | 164 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); |
130 if (window != kNullAcceleratedWidget) { | 165 if (window != kNullAcceleratedWidget) { |
166 if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() && | |
167 ui::SurfaceFactoryOzone::GetInstance() | |
168 ->CanShowPrimaryPlaneAsOverlay()) { | |
169 scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone = | |
170 ui::SurfaceFactoryOzone::GetInstance() | |
171 ->CreateSurfacelessEGLSurfaceForWidget(window); | |
172 if (!surface_ozone) | |
173 return NULL; | |
174 scoped_refptr<GLSurfaceOzoneSurfaceless> surface = | |
175 new GLSurfaceOzoneSurfaceless( | |
176 surface_ozone.Pass(), window, gfx::Size()); | |
177 if (!surface->Initialize()) | |
dnicoara
2014/08/26 00:59:15
You forgot the VSyncProvider
| |
178 return NULL; | |
179 return surface; | |
180 } | |
131 scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone = | 181 scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone = |
132 ui::SurfaceFactoryOzone::GetInstance()->CreateEGLSurfaceForWidget( | 182 ui::SurfaceFactoryOzone::GetInstance()->CreateEGLSurfaceForWidget( |
133 window); | 183 window); |
134 if (!surface_ozone) | 184 if (!surface_ozone) |
135 return NULL; | 185 return NULL; |
136 | 186 |
137 scoped_ptr<VSyncProvider> vsync_provider = | 187 scoped_ptr<VSyncProvider> vsync_provider = |
138 surface_ozone->CreateVSyncProvider(); | 188 surface_ozone->CreateVSyncProvider(); |
139 scoped_refptr<GLSurfaceOzoneEGL> surface = | 189 scoped_refptr<GLSurfaceOzoneEGL> surface = |
140 new GLSurfaceOzoneEGL(surface_ozone.Pass(), window); | 190 new GLSurfaceOzoneEGL(surface_ozone.Pass(), window); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 NOTREACHED(); | 227 NOTREACHED(); |
178 return NULL; | 228 return NULL; |
179 } | 229 } |
180 } | 230 } |
181 | 231 |
182 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 232 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
183 return ui::SurfaceFactoryOzone::GetInstance()->GetNativeDisplay(); | 233 return ui::SurfaceFactoryOzone::GetInstance()->GetNativeDisplay(); |
184 } | 234 } |
185 | 235 |
186 } // namespace gfx | 236 } // namespace gfx |
OLD | NEW |