OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/renderer_host/backing_store.h" | 5 #include "chrome/browser/renderer_host/backing_store.h" |
6 | 6 |
7 #include "base/gfx/gdi_util.h" | 7 #include "base/gfx/gdi_util.h" |
8 #include "chrome/browser/renderer_host/render_widget_host.h" | 8 #include "chrome/browser/renderer_host/render_widget_host.h" |
9 #include "chrome/common/transport_dib.h" | 9 #include "chrome/common/transport_dib.h" |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 DCHECK(hdc_); | 23 DCHECK(hdc_); |
24 | 24 |
25 DeleteDC(hdc_); | 25 DeleteDC(hdc_); |
26 | 26 |
27 if (backing_store_dib_) { | 27 if (backing_store_dib_) { |
28 DeleteObject(backing_store_dib_); | 28 DeleteObject(backing_store_dib_); |
29 backing_store_dib_ = NULL; | 29 backing_store_dib_ = NULL; |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 bool BackingStore::PaintRect(base::ProcessHandle process, | 33 void BackingStore::PaintRect(base::ProcessHandle process, |
34 TransportDIB* bitmap, | 34 TransportDIB* bitmap, |
35 const gfx::Rect& bitmap_rect) { | 35 const gfx::Rect& bitmap_rect) { |
36 if (!backing_store_dib_) { | 36 if (!backing_store_dib_) { |
37 backing_store_dib_ = CreateDIB(hdc_, size_.width(), size_.height(), true, | 37 backing_store_dib_ = CreateDIB(hdc_, size_.width(), size_.height(), true, |
38 NULL); | 38 NULL); |
39 DCHECK(backing_store_dib_ != NULL); | 39 DCHECK(backing_store_dib_ != NULL); |
40 original_bitmap_ = SelectObject(hdc_, backing_store_dib_); | 40 original_bitmap_ = SelectObject(hdc_, backing_store_dib_); |
41 } | 41 } |
42 | 42 |
43 // TODO(darin): protect against integer overflow | 43 // TODO(darin): protect against integer overflow |
(...skipping 11 matching lines...) Expand all Loading... |
55 paint_rect.y(), | 55 paint_rect.y(), |
56 paint_rect.width(), | 56 paint_rect.width(), |
57 paint_rect.height(), | 57 paint_rect.height(), |
58 0, 0, // source x,y | 58 0, 0, // source x,y |
59 paint_rect.width(), | 59 paint_rect.width(), |
60 paint_rect.height(), | 60 paint_rect.height(), |
61 bitmap->memory(), | 61 bitmap->memory(), |
62 reinterpret_cast<BITMAPINFO*>(&hdr), | 62 reinterpret_cast<BITMAPINFO*>(&hdr), |
63 DIB_RGB_COLORS, | 63 DIB_RGB_COLORS, |
64 SRCCOPY); | 64 SRCCOPY); |
65 | |
66 return true; | |
67 } | 65 } |
68 | 66 |
69 void BackingStore::ScrollRect(base::ProcessHandle process, | 67 void BackingStore::ScrollRect(base::ProcessHandle process, |
70 TransportDIB* bitmap, | 68 TransportDIB* bitmap, |
71 const gfx::Rect& bitmap_rect, | 69 const gfx::Rect& bitmap_rect, |
72 int dx, int dy, | 70 int dx, int dy, |
73 const gfx::Rect& clip_rect, | 71 const gfx::Rect& clip_rect, |
74 const gfx::Size& view_size) { | 72 const gfx::Size& view_size) { |
75 RECT damaged_rect, r = clip_rect.ToRECT(); | 73 RECT damaged_rect, r = clip_rect.ToRECT(); |
76 ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); | 74 ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); |
(...skipping 28 matching lines...) Expand all Loading... |
105 gfx::CreateBitmapHeaderWithColorDepth(width, height, color_depth, &hdr); | 103 gfx::CreateBitmapHeaderWithColorDepth(width, height, color_depth, &hdr); |
106 } else { | 104 } else { |
107 gfx::CreateBitmapHeader(width, height, &hdr); | 105 gfx::CreateBitmapHeader(width, height, &hdr); |
108 } | 106 } |
109 void* data = NULL; | 107 void* data = NULL; |
110 HANDLE dib = | 108 HANDLE dib = |
111 CreateDIBSection(hdc_, reinterpret_cast<BITMAPINFO*>(&hdr), | 109 CreateDIBSection(hdc_, reinterpret_cast<BITMAPINFO*>(&hdr), |
112 0, &data, section, 0); | 110 0, &data, section, 0); |
113 return dib; | 111 return dib; |
114 } | 112 } |
OLD | NEW |