Skip to content

Commit

Permalink
Split //ui/gl into //ui/gl + //ui/gi/init.
Browse files Browse the repository at this point in the history
Refactor //ui/gl to fix Ozone dep problem. This CL is step 1 described
in the associated bug.

BUG=611142
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review-Url: https://codereview.chromium.org/1920163005
Cr-Commit-Position: refs/heads/master@{#393838}
  • Loading branch information
kylechar authored and Commit bot committed May 16, 2016
1 parent 1d844dc commit 5b9dec1
Show file tree
Hide file tree
Showing 98 changed files with 384 additions and 116 deletions.
1 change: 1 addition & 0 deletions android_webview/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ source_set("common") {
"//third_party/WebKit/public:blink",
"//ui/events:gesture_detection",
"//ui/gl",
"//ui/gl/init",
"//ui/shell_dialogs",
"//v8",
]
Expand Down
1 change: 1 addition & 0 deletions android_webview/android_webview.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@
'../third_party/WebKit/public/blink.gyp:blink',
'../ui/events/events.gyp:gesture_detection',
'../ui/gl/gl.gyp:gl',
'../ui/gl/init/gl_init.gyp:gl_init',
'../ui/shell_dialogs/shell_dialogs.gyp:shell_dialogs',
'../url/ipc/url_ipc.gyp:url_ipc',
'../v8/src/v8.gyp:v8',
Expand Down
1 change: 1 addition & 0 deletions android_webview/android_webview_tests.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
'../testing/gtest.gyp:gtest',
'../ui/base/ui_base.gyp:ui_base_jni_headers',
'../ui/gl/gl.gyp:gl',
'../ui/gl/init/gl_init.gyp:gl_init',
'../ui/gl/gl.gyp:gl_test_support',
'android_webview_common',
'android_webview_unittests_jni',
Expand Down
2 changes: 1 addition & 1 deletion android_webview/browser/aw_gl_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace android_webview {
// This surface is used to represent the underlying surface provided by the App
// inside a hardware draw. Note that offscreen contexts will not be using this
// GLSurface.
class GL_EXPORT AwGLSurface : public gfx::GLSurface {
class AwGLSurface : public gfx::GLSurface {
public:
AwGLSurface();

Expand Down
7 changes: 4 additions & 3 deletions android_webview/browser/scoped_app_gl_state_restore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface_stub.h"
#include "ui/gl/init/gl_factory.h"

namespace android_webview {

Expand All @@ -22,9 +23,9 @@ class AppContextSurface {
public:
AppContextSurface()
: surface(new gfx::GLSurfaceStub),
context(gfx::GLContext::CreateGLContext(NULL,
surface.get(),
gfx::PreferDiscreteGpu)) {}
context(gl::init::CreateGLContext(nullptr,
surface.get(),
gfx::PreferDiscreteGpu)) {}
void MakeCurrent() { context->MakeCurrent(surface.get()); }

private:
Expand Down
7 changes: 4 additions & 3 deletions android_webview/browser/test/fake_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/init/gl_factory.h"

namespace android_webview {

Expand Down Expand Up @@ -192,11 +193,11 @@ void FakeWindow::CreateRenderThreadIfNeeded() {

void FakeWindow::InitializeOnRT(base::WaitableEvent* sync) {
CheckCurrentlyOnRT();
surface_ = gfx::GLSurface::CreateOffscreenGLSurface(surface_size_);
surface_ = gl::init::CreateOffscreenGLSurface(surface_size_);
DCHECK(surface_);
DCHECK(surface_->GetHandle());
context_ = gfx::GLContext::CreateGLContext(nullptr, surface_.get(),
gfx::PreferDiscreteGpu);
context_ = gl::init::CreateGLContext(nullptr, surface_.get(),
gfx::PreferDiscreteGpu);
DCHECK(context_);
sync->Signal();
}
Expand Down
1 change: 1 addition & 0 deletions blimp/client/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ source_set("client") {
"//third_party/libwebp",
"//ui/gfx/geometry",
"//ui/gl",
"//ui/gl/init",
"//url:url",
]
}
Expand Down
4 changes: 2 additions & 2 deletions blimp/client/app/blimp_startup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "blimp/client/app/blimp_discardable_memory_allocator.h"
#include "blimp/client/feature/compositor/decoding_image_generator.h"
#include "third_party/skia/include/core/SkGraphics.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/init/gl_factory.h"

class SkImageGenerator;

Expand Down Expand Up @@ -73,7 +73,7 @@ bool InitializeMainMessageLoop() {
// Set the DiscardableMemoryAllocator.
base::DiscardableMemoryAllocator::SetInstance(
g_discardable_memory_allocator.Pointer());
if (!gfx::GLSurface::InitializeOneOff())
if (!gl::init::InitializeGLOneOff())
return false;
SkGraphics::Init();
SkGraphics::SetImageGeneratorFromEncodedFactory(CreateImageGenerator);
Expand Down
1 change: 1 addition & 0 deletions components/mus/gles2/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ source_set("gles2") {
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/gl",
"//ui/gl/init",
"//ui/mojo/geometry:interfaces",
]

Expand Down
11 changes: 6 additions & 5 deletions components/mus/gles2/command_buffer_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_image_shared_memory.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/init/gl_factory.h"

#if defined(USE_OZONE)
#include "ui/gl/gl_image_ozone_native_pixmap.h"
Expand Down Expand Up @@ -86,16 +87,16 @@ bool CommandBufferDriver::Initialize(

const bool offscreen = widget_ == gfx::kNullAcceleratedWidget;
if (offscreen) {
surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(0, 0));
surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size(0, 0));
} else {
#if defined(USE_OZONE)
scoped_refptr<gfx::GLSurface> underlying_surface =
gfx::GLSurface::CreateSurfacelessViewGLSurface(widget_);
gl::init::CreateSurfacelessViewGLSurface(widget_);
if (!underlying_surface)
underlying_surface = gfx::GLSurface::CreateViewGLSurface(widget_);
underlying_surface = gl::init::CreateViewGLSurface(widget_);
#else
scoped_refptr<gfx::GLSurface> underlying_surface =
gfx::GLSurface::CreateViewGLSurface(widget_);
gl::init::CreateViewGLSurface(widget_);
#endif
scoped_refptr<GLSurfaceAdapterMus> surface_adapter =
new GLSurfaceAdapterMus(underlying_surface);
Expand All @@ -117,7 +118,7 @@ bool CommandBufferDriver::Initialize(
return false;

// TODO(piman): virtual contexts, gpu preference.
context_ = gfx::GLContext::CreateGLContext(
context_ = gl::init::CreateGLContext(
gpu_state_->share_group(), surface_.get(), gfx::PreferIntegratedGpu);
if (!context_.get())
return false;
Expand Down
4 changes: 2 additions & 2 deletions components/mus/gles2/gpu_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "base/threading/thread_restrictions.h"
#include "gpu/config/gpu_info_collector.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/init/gl_factory.h"

#if defined(USE_OZONE)
#include "ui/ozone/public/ozone_platform.h"
Expand Down Expand Up @@ -48,7 +48,7 @@ void GpuState::InitializeOnGpuThread(base::WaitableEvent* event) {
#if defined(USE_OZONE)
ui::OzonePlatform::InitializeForGPU();
#endif
hardware_rendering_available_ = gfx::GLSurface::InitializeOneOff();
hardware_rendering_available_ = gl::init::InitializeGLOneOff();
command_buffer_task_runner_ = new CommandBufferTaskRunner;
driver_manager_.reset(new CommandBufferDriverManager);
sync_point_manager_.reset(new gpu::SyncPointManager(true));
Expand Down
4 changes: 2 additions & 2 deletions content/common/sandbox_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "sandbox/mac/seatbelt.h"
#include "third_party/icu/source/common/unicode/uchar.h"
#include "ui/base/layout.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/init/gl_factory.h"

extern "C" {
void CGSSetDenyWindowServerConnections(bool);
Expand Down Expand Up @@ -329,7 +329,7 @@ NOINLINE void FatalStringQuoteException(const std::string& str) {
if (sandbox_type == SANDBOX_TYPE_GPU) {
// Preload either the desktop GL or the osmesa so, depending on the
// --use-gl flag.
gfx::GLSurface::InitializeOneOff();
gl::init::InitializeGLOneOff();

// Preload VideoToolbox.
media::InitializeVideoToolbox();
Expand Down
1 change: 1 addition & 0 deletions content/content_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
'../ui/gfx/ipc/gfx_ipc.gyp:gfx_ipc',
'../ui/gfx/ipc/skia/gfx_ipc_skia.gyp:gfx_ipc_skia',
'../ui/gl/gl.gyp:gl',
'../ui/gl/init/gl_init.gyp:gl_init',
'../ui/shell_dialogs/shell_dialogs.gyp:shell_dialogs',
'../url/url.gyp:url_lib',
'../url/ipc/url_ipc.gyp:url_ipc',
Expand Down
1 change: 1 addition & 0 deletions content/content_gpu.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'../media/media.gyp:media_gpu',
'../skia/skia.gyp:skia',
'../ui/gl/gl.gyp:gl',
'../ui/gl/init/gl_init.gyp:gl_init',
'content_common_mojo_bindings.gyp:content_common_mojo_bindings',
],
'sources': [
Expand Down
1 change: 1 addition & 0 deletions content/gpu/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ source_set("gpu_sources") {
"//ui/events/ipc",
"//ui/gfx/ipc",
"//ui/gl",
"//ui/gl/init",
]

if (mojo_media_host == "gpu") {
Expand Down
5 changes: 3 additions & 2 deletions content/gpu/gpu_child_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_switches.h"
#include "ui/gl/gpu_switching_manager.h"
#include "ui/gl/init/gl_factory.h"
#include "url/gurl.h"

#if defined(USE_OZONE)
Expand Down Expand Up @@ -199,8 +200,8 @@ GpuChildThread::GpuChildThread(
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kInProcessGPU));

if (!gfx::GLSurface::InitializeOneOff())
VLOG(1) << "gfx::GLSurface::InitializeOneOff failed";
if (!gl::init::InitializeGLOneOff())
VLOG(1) << "gl::init::InitializeGLOneOff failed";

g_thread_safe_sender.Get() = thread_safe_sender();
g_lazy_tls.Pointer()->Set(this);
Expand Down
21 changes: 11 additions & 10 deletions content/gpu/gpu_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_switches.h"
#include "ui/gl/gpu_switching_manager.h"
#include "ui/gl/init/gl_factory.h"

#if defined(OS_WIN)
#include <dwmapi.h>
Expand All @@ -54,8 +55,8 @@
#endif

#if defined(OS_WIN)
#include "base/win/windows_version.h"
#include "base/win/scoped_com_initializer.h"
#include "base/win/windows_version.h"
#include "media/gpu/dxva_video_decode_accelerator_win.h"
#include "sandbox/win/src/sandbox.h"
#endif
Expand Down Expand Up @@ -275,13 +276,13 @@ int GpuMain(const MainFunctionParams& parameters) {
bool gl_already_initialized = false;
#if defined(OS_MACOSX)
if (!command_line.HasSwitch(switches::kNoSandbox)) {
// On Mac, if the sandbox is enabled, then GLSurface::InitializeOneOff()
// On Mac, if the sandbox is enabled, then gl::init::InitializeGLOneOff()
// is called from the sandbox warmup code before getting here.
gl_already_initialized = true;
}
#endif
if (command_line.HasSwitch(switches::kInProcessGPU)) {
// With in-process GPU, GLSurface::InitializeOneOff() is called from
// With in-process GPU, gl::init::InitializeGLOneOff() is called from
// GpuChildThread before getting here.
gl_already_initialized = true;
}
Expand All @@ -290,7 +291,7 @@ int GpuMain(const MainFunctionParams& parameters) {
bool gl_initialized =
gl_already_initialized
? gfx::GetGLImplementation() != gfx::kGLImplementationNone
: gfx::GLSurface::InitializeOneOff();
: gl::init::InitializeGLOneOff();
if (gl_initialized) {
// We need to collect GL strings (VENDOR, RENDERER) for blacklisting
// purposes. However, on Mac we don't actually use them. As documented in
Expand Down Expand Up @@ -334,7 +335,7 @@ int GpuMain(const MainFunctionParams& parameters) {
UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo",
collect_context_time);
} else { // gl_initialized
VLOG(1) << "gfx::GLSurface::InitializeOneOff failed";
VLOG(1) << "gl::init::InitializeGLOneOff failed";
dead_on_arrival = true;
}

Expand Down Expand Up @@ -524,18 +525,18 @@ bool CanAccessNvidiaDeviceFile() {

void CreateDummyGlContext() {
scoped_refptr<gfx::GLSurface> surface(
gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()));
gl::init::CreateOffscreenGLSurface(gfx::Size()));
if (!surface.get()) {
DVLOG(1) << "gfx::GLSurface::CreateOffscreenGLSurface failed";
DVLOG(1) << "gl::init::CreateOffscreenGLSurface failed";
return;
}

// On Linux, this is needed to make sure /dev/nvidiactl has
// been opened and its descriptor cached.
scoped_refptr<gfx::GLContext> context(gfx::GLContext::CreateGLContext(
NULL, surface.get(), gfx::PreferDiscreteGpu));
scoped_refptr<gfx::GLContext> context(
gl::init::CreateGLContext(NULL, surface.get(), gfx::PreferDiscreteGpu));
if (!context.get()) {
DVLOG(1) << "gfx::GLContext::CreateGLContext failed";
DVLOG(1) << "gl::init::CreateGLContext failed";
return;
}

Expand Down
1 change: 1 addition & 0 deletions gpu/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ test("gpu_perftests") {
"//testing/perf",
"//ui/gfx/geometry",
"//ui/gl",
"//ui/gl/init",
]

# This target should not require the Chrome executable to run.
Expand Down
1 change: 1 addition & 0 deletions gpu/command_buffer/service/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ source_set("service_sources") {
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/gl",
"//ui/gl/init",
]

if (is_mac) {
Expand Down
11 changes: 6 additions & 5 deletions gpu/command_buffer/service/in_process_command_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "ui/gl/gl_image.h"
#include "ui/gl/gl_image_shared_memory.h"
#include "ui/gl/gl_share_group.h"
#include "ui/gl/init/gl_factory.h"

#if defined(OS_WIN)
#include <windows.h>
Expand Down Expand Up @@ -342,9 +343,9 @@ bool InProcessCommandBuffer::InitializeOnGpuThread(

if (!surface_.get()) {
if (params.is_offscreen)
surface_ = gfx::GLSurface::CreateOffscreenGLSurface(params.size);
surface_ = gl::init::CreateOffscreenGLSurface(params.size);
else
surface_ = gfx::GLSurface::CreateViewGLSurface(params.window);
surface_ = gl::init::CreateViewGLSurface(params.window);
}

if (!surface_.get()) {
Expand All @@ -364,7 +365,7 @@ bool InProcessCommandBuffer::InitializeOnGpuThread(
.use_virtualized_gl_contexts) {
context_ = gl_share_group_->GetSharedContext();
if (!context_.get()) {
context_ = gfx::GLContext::CreateGLContext(
context_ = gl::init::CreateGLContext(
gl_share_group_.get(), surface_.get(), params.gpu_preference);
gl_share_group_->SetSharedContext(context_.get());
}
Expand All @@ -377,8 +378,8 @@ bool InProcessCommandBuffer::InitializeOnGpuThread(
context_ = NULL;
}
} else {
context_ = gfx::GLContext::CreateGLContext(
gl_share_group_.get(), surface_.get(), params.gpu_preference);
context_ = gl::init::CreateGLContext(gl_share_group_.get(), surface_.get(),
params.gpu_preference);
}

if (!context_.get()) {
Expand Down
Loading

0 comments on commit 5b9dec1

Please sign in to comment.