| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" | 5 #include "content/public/browser/window_util.h" |
| 6 | 6 |
| 7 #include "base/win/scoped_gdi_object.h" | 7 #include "base/win/scoped_gdi_object.h" |
| 8 #include "base/win/scoped_hdc.h" | 8 #include "base/win/scoped_hdc.h" |
| 9 #include "base/win/scoped_select_object.h" | 9 #include "base/win/scoped_select_object.h" |
| 10 #include "ui/gfx/codec/png_codec.h" | 10 #include "ui/gfx/codec/png_codec.h" |
| 11 #include "ui/gfx/gdi_util.h" | 11 #include "ui/gfx/gdi_util.h" |
| 12 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
| 13 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 content_rect.right++; // Match what PrintWindow wants. | 29 content_rect.right++; // Match what PrintWindow wants. |
| 30 | 30 |
| 31 return gfx::Rect(content_rect.right - content_rect.left, | 31 return gfx::Rect(content_rect.right - content_rect.left, |
| 32 content_rect.bottom - content_rect.top); | 32 content_rect.bottom - content_rect.top); |
| 33 } | 33 } |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 namespace chrome { | 37 namespace content { |
| 38 namespace internal { | 38 |
| 39 bool GrabViewSnapshot(gfx::NativeView view_handle, |
| 40 std::vector<unsigned char>* png_representation, |
| 41 const gfx::Rect& snapshot_bounds) { |
| 42 return GrabWindowSnapshot(view_handle, png_representation, snapshot_bounds); |
| 43 } |
| 39 | 44 |
| 40 bool GrabWindowSnapshot(gfx::NativeWindow window_handle, | 45 bool GrabWindowSnapshot(gfx::NativeWindow window_handle, |
| 41 std::vector<unsigned char>* png_representation, | 46 std::vector<unsigned char>* png_representation, |
| 42 const gfx::Rect& snapshot_bounds) { | 47 const gfx::Rect& snapshot_bounds) { |
| 43 DCHECK(snapshot_bounds.right() <= GetWindowBounds(window_handle).right()); | 48 DCHECK(snapshot_bounds.right() <= GetWindowBounds(window_handle).right()); |
| 44 DCHECK(snapshot_bounds.bottom() <= GetWindowBounds(window_handle).bottom()); | 49 DCHECK(snapshot_bounds.bottom() <= GetWindowBounds(window_handle).bottom()); |
| 45 | 50 |
| 46 // Create a memory DC that's compatible with the window. | 51 // Create a memory DC that's compatible with the window. |
| 47 HDC window_hdc = GetWindowDC(window_handle); | 52 HDC window_hdc = GetWindowDC(window_handle); |
| 48 base::win::ScopedCreateDC mem_hdc(CreateCompatibleDC(window_hdc)); | 53 base::win::ScopedCreateDC mem_hdc(CreateCompatibleDC(window_hdc)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 snapshot_bounds.size(), | 96 snapshot_bounds.size(), |
| 92 snapshot_bounds.width() * 4, true, | 97 snapshot_bounds.width() * 4, true, |
| 93 std::vector<gfx::PNGCodec::Comment>(), | 98 std::vector<gfx::PNGCodec::Comment>(), |
| 94 png_representation); | 99 png_representation); |
| 95 | 100 |
| 96 ReleaseDC(window_handle, window_hdc); | 101 ReleaseDC(window_handle, window_hdc); |
| 97 | 102 |
| 98 return true; | 103 return true; |
| 99 } | 104 } |
| 100 | 105 |
| 101 } // namespace internal | 106 } // namespace content |
| 102 } // namespace chrome | |
| OLD | NEW |