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

Side by Side Diff: ui/gl/gl_surface_ozone.cc

Issue 1738973004: Fix EGL configs with GLSurfaceOzoneSurfaceless. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added format SURFACE_SURFACELESS. Created 4 years, 9 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
« no previous file with comments | « ui/gl/gl_surface_egl.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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 // Helper function for base::Bind to create callback to eglGetConfigAttrib. 50 // Helper function for base::Bind to create callback to eglGetConfigAttrib.
51 bool EglGetConfigAttribute(EGLDisplay display, 51 bool EglGetConfigAttribute(EGLDisplay display,
52 EGLConfig config, 52 EGLConfig config,
53 int32_t attribute, 53 int32_t attribute,
54 int32_t* value) { 54 int32_t* value) {
55 return eglGetConfigAttrib(display, config, attribute, value); 55 return eglGetConfigAttrib(display, config, attribute, value);
56 } 56 }
57 57
58 // Populates EglConfigCallbacks with appropriate callbacks.
59 ui::EglConfigCallbacks GetEglConfigCallbacks(EGLDisplay display) {
60 ui::EglConfigCallbacks callbacks;
61 callbacks.choose_config = base::Bind(EglChooseConfig, display);
62 callbacks.get_config_attribute = base::Bind(EglGetConfigAttribute, display);
63 callbacks.get_last_error_string = base::Bind(&ui::GetLastEGLErrorString);
64 return callbacks;
65 }
66
58 void WaitForFence(EGLDisplay display, EGLSyncKHR fence) { 67 void WaitForFence(EGLDisplay display, EGLSyncKHR fence) {
59 eglClientWaitSyncKHR(display, fence, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 68 eglClientWaitSyncKHR(display, fence, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,
60 EGL_FOREVER_KHR); 69 EGL_FOREVER_KHR);
61 } 70 }
62 71
63 // A thin wrapper around GLSurfaceEGL that owns the EGLNativeWindow. 72 // A thin wrapper around GLSurfaceEGL that owns the EGLNativeWindow.
64 class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { 73 class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL {
65 public: 74 public:
66 GLSurfaceOzoneEGL(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, 75 GLSurfaceOzoneEGL(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface,
67 AcceleratedWidget widget); 76 AcceleratedWidget widget);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 OverlayTransform transform, 139 OverlayTransform transform,
131 GLImage* image, 140 GLImage* image,
132 const Rect& bounds_rect, 141 const Rect& bounds_rect,
133 const RectF& crop_rect) { 142 const RectF& crop_rect) {
134 return image->ScheduleOverlayPlane(widget_, z_order, transform, bounds_rect, 143 return image->ScheduleOverlayPlane(widget_, z_order, transform, bounds_rect,
135 crop_rect); 144 crop_rect);
136 } 145 }
137 146
138 EGLConfig GLSurfaceOzoneEGL::GetConfig() { 147 EGLConfig GLSurfaceOzoneEGL::GetConfig() {
139 if (!config_) { 148 if (!config_) {
140 // Setup callbacks for configuring EGL on platform. 149 ui::EglConfigCallbacks callbacks = GetEglConfigCallbacks(GetDisplay());
141 EGLDisplay display = GetDisplay(); 150 config_ = ozone_surface_->GetEGLSurfaceConfig(callbacks);
142 ui::EglConfigCallbacks egl;
143 egl.choose_config = base::Bind(EglChooseConfig, display);
144 egl.get_config_attribute = base::Bind(EglGetConfigAttribute, display);
145 egl.get_last_error_string = base::Bind(&ui::GetLastEGLErrorString);
146
147 config_ = ozone_surface_->GetEGLSurfaceConfig(egl);
148 } 151 }
149 if (config_) 152 if (config_)
150 return config_; 153 return config_;
151 return NativeViewGLSurfaceEGL::GetConfig(); 154 return NativeViewGLSurfaceEGL::GetConfig();
152 } 155 }
153 156
154 GLSurfaceOzoneEGL::~GLSurfaceOzoneEGL() { 157 GLSurfaceOzoneEGL::~GLSurfaceOzoneEGL() {
155 Destroy(); // The EGL surface must be destroyed before SurfaceOzone. 158 Destroy(); // The EGL surface must be destroyed before SurfaceOzone.
156 } 159 }
157 160
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 VSyncProvider* GetVSyncProvider() override; 204 VSyncProvider* GetVSyncProvider() override;
202 bool SupportsAsyncSwap() override; 205 bool SupportsAsyncSwap() override;
203 bool SupportsPostSubBuffer() override; 206 bool SupportsPostSubBuffer() override;
204 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; 207 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override;
205 void SwapBuffersAsync(const SwapCompletionCallback& callback) override; 208 void SwapBuffersAsync(const SwapCompletionCallback& callback) override;
206 void PostSubBufferAsync(int x, 209 void PostSubBufferAsync(int x,
207 int y, 210 int y,
208 int width, 211 int width,
209 int height, 212 int height,
210 const SwapCompletionCallback& callback) override; 213 const SwapCompletionCallback& callback) override;
214 EGLConfig GetConfig() override;
211 215
212 protected: 216 protected:
213 struct PendingFrame { 217 struct PendingFrame {
214 PendingFrame(); 218 PendingFrame();
215 219
216 bool ScheduleOverlayPlanes(gfx::AcceleratedWidget widget); 220 bool ScheduleOverlayPlanes(gfx::AcceleratedWidget widget);
217 221
218 bool ready; 222 bool ready;
219 std::vector<GLSurfaceOverlay> overlays; 223 std::vector<GLSurfaceOverlay> overlays;
220 SwapCompletionCallback callback; 224 SwapCompletionCallback callback;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 void GLSurfaceOzoneSurfaceless::PostSubBufferAsync( 396 void GLSurfaceOzoneSurfaceless::PostSubBufferAsync(
393 int x, 397 int x,
394 int y, 398 int y,
395 int width, 399 int width,
396 int height, 400 int height,
397 const SwapCompletionCallback& callback) { 401 const SwapCompletionCallback& callback) {
398 // The actual sub buffer handling is handled at higher layers. 402 // The actual sub buffer handling is handled at higher layers.
399 SwapBuffersAsync(callback); 403 SwapBuffersAsync(callback);
400 } 404 }
401 405
406 EGLConfig GLSurfaceOzoneSurfaceless::GetConfig() {
407 if (!config_) {
408 ui::EglConfigCallbacks callbacks = GetEglConfigCallbacks(GetDisplay());
409 config_ = ozone_surface_->GetEGLSurfaceConfig(callbacks);
410 }
411 if (config_)
412 return config_;
413 return SurfacelessEGL::GetConfig();
414 }
415
402 GLSurfaceOzoneSurfaceless::~GLSurfaceOzoneSurfaceless() { 416 GLSurfaceOzoneSurfaceless::~GLSurfaceOzoneSurfaceless() {
403 Destroy(); // The EGL surface must be destroyed before SurfaceOzone. 417 Destroy(); // The EGL surface must be destroyed before SurfaceOzone.
404 } 418 }
405 419
406 void GLSurfaceOzoneSurfaceless::SubmitFrame() { 420 void GLSurfaceOzoneSurfaceless::SubmitFrame() {
407 DCHECK(!unsubmitted_frames_.empty()); 421 DCHECK(!unsubmitted_frames_.empty());
408 422
409 if (unsubmitted_frames_.front()->ready && !swap_buffers_pending_) { 423 if (unsubmitted_frames_.front()->ready && !swap_buffers_pending_) {
410 scoped_ptr<PendingFrame> frame(unsubmitted_frames_.front()); 424 scoped_ptr<PendingFrame> frame(unsubmitted_frames_.front());
411 unsubmitted_frames_.weak_erase(unsubmitted_frames_.begin()); 425 unsubmitted_frames_.weak_erase(unsubmitted_frames_.begin());
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 } 769 }
756 } 770 }
757 771
758 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { 772 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() {
759 return ui::OzonePlatform::GetInstance() 773 return ui::OzonePlatform::GetInstance()
760 ->GetSurfaceFactoryOzone() 774 ->GetSurfaceFactoryOzone()
761 ->GetNativeDisplay(); 775 ->GetNativeDisplay();
762 } 776 }
763 777
764 } // namespace gfx 778 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_egl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698