Commit 5c20d4ec authored by jbauman's avatar jbauman Committed by Commit bot

Remove layered window painting support from HWNDMessageHandler

The compositor always handles painting these directly now, so the additional buffer and code isn't necessary.

Review URL: https://codereview.chromium.org/1127393004

Cr-Commit-Position: refs/heads/master@{#329680}
parent 6888d6f9
......@@ -422,7 +422,6 @@ bool DesktopWindowTreeHostWin::IsFullscreen() const {
}
void DesktopWindowTreeHostWin::SetOpacity(unsigned char opacity) {
message_handler_->SetOpacity(static_cast<BYTE>(opacity));
content_window_->layer()->SetOpacity(opacity / 255.0);
}
......
......@@ -319,9 +319,6 @@ HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate)
lock_updates_count_(0),
ignore_window_pos_changes_(false),
last_monitor_(NULL),
use_layered_buffer_(false),
layered_alpha_(255),
waiting_for_redraw_layered_window_contents_(false),
is_first_nccalc_(true),
menu_depth_(0),
id_generator_(0),
......@@ -788,35 +785,6 @@ void HWNDMessageHandler::FrameTypeChanged() {
}
}
void HWNDMessageHandler::SchedulePaintInRect(const gfx::Rect& rect) {
if (use_layered_buffer_) {
// We must update the back-buffer immediately, since Windows' handling of
// invalid rects is somewhat mysterious.
invalid_rect_.Union(rect);
// In some situations, such as drag and drop, when Windows itself runs a
// nested message loop our message loop appears to be starved and we don't
// receive calls to DidProcessMessage(). This only seems to affect layered
// windows, so we schedule a redraw manually using a task, since those never
// seem to be starved. Also, wtf.
if (!waiting_for_redraw_layered_window_contents_) {
waiting_for_redraw_layered_window_contents_ = true;
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&HWNDMessageHandler::RedrawLayeredWindowContents,
weak_factory_.GetWeakPtr()));
}
} else {
// InvalidateRect() expects client coordinates.
RECT r = rect.ToRECT();
InvalidateRect(hwnd(), &r, FALSE);
}
}
void HWNDMessageHandler::SetOpacity(BYTE opacity) {
layered_alpha_ = opacity;
}
void HWNDMessageHandler::SetWindowIcons(const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon) {
if (!window_icon.isNull()) {
......@@ -1108,8 +1076,6 @@ void HWNDMessageHandler::TrackMouseEvents(DWORD mouse_tracking_flags) {
void HWNDMessageHandler::ClientAreaSizeChanged() {
gfx::Size s = GetClientAreaBounds().size();
delegate_->HandleClientSizeChanged(s);
if (use_layered_buffer_)
layered_window_contents_.reset(new gfx::Canvas(s, 1.0f, false));
}
bool HWNDMessageHandler::GetClientAreaInsets(gfx::Insets* insets) const {
......@@ -1239,35 +1205,6 @@ void HWNDMessageHandler::UnlockUpdates(bool force) {
}
}
void HWNDMessageHandler::RedrawLayeredWindowContents() {
waiting_for_redraw_layered_window_contents_ = false;
if (invalid_rect_.IsEmpty())
return;
// We need to clip to the dirty rect ourselves.
layered_window_contents_->sk_canvas()->save();
double scale = gfx::GetDPIScale();
layered_window_contents_->sk_canvas()->scale(
SkScalar(scale),SkScalar(scale));
layered_window_contents_->ClipRect(invalid_rect_);
delegate_->PaintLayeredWindow(layered_window_contents_.get());
layered_window_contents_->sk_canvas()->scale(
SkScalar(1.0/scale),SkScalar(1.0/scale));
layered_window_contents_->sk_canvas()->restore();
RECT wr;
GetWindowRect(hwnd(), &wr);
SIZE size = {wr.right - wr.left, wr.bottom - wr.top};
POINT position = {wr.left, wr.top};
HDC dib_dc = skia::BeginPlatformPaint(layered_window_contents_->sk_canvas());
POINT zero = {0, 0};
BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA};
UpdateLayeredWindow(hwnd(), NULL, &position, &size, dib_dc, &zero,
RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA);
invalid_rect_.SetRect(0, 0, 0, 0);
skia::EndPlatformPaint(layered_window_contents_->sk_canvas());
}
void HWNDMessageHandler::ForceRedrawWindow(int attempts) {
if (ui::IsWorkstationLocked()) {
// Presents will continue to fail as long as the input desktop is
......@@ -1365,8 +1302,6 @@ LRESULT HWNDMessageHandler::OnCreate(CREATESTRUCT* create_struct) {
tracked_objects::ScopedTracker tracking_profile1(
FROM_HERE_WITH_EXPLICIT_FUNCTION("440919 HWNDMessageHandler::OnCreate1"));
use_layered_buffer_ = !!(window_ex_style() & WS_EX_LAYERED);
if (window_ex_style() & WS_EX_COMPOSITED) {
// TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed.
tracked_objects::ScopedTracker tracking_profile2(
......@@ -2054,17 +1989,6 @@ void HWNDMessageHandler::OnNCPaint(HRGN rgn) {
OffsetRect(&dirty_region, -window_rect.left, -window_rect.top);
}
gfx::Rect old_paint_region = invalid_rect_;
if (!old_paint_region.IsEmpty()) {
// The root view has a region that needs to be painted. Include it in the
// region we're going to paint.
RECT old_paint_region_crect = old_paint_region.ToRECT();
RECT tmp = dirty_region;
UnionRect(&dirty_region, &tmp, &old_paint_region_crect);
}
SchedulePaintInRect(gfx::Rect(dirty_region));
delegate_->HandlePaintAccelerated(gfx::Rect(dirty_region));
// When using a custom frame, we want to avoid calling DefWindowProc() since
......
......@@ -189,9 +189,6 @@ class VIEWS_EXPORT HWNDMessageHandler :
void FrameTypeChanged();
void SchedulePaintInRect(const gfx::Rect& rect);
void SetOpacity(BYTE opacity);
void SetWindowIcons(const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon);
......@@ -305,10 +302,6 @@ class VIEWS_EXPORT HWNDMessageHandler :
// Stops ignoring SetWindowPos() requests (see below).
void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; }
// Synchronously updates the invalid contents of the Widget. Valid for
// layered windows only.
void RedrawLayeredWindowContents();
// Attempts to force the window to be redrawn, ensuring that it gets
// onscreen.
void ForceRedrawWindow(int attempts);
......@@ -545,39 +538,6 @@ class VIEWS_EXPORT HWNDMessageHandler :
HMONITOR last_monitor_;
gfx::Rect last_monitor_rect_, last_work_area_;
// Layered windows -----------------------------------------------------------
// Should we keep an off-screen buffer? This is false by default, set to true
// when WS_EX_LAYERED is specified before the native window is created.
//
// NOTE: this is intended to be used with a layered window (a window with an
// extended window style of WS_EX_LAYERED). If you are using a layered window
// and NOT changing the layered alpha or anything else, then leave this value
// alone. OTOH if you are invoking SetLayeredWindowAttributes then you'll
// most likely want to set this to false, or after changing the alpha toggle
// the extended style bit to false than back to true. See MSDN for more
// details.
bool use_layered_buffer_;
// The default alpha to be applied to the layered window.
BYTE layered_alpha_;
// A canvas that contains the window contents in the case of a layered
// window.
scoped_ptr<gfx::Canvas> layered_window_contents_;
// We must track the invalid rect ourselves, for two reasons:
// For layered windows, Windows will not do this properly with
// InvalidateRect()/GetUpdateRect(). (In fact, it'll return misleading
// information from GetUpdateRect()).
// We also need to keep track of the invalid rectangle for the RootView should
// we need to paint the non-client area. The data supplied to WM_NCPAINT seems
// to be insufficient.
gfx::Rect invalid_rect_;
// Set to true when waiting for RedrawLayeredWindowContents().
bool waiting_for_redraw_layered_window_contents_;
// True the first time nccalc is called on a sizable widget
bool is_first_nccalc_;
......
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