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

Unified Diff: chrome/browser/ui/window_snapshot/window_snapshot_win.cc

Issue 9387027: Revert 121840 - Make scoped dc objects smarter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 months 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 | « chrome/browser/aeropeek_manager.cc ('k') | chrome/renderer/print_web_view_helper_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/window_snapshot/window_snapshot_win.cc
===================================================================
--- chrome/browser/ui/window_snapshot/window_snapshot_win.cc (revision 121842)
+++ chrome/browser/ui/window_snapshot/window_snapshot_win.cc (working copy)
@@ -43,29 +43,36 @@
&hdr);
unsigned char *bit_ptr = NULL;
base::win::ScopedBitmap bitmap(
- CreateDIBSection(mem_hdc.get(),
+ CreateDIBSection(mem_hdc,
reinterpret_cast<BITMAPINFO*>(&hdr),
DIB_RGB_COLORS,
reinterpret_cast<void **>(&bit_ptr),
NULL, 0));
- base::win::ScopedSelectObject select_bitmap(mem_hdc.get(), bitmap);
+ base::win::ScopedSelectObject select_bitmap(mem_hdc, bitmap);
// Clear the bitmap to white (so that rounded corners on windows
// show up on a white background, and strangely-shaped windows
// look reasonable). Not capturing an alpha mask saves a
// bit of space.
- PatBlt(mem_hdc.get(), 0, 0, snapshot_bounds.width(), snapshot_bounds.height(),
+ PatBlt(mem_hdc, 0, 0, snapshot_bounds.width(), snapshot_bounds.height(),
WHITENESS);
+ // Grab a copy of the window
+ // First, see if PrintWindow is defined (it's not in Windows 2000).
+ typedef BOOL (WINAPI *PrintWindowPointer)(HWND, HDC, UINT);
+ PrintWindowPointer print_window =
+ reinterpret_cast<PrintWindowPointer>(
+ GetProcAddress(GetModuleHandle(L"User32.dll"), "PrintWindow"));
- if (snapshot_bounds.origin() != gfx::Point()) {
- BitBlt(mem_hdc.get(),
- 0, 0, snapshot_bounds.width(), snapshot_bounds.height(),
- window_hdc,
- snapshot_bounds.x(), snapshot_bounds.y(),
- SRCCOPY);
- } else if (!PrintWindow(window_handle, mem_hdc.get(), 0)) {
- NOTREACHED();
- }
+ // If PrintWindow is defined, use it. It will work on partially
+ // obscured windows, and works better for out of process sub-windows.
+ // Otherwise grab the bits we can get with BitBlt; it's better
+ // than nothing and will work fine in the average case (window is
+ // completely on screen).
+ if (snapshot_bounds.origin() == gfx::Point() && print_window)
+ (*print_window)(window_handle, mem_hdc, 0);
+ else
+ BitBlt(mem_hdc, 0, 0, snapshot_bounds.width(), snapshot_bounds.height(),
+ window_hdc, snapshot_bounds.x(), snapshot_bounds.y(), SRCCOPY);
// We now have a copy of the window contents in a DIB, so
// encode it into a useful format for posting to the bug report
« no previous file with comments | « chrome/browser/aeropeek_manager.cc ('k') | chrome/renderer/print_web_view_helper_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698