OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/renderer_host/backing_store_win.h" | 5 #include "content/browser/renderer_host/backing_store_win.h" |
6 | 6 |
7 #include "app/surface/transport_dib.h" | |
8 #include "base/command_line.h" | 7 #include "base/command_line.h" |
9 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
10 #include "content/browser/renderer_host/render_process_host.h" | 9 #include "content/browser/renderer_host/render_process_host.h" |
11 #include "content/browser/renderer_host/render_widget_host.h" | 10 #include "content/browser/renderer_host/render_widget_host.h" |
12 #include "skia/ext/platform_canvas.h" | 11 #include "skia/ext/platform_canvas.h" |
13 #include "ui/gfx/gdi_util.h" | 12 #include "ui/gfx/gdi_util.h" |
| 13 #include "ui/gfx/surface/transport_dib.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // Creates a dib conforming to the height/width/section parameters passed in. | 17 // Creates a dib conforming to the height/width/section parameters passed in. |
18 HANDLE CreateDIB(HDC dc, int width, int height, int color_depth) { | 18 HANDLE CreateDIB(HDC dc, int width, int height, int color_depth) { |
19 BITMAPV5HEADER hdr = {0}; | 19 BITMAPV5HEADER hdr = {0}; |
20 ZeroMemory(&hdr, sizeof(BITMAPV5HEADER)); | 20 ZeroMemory(&hdr, sizeof(BITMAPV5HEADER)); |
21 | 21 |
22 // These values are shared with gfx::PlatformDevice | 22 // These values are shared with gfx::PlatformDevice |
23 hdr.bV5Size = sizeof(BITMAPINFOHEADER); | 23 hdr.bV5Size = sizeof(BITMAPINFOHEADER); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 rv = StretchDIBits(hdc, | 62 rv = StretchDIBits(hdc, |
63 dest_x, dest_y, dest_w, dest_h, | 63 dest_x, dest_y, dest_w, dest_h, |
64 src_x, bottom_up_src_y, src_w, src_h, | 64 src_x, bottom_up_src_y, src_w, src_h, |
65 pixels, bitmap_info, DIB_RGB_COLORS, SRCCOPY); | 65 pixels, bitmap_info, DIB_RGB_COLORS, SRCCOPY); |
66 } | 66 } |
67 DCHECK(rv != GDI_ERROR); | 67 DCHECK(rv != GDI_ERROR); |
68 } | 68 } |
69 | 69 |
70 } // namespace | 70 } // namespace |
71 | 71 |
72 BackingStoreWin::BackingStoreWin(RenderWidgetHost* widget, const gfx::Size& size
) | 72 BackingStoreWin::BackingStoreWin(RenderWidgetHost* widget, |
| 73 const gfx::Size& size) |
73 : BackingStore(widget, size), | 74 : BackingStore(widget, size), |
74 backing_store_dib_(NULL), | 75 backing_store_dib_(NULL), |
75 original_bitmap_(NULL) { | 76 original_bitmap_(NULL) { |
76 HDC screen_dc = ::GetDC(NULL); | 77 HDC screen_dc = ::GetDC(NULL); |
77 color_depth_ = ::GetDeviceCaps(screen_dc, BITSPIXEL); | 78 color_depth_ = ::GetDeviceCaps(screen_dc, BITSPIXEL); |
78 // Color depths less than 16 bpp require a palette to be specified. Instead, | 79 // Color depths less than 16 bpp require a palette to be specified. Instead, |
79 // we specify the desired color depth as 16 which lets the OS to come up | 80 // we specify the desired color depth as 16 which lets the OS to come up |
80 // with an approximation. | 81 // with an approximation. |
81 if (color_depth_ < 16) | 82 if (color_depth_ < 16) |
82 color_depth_ = 16; | 83 color_depth_ = 16; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 167 |
167 void BackingStoreWin::ScrollBackingStore(int dx, int dy, | 168 void BackingStoreWin::ScrollBackingStore(int dx, int dy, |
168 const gfx::Rect& clip_rect, | 169 const gfx::Rect& clip_rect, |
169 const gfx::Size& view_size) { | 170 const gfx::Size& view_size) { |
170 RECT damaged_rect, r = clip_rect.ToRECT(); | 171 RECT damaged_rect, r = clip_rect.ToRECT(); |
171 ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); | 172 ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); |
172 | 173 |
173 // TODO(darin): this doesn't work if dx and dy are both non-zero! | 174 // TODO(darin): this doesn't work if dx and dy are both non-zero! |
174 DCHECK(dx == 0 || dy == 0); | 175 DCHECK(dx == 0 || dy == 0); |
175 } | 176 } |
OLD | NEW |