Commit 0bef0a1b authored by kylechar's avatar kylechar Committed by Commit Bot

Delete SoftwareOutputDeviceWinDirectChild.

This software output device implementation created a child window to
draw into from the GPU process. This was to prevent some flashes in the
blank areas of the window on resize. While investigating
https://crbug.com/924975 it seems like drawing directly into the browser
HWND no longer causes any issues on Windows 7 or 10.

Drawing directly in the browser HWND also fixes the bug where we aren't
redrawing exposed regions on Windows 7 with DWM disabled and software
compositing. This was caused by the WM_PAINT update region being empty
for the browser window because it has the WS_CLIPCHILDREN style. The
child window wasn't handling the WM_PAINT message and with DWM disabled
Windows doesn't keep it's own copy of the pixels. As a result, nothing
was telling the display compositor to paint those pixels again.

Bug: 924975, 835906
Change-Id: I70eef78223ea6f18f4898ebb4d973811fa85c1d2
Reviewed-on: https://chromium-review.googlesource.com/c/1450399
Commit-Queue: kylechar <kylechar@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628433}
parent 37b1c730
......@@ -8,7 +8,6 @@
#include "base/memory/shared_memory.h"
#include "base/threading/thread_checker.h"
#include "base/win/windows_version.h"
#include "base/win/wrapped_window_proc.h"
#include "components/viz/common/display/use_layered_window.h"
#include "components/viz/common/resources/resource_sizes.h"
#include "components/viz/service/display_embedder/output_device_backing.h"
......@@ -17,7 +16,6 @@
#include "skia/ext/platform_canvas.h"
#include "skia/ext/skia_utils_win.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/base/win/hidden_window.h"
#include "ui/gfx/gdi_util.h"
#include "ui/gfx/skia_util.h"
#include "ui/gfx/win/hwnd_util.h"
......@@ -336,96 +334,6 @@ void SoftwareOutputDeviceWinProxy::DrawAck() {
std::move(swap_ack_callback_).Run();
}
// WindowProc callback function for SoftwareOutputDeviceWinDirectChild.
LRESULT CALLBACK IntermediateWindowProc(HWND window,
UINT message,
WPARAM w_param,
LPARAM l_param) {
switch (message) {
case WM_ERASEBKGND:
// Prevent Windows from erasing all window content on resize.
return 1;
default:
return DefWindowProc(window, message, w_param, l_param);
}
}
// SoftwareOutputDevice implementation that creates a child HWND and draws
// directly to it. This is intended to be used in the GPU process. The child
// HWND is initially parented to a hidden window and needs be reparented to the
// appropriate browser HWND. The backing buffer for paint is shared for all
// instances of this class.
class SoftwareOutputDeviceWinDirectChild
: public SoftwareOutputDeviceWinDirect {
public:
static std::unique_ptr<SoftwareOutputDeviceWinDirectChild> Create(
OutputDeviceBacking* backing);
~SoftwareOutputDeviceWinDirectChild() override;
// SoftwareOutputDeviceWinBase implementation.
void ResizeDelegated() override;
private:
static wchar_t* GetWindowClass();
SoftwareOutputDeviceWinDirectChild(HWND child_hwnd,
OutputDeviceBacking* backing);
DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDeviceWinDirectChild);
};
// static
std::unique_ptr<SoftwareOutputDeviceWinDirectChild>
SoftwareOutputDeviceWinDirectChild::Create(OutputDeviceBacking* backing) {
// Create a child window that is initially parented to a hidden window.
// |child_hwnd| needs to be reparented to a browser created HWND to be
// visible.
HWND child_hwnd =
CreateWindowEx(WS_EX_NOPARENTNOTIFY, GetWindowClass(), L"",
WS_CHILDWINDOW | WS_DISABLED | WS_VISIBLE, 0, 0, 0, 0,
ui::GetHiddenWindow(), nullptr, nullptr, nullptr);
DCHECK(child_hwnd);
return base::WrapUnique(
new SoftwareOutputDeviceWinDirectChild(child_hwnd, backing));
}
SoftwareOutputDeviceWinDirectChild::~SoftwareOutputDeviceWinDirectChild() {
DestroyWindow(hwnd());
}
void SoftwareOutputDeviceWinDirectChild::ResizeDelegated() {
SoftwareOutputDeviceWinDirect::ResizeDelegated();
// Resize the child HWND to match the content size.
SetWindowPos(hwnd(), nullptr, 0, 0, viewport_pixel_size_.width(),
viewport_pixel_size_.height(),
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOCOPYBITS |
SWP_NOOWNERZORDER | SWP_NOZORDER);
}
// static
wchar_t* SoftwareOutputDeviceWinDirectChild::GetWindowClass() {
static ATOM window_class = 0;
// Register window class on first call.
if (!window_class) {
WNDCLASSEX intermediate_class;
base::win::InitializeWindowClass(
L"Intermediate Software Window",
&base::win::WrappedWindowProc<IntermediateWindowProc>, CS_OWNDC, 0, 0,
nullptr, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)), nullptr,
nullptr, nullptr, &intermediate_class);
window_class = RegisterClassEx(&intermediate_class);
DCHECK(window_class);
}
return reinterpret_cast<wchar_t*>(window_class);
}
SoftwareOutputDeviceWinDirectChild::SoftwareOutputDeviceWinDirectChild(
HWND child_hwnd,
OutputDeviceBacking* backing)
: SoftwareOutputDeviceWinDirect(child_hwnd, backing) {}
} // namespace
std::unique_ptr<SoftwareOutputDevice> CreateSoftwareOutputDeviceWinBrowser(
......@@ -442,6 +350,8 @@ std::unique_ptr<SoftwareOutputDevice> CreateSoftwareOutputDeviceWinGpu(
OutputDeviceBacking* backing,
mojom::DisplayClient* display_client,
HWND* out_child_hwnd) {
// TODO(kylechar): Remove |out_child_hwnd| parameter it's no longer used.
if (NeedsToUseLayerWindow(hwnd)) {
DCHECK(display_client);
......@@ -456,13 +366,7 @@ std::unique_ptr<SoftwareOutputDevice> CreateSoftwareOutputDeviceWinGpu(
return std::make_unique<SoftwareOutputDeviceWinProxy>(
hwnd, std::move(layered_window_updater));
} else {
auto software_output_device =
SoftwareOutputDeviceWinDirectChild::Create(backing);
// The child HWND needs to be parented to the browser HWND to be visible.
*out_child_hwnd = software_output_device->hwnd();
return software_output_device;
return std::make_unique<SoftwareOutputDeviceWinDirect>(hwnd, backing);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment