Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Unified Diff: ui/views/win/hwnd_message_handler.cc

Issue 673623002: Fix regions generation on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/path_win_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/win/hwnd_message_handler.cc
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index 1544507ef39740982de458fcff8f71dd0b069b6c..4d2d0d866241e19dad3b25862404555de2da2473 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -12,6 +12,7 @@
#include "base/bind.h"
#include "base/debug/trace_event.h"
+#include "base/win/scoped_gdi_object.h"
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
#include "ui/base/touch/touch_enabled.h"
@@ -1128,14 +1129,14 @@ void HWNDMessageHandler::ResetWindowRegion(bool force, bool redraw) {
// Changing the window region is going to force a paint. Only change the
// window region if the region really differs.
- HRGN current_rgn = CreateRectRgn(0, 0, 0, 0);
+ base::win::ScopedRegion current_rgn(CreateRectRgn(0, 0, 0, 0));
int current_rgn_result = GetWindowRgn(hwnd(), current_rgn);
RECT window_rect;
GetWindowRect(hwnd(), &window_rect);
- HRGN new_region;
+ base::win::ScopedRegion new_region;
if (custom_window_region_) {
- new_region = ::CreateRectRgn(0, 0, 0, 0);
+ new_region.Set(::CreateRectRgn(0, 0, 0, 0));
::CombineRgn(new_region, custom_window_region_.Get(), NULL, RGN_COPY);
} else if (IsMaximized()) {
HMONITOR monitor = MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONEAREST);
@@ -1144,23 +1145,23 @@ void HWNDMessageHandler::ResetWindowRegion(bool force, bool redraw) {
GetMonitorInfo(monitor, &mi);
RECT work_rect = mi.rcWork;
OffsetRect(&work_rect, -window_rect.left, -window_rect.top);
- new_region = CreateRectRgnIndirect(&work_rect);
+ new_region.Set(CreateRectRgnIndirect(&work_rect));
} else {
gfx::Path window_mask;
delegate_->GetWindowMask(gfx::Size(window_rect.right - window_rect.left,
window_rect.bottom - window_rect.top),
&window_mask);
- new_region = gfx::CreateHRGNFromSkPath(window_mask);
+ if (!window_mask.isEmpty())
+ new_region.Set(gfx::CreateHRGNFromSkPath(window_mask));
}
- if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) {
+ const bool has_current_region = current_rgn != 0;
+ const bool has_new_region = new_region != 0;
+ if (has_current_region != has_new_region ||
+ (has_current_region && !EqualRgn(current_rgn, new_region))) {
// SetWindowRgn takes ownership of the HRGN created by CreateNativeRegion.
- SetWindowRgn(hwnd(), new_region, redraw);
- } else {
- DeleteObject(new_region);
+ SetWindowRgn(hwnd(), new_region.release(), redraw);
}
-
- DeleteObject(current_rgn);
}
void HWNDMessageHandler::UpdateDwmNcRenderingPolicy() {
« no previous file with comments | « ui/gfx/path_win_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698