Skip to content

Commit

Permalink
[Transparency][WIN] add "force-cpu-draw" command line switch / global…
Browse files Browse the repository at this point in the history
… variable for transparency click through

Conflicts:
	ui/views/win/hwnd_message_handler.cc
  • Loading branch information
jefry-vcube authored and rogerwang committed Feb 28, 2015
1 parent 6b49cbf commit a9e8631
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions content/browser/compositor/software_output_device_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
#include "ui/gfx/canvas_skia_paint.h"
#include "ui/gfx/gdi_util.h"
#include "ui/gfx/skia_util.h"
#include "ui/views/win/hwnd_message_handler.h"
#include "ui/gfx/win/hwnd_util.h"

namespace content {
extern bool g_force_cpu_draw;

SoftwareOutputDeviceWin::SoftwareOutputDeviceWin(ui::Compositor* compositor)
: hwnd_(compositor->widget()),
Expand Down Expand Up @@ -71,6 +74,14 @@ void SoftwareOutputDeviceWin::EndPaint(cc::SoftwareFrameData* frame_data) {

SkCanvas* canvas = contents_->sk_canvas();
DCHECK(canvas);

if (g_force_cpu_draw) {
LONG style = GetWindowLong(hwnd_, GWL_EXSTYLE);
is_hwnd_composited_ = !!(style & (WS_EX_COMPOSITED | WS_EX_LAYERED));
views::HWNDMessageHandler* window = reinterpret_cast<views::HWNDMessageHandler*>(gfx::GetWindowUserData(hwnd_));
is_hwnd_composited_ &= window->remove_standard_frame_;
}

if (is_hwnd_composited_) {
RECT wr;
GetWindowRect(hwnd_, &wr);
Expand Down
5 changes: 5 additions & 0 deletions ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include "ui/wm/core/input_method_event_filter.h"
#include "ui/wm/core/window_animations.h"
#include "ui/wm/public/scoped_tooltip_disabler.h"

namespace content {
extern bool g_force_cpu_draw;
}

DECLARE_WINDOW_PROPERTY_TYPE(views::DesktopWindowTreeHostWin*);

Expand Down Expand Up @@ -908,6 +912,7 @@ void DesktopWindowTreeHostWin::HandleInputLanguageChange(

bool DesktopWindowTreeHostWin::HandlePaintAccelerated(
const gfx::Rect& invalid_rect) {
if (content::g_force_cpu_draw) return false;
return native_widget_delegate_->OnNativeWidgetPaintAccelerated(invalid_rect);
}

Expand Down
3 changes: 2 additions & 1 deletion ui/views/win/hwnd_message_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

namespace content {
extern bool g_support_transparency;
extern bool g_force_cpu_draw;
}

namespace views {
Expand Down Expand Up @@ -2564,7 +2565,7 @@ void HWNDMessageHandler::PerformDwmTransition() {
// The non-client view needs to update too.
delegate_->HandleFrameChanged();

if (IsVisible() && !delegate_->IsUsingCustomFrame()) {
if (IsVisible() && !delegate_->IsUsingCustomFrame() && !content::g_force_cpu_draw) {
// For some reason, we need to hide the window after we change from a custom
// frame to a native frame. If we don't, the client area will be filled
// with black. This seems to be related to an interaction between DWM and
Expand Down

0 comments on commit a9e8631

Please sign in to comment.