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

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

Issue 17932004: Support ozone=1 compositor_unittests with OSMesa (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added missed files Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_egl.h" 5 #include "ui/gl/gl_surface_egl.h"
6 6
7 #if defined(OS_ANDROID) 7 #if defined(OS_ANDROID)
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 #endif 9 #endif
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "ui/gl/egl_util.h" 15 #include "ui/gl/egl_util.h"
16 #include "ui/gl/gl_context.h" 16 #include "ui/gl/gl_context.h"
17 #include "ui/gl/gl_implementation.h" 17 #include "ui/gl/gl_implementation.h"
18 #include "ui/gl/gl_surface_osmesa.h"
18 #include "ui/gl/gl_surface_stub.h" 19 #include "ui/gl/gl_surface_stub.h"
19 #include "ui/gl/scoped_make_current.h" 20 #include "ui/gl/scoped_make_current.h"
20 21
21 #if defined(USE_X11) 22 #if defined(USE_X11)
22 extern "C" { 23 extern "C" {
23 #include <X11/Xlib.h> 24 #include <X11/Xlib.h>
24 } 25 }
25 #endif 26 #endif
26 27
27 #if defined (USE_OZONE) 28 #if defined (USE_OZONE)
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 558 }
558 559
559 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { 560 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() {
560 Destroy(); 561 Destroy();
561 } 562 }
562 563
563 #if defined(ANDROID) || defined(USE_OZONE) 564 #if defined(ANDROID) || defined(USE_OZONE)
564 565
565 // static 566 // static
566 bool GLSurface::InitializeOneOffInternal() { 567 bool GLSurface::InitializeOneOffInternal() {
568 if (GetGLImplementation() == kGLImplementationOSMesaGL) {
569 return true;
570 }
567 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); 571 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2);
568 572
569 if (!GLSurfaceEGL::InitializeOneOff()) { 573 if (!GLSurfaceEGL::InitializeOneOff()) {
570 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; 574 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
571 return false; 575 return false;
572 } 576 }
573 return true; 577 return true;
574 } 578 }
575 579
576 // static 580 // static
577 scoped_refptr<GLSurface> 581 scoped_refptr<GLSurface>
578 GLSurface::CreateViewGLSurface(gfx::AcceleratedWidget window) { 582 GLSurface::CreateViewGLSurface(gfx::AcceleratedWidget window) {
583
584 if (GetGLImplementation() == kGLImplementationOSMesaGL) {
585 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless(window));
jonathan.backer 2013/06/27 17:13:28 Can we define this class in an anonymous namespace
rjkroege 2013/06/28 00:25:01 Yes. But there is a difficulty around this. gl_sur
jonathan.backer 2013/06/28 13:13:47 Thanks for the explanation. I have a slight prefer
586 if (!surface->Initialize())
587 return NULL;
588 return surface;
589 }
579 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); 590 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2);
580 if (window) { 591 if (window) {
581 scoped_refptr<NativeViewGLSurfaceEGL> surface; 592 scoped_refptr<NativeViewGLSurfaceEGL> surface;
582 VSyncProvider* sync_provider = NULL; 593 VSyncProvider* sync_provider = NULL;
583 #if defined(USE_OZONE) 594 #if defined(USE_OZONE)
584 window = ui::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget( 595 window = ui::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget(
585 window); 596 window);
586 sync_provider = 597 sync_provider =
587 ui::SurfaceFactoryOzone::GetInstance()->GetVSyncProvider(window); 598 ui::SurfaceFactoryOzone::GetInstance()->GetVSyncProvider(window);
588 #endif 599 #endif
589 surface = new NativeViewGLSurfaceEGL(window); 600 surface = new NativeViewGLSurfaceEGL(window);
590 if(surface->Initialize(sync_provider)) 601 if(surface->Initialize(sync_provider))
591 return surface; 602 return surface;
592 } else { 603 } else {
593 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); 604 scoped_refptr<GLSurface> surface = new GLSurfaceStub();
594 if (surface->Initialize()) 605 if (surface->Initialize())
595 return surface; 606 return surface;
596 } 607 }
597 return NULL; 608 return NULL;
598 } 609 }
599 610
600 // static 611 // static
601 scoped_refptr<GLSurface> 612 scoped_refptr<GLSurface>
602 GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) { 613 GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) {
603 switch (GetGLImplementation()) { 614 switch (GetGLImplementation()) {
615 case kGLImplementationOSMesaGL: {
616 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(1, size));
617 if (!surface->Initialize())
618 return NULL;
619
620 return surface;
621 }
604 case kGLImplementationEGLGLES2: { 622 case kGLImplementationEGLGLES2: {
605 scoped_refptr<PbufferGLSurfaceEGL> surface( 623 scoped_refptr<PbufferGLSurfaceEGL> surface(
606 new PbufferGLSurfaceEGL(size)); 624 new PbufferGLSurfaceEGL(size));
607 if (!surface->Initialize()) 625 if (!surface->Initialize())
608 return NULL; 626 return NULL;
609 return surface; 627 return surface;
610 } 628 }
611 default: 629 default:
612 NOTREACHED(); 630 NOTREACHED();
613 return NULL; 631 return NULL;
614 } 632 }
615 } 633 }
616 634
617 #endif 635 #endif
618 636
619 } // namespace gfx 637 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698