Index: gpu/ipc/service/child_window_win.cc |
diff --git a/gpu/ipc/service/child_window_surface_win.cc b/gpu/ipc/service/child_window_win.cc |
similarity index 60% |
copy from gpu/ipc/service/child_window_surface_win.cc |
copy to gpu/ipc/service/child_window_win.cc |
index e7f482064f415fc79b411130ba92e22067530d92..1246c5773182b4e52ca120b0b9d16df9541e2b87 100644 |
--- a/gpu/ipc/service/child_window_surface_win.cc |
+++ b/gpu/ipc/service/child_window_win.cc |
@@ -1,8 +1,8 @@ |
-// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "gpu/ipc/service/child_window_surface_win.h" |
+#include "gpu/ipc/service/child_window_win.h" |
#include <memory> |
@@ -17,10 +17,6 @@ |
#include "ui/gfx/native_widget_types.h" |
#include "ui/gfx/win/hwnd_util.h" |
#include "ui/gfx/win/window_impl.h" |
-#include "ui/gl/egl_util.h" |
-#include "ui/gl/gl_context.h" |
-#include "ui/gl/gl_surface_egl.h" |
-#include "ui/gl/scoped_make_current.h" |
namespace gpu { |
@@ -156,50 +152,12 @@ void DestroyWindowsOnThread(HWND child_window, HWND hidden_popup_window) { |
} // namespace |
-ChildWindowSurfaceWin::ChildWindowSurfaceWin( |
+ChildWindowWin::ChildWindowWin( |
base::WeakPtr<ImageTransportSurfaceDelegate> delegate, |
HWND parent_window) |
- : gl::NativeViewGLSurfaceEGL(0), |
- parent_window_(parent_window), |
- delegate_(delegate), |
- alpha_(true), |
- first_swap_(true) { |
- // Don't use EGL_ANGLE_window_fixed_size so that we can avoid recreating the |
- // window surface, which can cause flicker on DirectComposition. |
- enable_fixed_size_angle_ = false; |
-} |
- |
-EGLConfig ChildWindowSurfaceWin::GetConfig() { |
- if (!config_) { |
- int alpha_size = alpha_ ? 8 : EGL_DONT_CARE; |
- |
- EGLint config_attribs[] = {EGL_ALPHA_SIZE, |
- alpha_size, |
- EGL_BLUE_SIZE, |
- 8, |
- EGL_GREEN_SIZE, |
- 8, |
- EGL_RED_SIZE, |
- 8, |
- EGL_RENDERABLE_TYPE, |
- EGL_OPENGL_ES2_BIT, |
- EGL_SURFACE_TYPE, |
- EGL_WINDOW_BIT | EGL_PBUFFER_BIT, |
- EGL_NONE}; |
- |
- EGLDisplay display = GetHardwareDisplay(); |
- EGLint num_configs; |
- if (!eglChooseConfig(display, config_attribs, &config_, 1, &num_configs)) { |
- LOG(ERROR) << "eglChooseConfig failed with error " |
- << ui::GetLastEGLErrorString(); |
- return NULL; |
- } |
- } |
- |
- return config_; |
-} |
+ : parent_window_(parent_window), window_(nullptr), delegate_(delegate) {} |
-bool ChildWindowSurfaceWin::InitializeNativeWindow() { |
+bool ChildWindowWin::Initialize() { |
if (window_) |
return true; |
@@ -224,78 +182,7 @@ bool ChildWindowSurfaceWin::InitializeNativeWindow() { |
return true; |
} |
-bool ChildWindowSurfaceWin::Resize(const gfx::Size& size, |
- float scale_factor, |
- bool has_alpha) { |
- if (!SupportsPostSubBuffer()) { |
- if (!MoveWindow(window_, 0, 0, size.width(), size.height(), FALSE)) { |
- return false; |
- } |
- alpha_ = has_alpha; |
- return gl::NativeViewGLSurfaceEGL::Resize(size, scale_factor, has_alpha); |
- } else { |
- if (size == GetSize() && has_alpha == alpha_) |
- return true; |
- |
- // Force a resize and redraw (but not a move, activate, etc.). |
- if (!SetWindowPos(window_, nullptr, 0, 0, size.width(), size.height(), |
- SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOCOPYBITS | |
- SWP_NOOWNERZORDER | SWP_NOZORDER)) { |
- return false; |
- } |
- size_ = size; |
- if (has_alpha == alpha_) { |
- // A 0-size PostSubBuffer doesn't swap but forces the swap chain to resize |
- // to match the window. |
- PostSubBuffer(0, 0, 0, 0); |
- } else { |
- alpha_ = has_alpha; |
- config_ = nullptr; |
- |
- std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current; |
- gl::GLContext* current_context = gl::GLContext::GetCurrent(); |
- bool was_current = current_context && current_context->IsCurrent(this); |
- if (was_current) { |
- scoped_make_current.reset( |
- new ui::ScopedMakeCurrent(current_context, this)); |
- current_context->ReleaseCurrent(this); |
- } |
- |
- Destroy(); |
- |
- if (!Initialize()) { |
- LOG(ERROR) << "Failed to resize window."; |
- return false; |
- } |
- } |
- return true; |
- } |
-} |
- |
-gfx::SwapResult ChildWindowSurfaceWin::SwapBuffers() { |
- gfx::SwapResult result = NativeViewGLSurfaceEGL::SwapBuffers(); |
- // Force the driver to finish drawing before clearing the contents to |
- // transparent, to reduce or eliminate the period of time where the contents |
- // have flashed black. |
- if (first_swap_) { |
- glFinish(); |
- first_swap_ = false; |
- } |
- ClearInvalidContents(); |
- return result; |
-} |
- |
-gfx::SwapResult ChildWindowSurfaceWin::PostSubBuffer(int x, |
- int y, |
- int width, |
- int height) { |
- gfx::SwapResult result = |
- NativeViewGLSurfaceEGL::PostSubBuffer(x, y, width, height); |
- ClearInvalidContents(); |
- return result; |
-} |
- |
-void ChildWindowSurfaceWin::ClearInvalidContents() { |
+void ChildWindowWin::ClearInvalidContents() { |
base::AutoLock lock(shared_data_->rect_lock); |
if (!shared_data_->rect_to_clear.IsEmpty()) { |
base::win::ScopedGetDC dc(window_); |
@@ -309,7 +196,7 @@ void ChildWindowSurfaceWin::ClearInvalidContents() { |
} |
} |
-ChildWindowSurfaceWin::~ChildWindowSurfaceWin() { |
+ChildWindowWin::~ChildWindowWin() { |
if (shared_data_) { |
scoped_refptr<base::TaskRunner> task_runner = |
shared_data_->thread.task_runner(); |