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/win_util.h" | 9 #include "chrome/common/win_util.h" |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
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 bool BackingStore::PaintRect(base::ProcessHandle process, |
34 HANDLE bitmap_section, | 34 BitmapWireData bitmap_section, |
35 const gfx::Rect& bitmap_rect) { | 35 const gfx::Rect& bitmap_rect) { |
36 // The bitmap received is valid only in the renderer process. | 36 // The bitmap received is valid only in the renderer process. |
37 HANDLE valid_bitmap = | 37 HANDLE valid_bitmap = |
38 win_util::GetSectionFromProcess(bitmap_section, process, false); | 38 win_util::GetSectionFromProcess(bitmap_section, process, false); |
39 if (!valid_bitmap) | 39 if (!valid_bitmap) |
40 return false; | 40 return false; |
41 | 41 |
42 if (!backing_store_dib_) { | 42 if (!backing_store_dib_) { |
43 backing_store_dib_ = CreateDIB(hdc_, size_.width(), size_.height(), true, | 43 backing_store_dib_ = CreateDIB(hdc_, size_.width(), size_.height(), true, |
44 NULL); | 44 NULL); |
(...skipping 24 matching lines...) Expand all Loading... |
69 reinterpret_cast<BITMAPINFO*>(&hdr), | 69 reinterpret_cast<BITMAPINFO*>(&hdr), |
70 DIB_RGB_COLORS, | 70 DIB_RGB_COLORS, |
71 SRCCOPY); | 71 SRCCOPY); |
72 | 72 |
73 UnmapViewOfFile(backing_store_data); | 73 UnmapViewOfFile(backing_store_data); |
74 CloseHandle(valid_bitmap); | 74 CloseHandle(valid_bitmap); |
75 return true; | 75 return true; |
76 } | 76 } |
77 | 77 |
78 void BackingStore::ScrollRect(base::ProcessHandle process, | 78 void BackingStore::ScrollRect(base::ProcessHandle process, |
79 HANDLE bitmap, const gfx::Rect& bitmap_rect, | 79 BitmapWireData bitmap, |
| 80 const gfx::Rect& bitmap_rect, |
80 int dx, int dy, | 81 int dx, int dy, |
81 const gfx::Rect& clip_rect, | 82 const gfx::Rect& clip_rect, |
82 const gfx::Size& view_size) { | 83 const gfx::Size& view_size) { |
83 RECT damaged_rect, r = clip_rect.ToRECT(); | 84 RECT damaged_rect, r = clip_rect.ToRECT(); |
84 ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); | 85 ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); |
85 | 86 |
86 // TODO(darin): this doesn't work if dx and dy are both non-zero! | 87 // TODO(darin): this doesn't work if dx and dy are both non-zero! |
87 DCHECK(dx == 0 || dy == 0); | 88 DCHECK(dx == 0 || dy == 0); |
88 | 89 |
89 // We expect that damaged_rect should equal bitmap_rect. | 90 // We expect that damaged_rect should equal bitmap_rect. |
(...skipping 23 matching lines...) Expand all Loading... |
113 gfx::CreateBitmapHeaderWithColorDepth(width, height, color_depth, &hdr); | 114 gfx::CreateBitmapHeaderWithColorDepth(width, height, color_depth, &hdr); |
114 } else { | 115 } else { |
115 gfx::CreateBitmapHeader(width, height, &hdr); | 116 gfx::CreateBitmapHeader(width, height, &hdr); |
116 } | 117 } |
117 void* data = NULL; | 118 void* data = NULL; |
118 HANDLE dib = | 119 HANDLE dib = |
119 CreateDIBSection(hdc_, reinterpret_cast<BITMAPINFO*>(&hdr), | 120 CreateDIBSection(hdc_, reinterpret_cast<BITMAPINFO*>(&hdr), |
120 0, &data, section, 0); | 121 0, &data, section, 0); |
121 return dib; | 122 return dib; |
122 } | 123 } |
OLD | NEW |