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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 public: | 44 public: |
45 GLSurfaceOzoneEGL(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | 45 GLSurfaceOzoneEGL(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
46 AcceleratedWidget widget); | 46 AcceleratedWidget widget); |
47 | 47 |
48 // GLSurface: | 48 // GLSurface: |
49 bool Initialize() override; | 49 bool Initialize() override; |
50 bool Resize(const gfx::Size& size, float scale_factor) override; | 50 bool Resize(const gfx::Size& size, float scale_factor) override; |
51 gfx::SwapResult SwapBuffers() override; | 51 gfx::SwapResult SwapBuffers() override; |
52 bool ScheduleOverlayPlane(int z_order, | 52 bool ScheduleOverlayPlane(int z_order, |
53 OverlayTransform transform, | 53 OverlayTransform transform, |
| 54 gfx::BufferFormat storage_format, |
54 GLImage* image, | 55 GLImage* image, |
55 const Rect& bounds_rect, | 56 const Rect& bounds_rect, |
56 const RectF& crop_rect) override; | 57 const RectF& crop_rect, |
| 58 bool handle_scaling) override; |
57 | 59 |
58 private: | 60 private: |
59 using NativeViewGLSurfaceEGL::Initialize; | 61 using NativeViewGLSurfaceEGL::Initialize; |
60 | 62 |
61 ~GLSurfaceOzoneEGL() override; | 63 ~GLSurfaceOzoneEGL() override; |
62 | 64 |
63 bool ReinitializeNativeSurface(); | 65 bool ReinitializeNativeSurface(); |
64 | 66 |
65 // The native surface. Deleting this is allowed to free the EGLNativeWindow. | 67 // The native surface. Deleting this is allowed to free the EGLNativeWindow. |
66 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; | 68 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; |
(...skipping 27 matching lines...) Expand all Loading... |
94 gfx::SwapResult result = NativeViewGLSurfaceEGL::SwapBuffers(); | 96 gfx::SwapResult result = NativeViewGLSurfaceEGL::SwapBuffers(); |
95 if (result != gfx::SwapResult::SWAP_ACK) | 97 if (result != gfx::SwapResult::SWAP_ACK) |
96 return result; | 98 return result; |
97 | 99 |
98 return ozone_surface_->OnSwapBuffers() ? gfx::SwapResult::SWAP_ACK | 100 return ozone_surface_->OnSwapBuffers() ? gfx::SwapResult::SWAP_ACK |
99 : gfx::SwapResult::SWAP_FAILED; | 101 : gfx::SwapResult::SWAP_FAILED; |
100 } | 102 } |
101 | 103 |
102 bool GLSurfaceOzoneEGL::ScheduleOverlayPlane(int z_order, | 104 bool GLSurfaceOzoneEGL::ScheduleOverlayPlane(int z_order, |
103 OverlayTransform transform, | 105 OverlayTransform transform, |
| 106 gfx::BufferFormat storage_format, |
104 GLImage* image, | 107 GLImage* image, |
105 const Rect& bounds_rect, | 108 const Rect& bounds_rect, |
106 const RectF& crop_rect) { | 109 const RectF& crop_rect, |
107 return image->ScheduleOverlayPlane(widget_, z_order, transform, bounds_rect, | 110 bool handle_scaling) { |
108 crop_rect); | 111 return image->ScheduleOverlayPlane(widget_, z_order, transform, |
| 112 storage_format, bounds_rect, |
| 113 crop_rect, handle_scaling); |
109 } | 114 } |
110 | 115 |
111 GLSurfaceOzoneEGL::~GLSurfaceOzoneEGL() { | 116 GLSurfaceOzoneEGL::~GLSurfaceOzoneEGL() { |
112 Destroy(); // The EGL surface must be destroyed before SurfaceOzone. | 117 Destroy(); // The EGL surface must be destroyed before SurfaceOzone. |
113 } | 118 } |
114 | 119 |
115 bool GLSurfaceOzoneEGL::ReinitializeNativeSurface() { | 120 bool GLSurfaceOzoneEGL::ReinitializeNativeSurface() { |
116 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current; | 121 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current; |
117 GLContext* current_context = GLContext::GetCurrent(); | 122 GLContext* current_context = GLContext::GetCurrent(); |
118 bool was_current = current_context && current_context->IsCurrent(this); | 123 bool was_current = current_context && current_context->IsCurrent(this); |
(...skipping 23 matching lines...) Expand all Loading... |
142 public: | 147 public: |
143 GLSurfaceOzoneSurfaceless(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | 148 GLSurfaceOzoneSurfaceless(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
144 AcceleratedWidget widget); | 149 AcceleratedWidget widget); |
145 | 150 |
146 // GLSurface: | 151 // GLSurface: |
147 bool Initialize() override; | 152 bool Initialize() override; |
148 bool Resize(const gfx::Size& size, float scale_factor) override; | 153 bool Resize(const gfx::Size& size, float scale_factor) override; |
149 gfx::SwapResult SwapBuffers() override; | 154 gfx::SwapResult SwapBuffers() override; |
150 bool ScheduleOverlayPlane(int z_order, | 155 bool ScheduleOverlayPlane(int z_order, |
151 OverlayTransform transform, | 156 OverlayTransform transform, |
| 157 gfx::BufferFormat storage_format, |
152 GLImage* image, | 158 GLImage* image, |
153 const Rect& bounds_rect, | 159 const Rect& bounds_rect, |
154 const RectF& crop_rect) override; | 160 const RectF& crop_rect, |
| 161 bool handle_scaling) override; |
155 bool IsOffscreen() override; | 162 bool IsOffscreen() override; |
156 VSyncProvider* GetVSyncProvider() override; | 163 VSyncProvider* GetVSyncProvider() override; |
157 bool SupportsAsyncSwap() override; | 164 bool SupportsAsyncSwap() override; |
158 bool SupportsPostSubBuffer() override; | 165 bool SupportsPostSubBuffer() override; |
159 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; | 166 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
160 void SwapBuffersAsync(const SwapCompletionCallback& callback) override; | 167 void SwapBuffersAsync(const SwapCompletionCallback& callback) override; |
161 void PostSubBufferAsync(int x, | 168 void PostSubBufferAsync(int x, |
162 int y, | 169 int y, |
163 int width, | 170 int width, |
164 int height, | 171 int height, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 glFinish(); | 263 glFinish(); |
257 } | 264 } |
258 | 265 |
259 unsubmitted_frames_.back()->ScheduleOverlayPlanes(widget_); | 266 unsubmitted_frames_.back()->ScheduleOverlayPlanes(widget_); |
260 unsubmitted_frames_.back()->overlays.clear(); | 267 unsubmitted_frames_.back()->overlays.clear(); |
261 | 268 |
262 return ozone_surface_->OnSwapBuffers() ? gfx::SwapResult::SWAP_ACK | 269 return ozone_surface_->OnSwapBuffers() ? gfx::SwapResult::SWAP_ACK |
263 : gfx::SwapResult::SWAP_FAILED; | 270 : gfx::SwapResult::SWAP_FAILED; |
264 } | 271 } |
265 | 272 |
266 bool GLSurfaceOzoneSurfaceless::ScheduleOverlayPlane(int z_order, | 273 bool GLSurfaceOzoneSurfaceless::ScheduleOverlayPlane( |
267 OverlayTransform transform, | 274 int z_order, OverlayTransform transform, |
268 GLImage* image, | 275 gfx::BufferFormat storage_format, GLImage* image, |
269 const Rect& bounds_rect, | 276 const Rect& bounds_rect, const RectF& crop_rect, |
270 const RectF& crop_rect) { | 277 bool handle_scaling) { |
271 unsubmitted_frames_.back()->overlays.push_back( | 278 unsubmitted_frames_.back()->overlays.push_back( |
272 GLSurfaceOverlay(z_order, transform, image, bounds_rect, crop_rect)); | 279 GLSurfaceOverlay(z_order, transform, storage_format, image, bounds_rect, |
| 280 crop_rect, handle_scaling)); |
273 return true; | 281 return true; |
274 } | 282 } |
275 | 283 |
276 bool GLSurfaceOzoneSurfaceless::IsOffscreen() { | 284 bool GLSurfaceOzoneSurfaceless::IsOffscreen() { |
277 return false; | 285 return false; |
278 } | 286 } |
279 | 287 |
280 VSyncProvider* GLSurfaceOzoneSurfaceless::GetVSyncProvider() { | 288 VSyncProvider* GLSurfaceOzoneSurfaceless::GetVSyncProvider() { |
281 return vsync_provider_.get(); | 289 return vsync_provider_.get(); |
282 } | 290 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 CreatePixmaps(); | 485 CreatePixmaps(); |
478 } | 486 } |
479 | 487 |
480 bool GLSurfaceOzoneSurfacelessSurfaceImpl::SupportsPostSubBuffer() { | 488 bool GLSurfaceOzoneSurfacelessSurfaceImpl::SupportsPostSubBuffer() { |
481 return false; | 489 return false; |
482 } | 490 } |
483 | 491 |
484 gfx::SwapResult GLSurfaceOzoneSurfacelessSurfaceImpl::SwapBuffers() { | 492 gfx::SwapResult GLSurfaceOzoneSurfacelessSurfaceImpl::SwapBuffers() { |
485 if (!images_[current_surface_]->ScheduleOverlayPlane( | 493 if (!images_[current_surface_]->ScheduleOverlayPlane( |
486 widget_, 0, OverlayTransform::OVERLAY_TRANSFORM_NONE, | 494 widget_, 0, OverlayTransform::OVERLAY_TRANSFORM_NONE, |
487 gfx::Rect(GetSize()), gfx::RectF(1, 1))) | 495 gfx::BufferFormat::BGRX_8888, gfx::Rect(GetSize()), |
| 496 gfx::RectF(1, 1), true)) { |
488 return gfx::SwapResult::SWAP_FAILED; | 497 return gfx::SwapResult::SWAP_FAILED; |
| 498 } |
489 gfx::SwapResult result = GLSurfaceOzoneSurfaceless::SwapBuffers(); | 499 gfx::SwapResult result = GLSurfaceOzoneSurfaceless::SwapBuffers(); |
490 if (result != gfx::SwapResult::SWAP_ACK) | 500 if (result != gfx::SwapResult::SWAP_ACK) |
491 return result; | 501 return result; |
492 current_surface_ ^= 1; | 502 current_surface_ ^= 1; |
493 BindFramebuffer(); | 503 BindFramebuffer(); |
494 return gfx::SwapResult::SWAP_ACK; | 504 return gfx::SwapResult::SWAP_ACK; |
495 } | 505 } |
496 | 506 |
497 void GLSurfaceOzoneSurfacelessSurfaceImpl::SwapBuffersAsync( | 507 void GLSurfaceOzoneSurfacelessSurfaceImpl::SwapBuffersAsync( |
498 const SwapCompletionCallback& callback) { | 508 const SwapCompletionCallback& callback) { |
499 if (!images_[current_surface_]->ScheduleOverlayPlane( | 509 if (!images_[current_surface_]->ScheduleOverlayPlane( |
500 widget_, 0, OverlayTransform::OVERLAY_TRANSFORM_NONE, | 510 widget_, 0, OverlayTransform::OVERLAY_TRANSFORM_NONE, |
501 gfx::Rect(GetSize()), gfx::RectF(1, 1))) { | 511 gfx::BufferFormat::BGRX_8888, gfx::Rect(GetSize()), |
| 512 gfx::RectF(1, 1), true)) { |
502 callback.Run(gfx::SwapResult::SWAP_FAILED); | 513 callback.Run(gfx::SwapResult::SWAP_FAILED); |
503 return; | 514 return; |
504 } | 515 } |
505 GLSurfaceOzoneSurfaceless::SwapBuffersAsync(callback); | 516 GLSurfaceOzoneSurfaceless::SwapBuffersAsync(callback); |
506 current_surface_ ^= 1; | 517 current_surface_ ^= 1; |
507 BindFramebuffer(); | 518 BindFramebuffer(); |
508 } | 519 } |
509 | 520 |
510 void GLSurfaceOzoneSurfacelessSurfaceImpl::Destroy() { | 521 void GLSurfaceOzoneSurfacelessSurfaceImpl::Destroy() { |
511 if (!context_) | 522 if (!context_) |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 } | 712 } |
702 } | 713 } |
703 | 714 |
704 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 715 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
705 return ui::OzonePlatform::GetInstance() | 716 return ui::OzonePlatform::GetInstance() |
706 ->GetSurfaceFactoryOzone() | 717 ->GetSurfaceFactoryOzone() |
707 ->GetNativeDisplay(); | 718 ->GetNativeDisplay(); |
708 } | 719 } |
709 | 720 |
710 } // namespace gfx | 721 } // namespace gfx |
OLD | NEW |