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 12 matching lines...) Expand all Loading... |
23 | 23 |
24 // A thin wrapper around GLSurfaceEGL that owns the EGLNativeWindow | 24 // A thin wrapper around GLSurfaceEGL that owns the EGLNativeWindow |
25 class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { | 25 class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { |
26 public: | 26 public: |
27 GLSurfaceOzoneEGL(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | 27 GLSurfaceOzoneEGL(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
28 AcceleratedWidget widget) | 28 AcceleratedWidget widget) |
29 : NativeViewGLSurfaceEGL(ozone_surface->GetNativeWindow()), | 29 : NativeViewGLSurfaceEGL(ozone_surface->GetNativeWindow()), |
30 ozone_surface_(ozone_surface.Pass()), | 30 ozone_surface_(ozone_surface.Pass()), |
31 widget_(widget) {} | 31 widget_(widget) {} |
32 | 32 |
33 virtual bool Initialize() OVERRIDE { | 33 virtual bool Initialize() override { |
34 return Initialize(ozone_surface_->CreateVSyncProvider()); | 34 return Initialize(ozone_surface_->CreateVSyncProvider()); |
35 } | 35 } |
36 virtual bool Resize(const gfx::Size& size) OVERRIDE { | 36 virtual bool Resize(const gfx::Size& size) override { |
37 if (!ozone_surface_->ResizeNativeWindow(size)) { | 37 if (!ozone_surface_->ResizeNativeWindow(size)) { |
38 if (!ReinitializeNativeSurface() || | 38 if (!ReinitializeNativeSurface() || |
39 !ozone_surface_->ResizeNativeWindow(size)) | 39 !ozone_surface_->ResizeNativeWindow(size)) |
40 return false; | 40 return false; |
41 } | 41 } |
42 | 42 |
43 return NativeViewGLSurfaceEGL::Resize(size); | 43 return NativeViewGLSurfaceEGL::Resize(size); |
44 } | 44 } |
45 virtual bool SwapBuffers() OVERRIDE { | 45 virtual bool SwapBuffers() override { |
46 if (!NativeViewGLSurfaceEGL::SwapBuffers()) | 46 if (!NativeViewGLSurfaceEGL::SwapBuffers()) |
47 return false; | 47 return false; |
48 | 48 |
49 return ozone_surface_->OnSwapBuffers(); | 49 return ozone_surface_->OnSwapBuffers(); |
50 } | 50 } |
51 virtual bool ScheduleOverlayPlane(int z_order, | 51 virtual bool ScheduleOverlayPlane(int z_order, |
52 OverlayTransform transform, | 52 OverlayTransform transform, |
53 GLImage* image, | 53 GLImage* image, |
54 const Rect& bounds_rect, | 54 const Rect& bounds_rect, |
55 const RectF& crop_rect) OVERRIDE { | 55 const RectF& crop_rect) override { |
56 return image->ScheduleOverlayPlane( | 56 return image->ScheduleOverlayPlane( |
57 widget_, z_order, transform, bounds_rect, crop_rect); | 57 widget_, z_order, transform, bounds_rect, crop_rect); |
58 } | 58 } |
59 | 59 |
60 private: | 60 private: |
61 using NativeViewGLSurfaceEGL::Initialize; | 61 using NativeViewGLSurfaceEGL::Initialize; |
62 | 62 |
63 virtual ~GLSurfaceOzoneEGL() { | 63 virtual ~GLSurfaceOzoneEGL() { |
64 Destroy(); // EGL surface must be destroyed before SurfaceOzone | 64 Destroy(); // EGL surface must be destroyed before SurfaceOzone |
65 } | 65 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 }; | 100 }; |
101 | 101 |
102 class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL { | 102 class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL { |
103 public: | 103 public: |
104 GLSurfaceOzoneSurfaceless(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | 104 GLSurfaceOzoneSurfaceless(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
105 AcceleratedWidget widget) | 105 AcceleratedWidget widget) |
106 : SurfacelessEGL(gfx::Size()), | 106 : SurfacelessEGL(gfx::Size()), |
107 ozone_surface_(ozone_surface.Pass()), | 107 ozone_surface_(ozone_surface.Pass()), |
108 widget_(widget) {} | 108 widget_(widget) {} |
109 | 109 |
110 virtual bool Initialize() OVERRIDE { | 110 virtual bool Initialize() override { |
111 if (!SurfacelessEGL::Initialize()) | 111 if (!SurfacelessEGL::Initialize()) |
112 return false; | 112 return false; |
113 vsync_provider_ = ozone_surface_->CreateVSyncProvider(); | 113 vsync_provider_ = ozone_surface_->CreateVSyncProvider(); |
114 if (!vsync_provider_) | 114 if (!vsync_provider_) |
115 return false; | 115 return false; |
116 return true; | 116 return true; |
117 } | 117 } |
118 virtual bool Resize(const gfx::Size& size) OVERRIDE { | 118 virtual bool Resize(const gfx::Size& size) override { |
119 if (!ozone_surface_->ResizeNativeWindow(size)) | 119 if (!ozone_surface_->ResizeNativeWindow(size)) |
120 return false; | 120 return false; |
121 | 121 |
122 return SurfacelessEGL::Resize(size); | 122 return SurfacelessEGL::Resize(size); |
123 } | 123 } |
124 virtual bool SwapBuffers() OVERRIDE { | 124 virtual bool SwapBuffers() override { |
125 // TODO: this should be replaced by a fence when supported by the driver. | 125 // TODO: this should be replaced by a fence when supported by the driver. |
126 glFinish(); | 126 glFinish(); |
127 return ozone_surface_->OnSwapBuffers(); | 127 return ozone_surface_->OnSwapBuffers(); |
128 } | 128 } |
129 virtual bool ScheduleOverlayPlane(int z_order, | 129 virtual bool ScheduleOverlayPlane(int z_order, |
130 OverlayTransform transform, | 130 OverlayTransform transform, |
131 GLImage* image, | 131 GLImage* image, |
132 const Rect& bounds_rect, | 132 const Rect& bounds_rect, |
133 const RectF& crop_rect) OVERRIDE { | 133 const RectF& crop_rect) override { |
134 return image->ScheduleOverlayPlane( | 134 return image->ScheduleOverlayPlane( |
135 widget_, z_order, transform, bounds_rect, crop_rect); | 135 widget_, z_order, transform, bounds_rect, crop_rect); |
136 } | 136 } |
137 virtual bool IsOffscreen() OVERRIDE { return false; } | 137 virtual bool IsOffscreen() override { return false; } |
138 virtual VSyncProvider* GetVSyncProvider() OVERRIDE { | 138 virtual VSyncProvider* GetVSyncProvider() override { |
139 return vsync_provider_.get(); | 139 return vsync_provider_.get(); |
140 } | 140 } |
141 virtual bool SupportsPostSubBuffer() OVERRIDE { return true; } | 141 virtual bool SupportsPostSubBuffer() override { return true; } |
142 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE { | 142 virtual bool PostSubBuffer(int x, int y, int width, int height) override { |
143 // The actual sub buffer handling is handled at higher layers. | 143 // The actual sub buffer handling is handled at higher layers. |
144 SwapBuffers(); | 144 SwapBuffers(); |
145 return true; | 145 return true; |
146 } | 146 } |
147 virtual bool IsSurfaceless() const OVERRIDE { return true; } | 147 virtual bool IsSurfaceless() const override { return true; } |
148 | 148 |
149 private: | 149 private: |
150 virtual ~GLSurfaceOzoneSurfaceless() { | 150 virtual ~GLSurfaceOzoneSurfaceless() { |
151 Destroy(); // EGL surface must be destroyed before SurfaceOzone | 151 Destroy(); // EGL surface must be destroyed before SurfaceOzone |
152 } | 152 } |
153 | 153 |
154 // The native surface. Deleting this is allowed to free the EGLNativeWindow. | 154 // The native surface. Deleting this is allowed to free the EGLNativeWindow. |
155 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; | 155 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; |
156 AcceleratedWidget widget_; | 156 AcceleratedWidget widget_; |
157 scoped_ptr<VSyncProvider> vsync_provider_; | 157 scoped_ptr<VSyncProvider> vsync_provider_; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 NOTREACHED(); | 248 NOTREACHED(); |
249 return NULL; | 249 return NULL; |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 253 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
254 return ui::SurfaceFactoryOzone::GetInstance()->GetNativeDisplay(); | 254 return ui::SurfaceFactoryOzone::GetInstance()->GetNativeDisplay(); |
255 } | 255 } |
256 | 256 |
257 } // namespace gfx | 257 } // namespace gfx |
OLD | NEW |