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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 | 38 |
39 // A thin wrapper around GLSurfaceEGL that owns the EGLNativeWindow. | 39 // A thin wrapper around GLSurfaceEGL that owns the EGLNativeWindow. |
40 class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { | 40 class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { |
41 public: | 41 public: |
42 GLSurfaceOzoneEGL(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | 42 GLSurfaceOzoneEGL(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
43 AcceleratedWidget widget); | 43 AcceleratedWidget widget); |
44 | 44 |
45 // GLSurface: | 45 // GLSurface: |
46 bool Initialize() override; | 46 bool Initialize() override; |
47 bool Resize(const gfx::Size& size) override; | 47 bool Resize(const gfx::Size& size, float scale_factor) override; |
48 gfx::SwapResult SwapBuffers() override; | 48 gfx::SwapResult SwapBuffers() override; |
49 bool ScheduleOverlayPlane(int z_order, | 49 bool ScheduleOverlayPlane(int z_order, |
50 OverlayTransform transform, | 50 OverlayTransform transform, |
51 GLImage* image, | 51 GLImage* image, |
52 const Rect& bounds_rect, | 52 const Rect& bounds_rect, |
53 const RectF& crop_rect) override; | 53 const RectF& crop_rect) override; |
54 | 54 |
55 private: | 55 private: |
56 using NativeViewGLSurfaceEGL::Initialize; | 56 using NativeViewGLSurfaceEGL::Initialize; |
57 | 57 |
(...skipping 12 matching lines...) Expand all Loading... |
70 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | 70 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
71 AcceleratedWidget widget) | 71 AcceleratedWidget widget) |
72 : NativeViewGLSurfaceEGL(ozone_surface->GetNativeWindow()), | 72 : NativeViewGLSurfaceEGL(ozone_surface->GetNativeWindow()), |
73 ozone_surface_(ozone_surface.Pass()), | 73 ozone_surface_(ozone_surface.Pass()), |
74 widget_(widget) {} | 74 widget_(widget) {} |
75 | 75 |
76 bool GLSurfaceOzoneEGL::Initialize() { | 76 bool GLSurfaceOzoneEGL::Initialize() { |
77 return Initialize(ozone_surface_->CreateVSyncProvider()); | 77 return Initialize(ozone_surface_->CreateVSyncProvider()); |
78 } | 78 } |
79 | 79 |
80 bool GLSurfaceOzoneEGL::Resize(const gfx::Size& size) { | 80 bool GLSurfaceOzoneEGL::Resize(const gfx::Size& size, float scale_factor) { |
81 if (!ozone_surface_->ResizeNativeWindow(size)) { | 81 if (!ozone_surface_->ResizeNativeWindow(size)) { |
82 if (!ReinitializeNativeSurface() || | 82 if (!ReinitializeNativeSurface() || |
83 !ozone_surface_->ResizeNativeWindow(size)) | 83 !ozone_surface_->ResizeNativeWindow(size)) |
84 return false; | 84 return false; |
85 } | 85 } |
86 | 86 |
87 return NativeViewGLSurfaceEGL::Resize(size); | 87 return NativeViewGLSurfaceEGL::Resize(size, scale_factor); |
88 } | 88 } |
89 | 89 |
90 gfx::SwapResult GLSurfaceOzoneEGL::SwapBuffers() { | 90 gfx::SwapResult GLSurfaceOzoneEGL::SwapBuffers() { |
91 gfx::SwapResult result = NativeViewGLSurfaceEGL::SwapBuffers(); | 91 gfx::SwapResult result = NativeViewGLSurfaceEGL::SwapBuffers(); |
92 if (result != gfx::SwapResult::SWAP_ACK) | 92 if (result != gfx::SwapResult::SWAP_ACK) |
93 return result; | 93 return result; |
94 | 94 |
95 return ozone_surface_->OnSwapBuffers() ? gfx::SwapResult::SWAP_ACK | 95 return ozone_surface_->OnSwapBuffers() ? gfx::SwapResult::SWAP_ACK |
96 : gfx::SwapResult::SWAP_FAILED; | 96 : gfx::SwapResult::SWAP_FAILED; |
97 } | 97 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return true; | 135 return true; |
136 } | 136 } |
137 | 137 |
138 class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL { | 138 class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL { |
139 public: | 139 public: |
140 GLSurfaceOzoneSurfaceless(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | 140 GLSurfaceOzoneSurfaceless(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
141 AcceleratedWidget widget); | 141 AcceleratedWidget widget); |
142 | 142 |
143 // GLSurface: | 143 // GLSurface: |
144 bool Initialize() override; | 144 bool Initialize() override; |
145 bool Resize(const gfx::Size& size) override; | 145 bool Resize(const gfx::Size& size, float scale_factor) override; |
146 gfx::SwapResult SwapBuffers() override; | 146 gfx::SwapResult SwapBuffers() override; |
147 bool ScheduleOverlayPlane(int z_order, | 147 bool ScheduleOverlayPlane(int z_order, |
148 OverlayTransform transform, | 148 OverlayTransform transform, |
149 GLImage* image, | 149 GLImage* image, |
150 const Rect& bounds_rect, | 150 const Rect& bounds_rect, |
151 const RectF& crop_rect) override; | 151 const RectF& crop_rect) override; |
152 bool IsOffscreen() override; | 152 bool IsOffscreen() override; |
153 VSyncProvider* GetVSyncProvider() override; | 153 VSyncProvider* GetVSyncProvider() override; |
154 bool SupportsPostSubBuffer() override; | 154 bool SupportsPostSubBuffer() override; |
155 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; | 155 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 254 |
255 bool GLSurfaceOzoneSurfaceless::Initialize() { | 255 bool GLSurfaceOzoneSurfaceless::Initialize() { |
256 if (!SurfacelessEGL::Initialize()) | 256 if (!SurfacelessEGL::Initialize()) |
257 return false; | 257 return false; |
258 vsync_provider_ = ozone_surface_->CreateVSyncProvider(); | 258 vsync_provider_ = ozone_surface_->CreateVSyncProvider(); |
259 if (!vsync_provider_) | 259 if (!vsync_provider_) |
260 return false; | 260 return false; |
261 return true; | 261 return true; |
262 } | 262 } |
263 | 263 |
264 bool GLSurfaceOzoneSurfaceless::Resize(const gfx::Size& size) { | 264 bool GLSurfaceOzoneSurfaceless::Resize(const gfx::Size& size, |
| 265 float scale_factor) { |
265 if (!ozone_surface_->ResizeNativeWindow(size)) | 266 if (!ozone_surface_->ResizeNativeWindow(size)) |
266 return false; | 267 return false; |
267 | 268 |
268 return SurfacelessEGL::Resize(size); | 269 return SurfacelessEGL::Resize(size, scale_factor); |
269 } | 270 } |
270 | 271 |
271 gfx::SwapResult GLSurfaceOzoneSurfaceless::SwapBuffers() { | 272 gfx::SwapResult GLSurfaceOzoneSurfaceless::SwapBuffers() { |
272 glFlush(); | 273 glFlush(); |
273 // TODO: the following should be replaced by a per surface flush as it gets | 274 // TODO: the following should be replaced by a per surface flush as it gets |
274 // implemented in GL drivers. | 275 // implemented in GL drivers. |
275 if (has_implicit_external_sync_) { | 276 if (has_implicit_external_sync_) { |
276 EGLSyncKHR fence = InsertFence(); | 277 EGLSyncKHR fence = InsertFence(); |
277 if (!fence) | 278 if (!fence) |
278 return SwapResult::SWAP_FAILED; | 279 return SwapResult::SWAP_FAILED; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 class GL_EXPORT GLSurfaceOzoneSurfacelessSurfaceImpl | 420 class GL_EXPORT GLSurfaceOzoneSurfacelessSurfaceImpl |
420 : public GLSurfaceOzoneSurfaceless { | 421 : public GLSurfaceOzoneSurfaceless { |
421 public: | 422 public: |
422 GLSurfaceOzoneSurfacelessSurfaceImpl( | 423 GLSurfaceOzoneSurfacelessSurfaceImpl( |
423 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | 424 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
424 AcceleratedWidget widget); | 425 AcceleratedWidget widget); |
425 | 426 |
426 // GLSurface: | 427 // GLSurface: |
427 unsigned int GetBackingFrameBufferObject() override; | 428 unsigned int GetBackingFrameBufferObject() override; |
428 bool OnMakeCurrent(GLContext* context) override; | 429 bool OnMakeCurrent(GLContext* context) override; |
429 bool Resize(const gfx::Size& size) override; | 430 bool Resize(const gfx::Size& size, float scale_factor) override; |
430 bool SupportsPostSubBuffer() override; | 431 bool SupportsPostSubBuffer() override; |
431 gfx::SwapResult SwapBuffers() override; | 432 gfx::SwapResult SwapBuffers() override; |
432 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; | 433 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; |
433 void Destroy() override; | 434 void Destroy() override; |
434 bool IsSurfaceless() const override; | 435 bool IsSurfaceless() const override; |
435 | 436 |
436 private: | 437 private: |
437 ~GLSurfaceOzoneSurfacelessSurfaceImpl() override; | 438 ~GLSurfaceOzoneSurfacelessSurfaceImpl() override; |
438 | 439 |
439 void BindFramebuffer(); | 440 void BindFramebuffer(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 return false; | 473 return false; |
473 glGenTextures(arraysize(textures_), textures_); | 474 glGenTextures(arraysize(textures_), textures_); |
474 if (!CreatePixmaps()) | 475 if (!CreatePixmaps()) |
475 return false; | 476 return false; |
476 } | 477 } |
477 BindFramebuffer(); | 478 BindFramebuffer(); |
478 glBindFramebufferEXT(GL_FRAMEBUFFER, fbo_); | 479 glBindFramebufferEXT(GL_FRAMEBUFFER, fbo_); |
479 return SurfacelessEGL::OnMakeCurrent(context); | 480 return SurfacelessEGL::OnMakeCurrent(context); |
480 } | 481 } |
481 | 482 |
482 bool GLSurfaceOzoneSurfacelessSurfaceImpl::Resize(const gfx::Size& size) { | 483 bool GLSurfaceOzoneSurfacelessSurfaceImpl::Resize(const gfx::Size& size, |
| 484 float scale_factor) { |
483 if (size == GetSize()) | 485 if (size == GetSize()) |
484 return true; | 486 return true; |
485 return GLSurfaceOzoneSurfaceless::Resize(size) && CreatePixmaps(); | 487 return GLSurfaceOzoneSurfaceless::Resize(size, scale_factor) && |
| 488 CreatePixmaps(); |
486 } | 489 } |
487 | 490 |
488 bool GLSurfaceOzoneSurfacelessSurfaceImpl::SupportsPostSubBuffer() { | 491 bool GLSurfaceOzoneSurfacelessSurfaceImpl::SupportsPostSubBuffer() { |
489 return false; | 492 return false; |
490 } | 493 } |
491 | 494 |
492 gfx::SwapResult GLSurfaceOzoneSurfacelessSurfaceImpl::SwapBuffers() { | 495 gfx::SwapResult GLSurfaceOzoneSurfacelessSurfaceImpl::SwapBuffers() { |
493 if (!images_[current_surface_]->ScheduleOverlayPlane( | 496 if (!images_[current_surface_]->ScheduleOverlayPlane( |
494 widget_, 0, OverlayTransform::OVERLAY_TRANSFORM_NONE, | 497 widget_, 0, OverlayTransform::OVERLAY_TRANSFORM_NONE, |
495 gfx::Rect(GetSize()), gfx::RectF(1, 1))) | 498 gfx::Rect(GetSize()), gfx::RectF(1, 1))) |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 } | 712 } |
710 } | 713 } |
711 | 714 |
712 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 715 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
713 return ui::OzonePlatform::GetInstance() | 716 return ui::OzonePlatform::GetInstance() |
714 ->GetSurfaceFactoryOzone() | 717 ->GetSurfaceFactoryOzone() |
715 ->GetNativeDisplay(); | 718 ->GetNativeDisplay(); |
716 } | 719 } |
717 | 720 |
718 } // namespace gfx | 721 } // namespace gfx |
OLD | NEW |