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 class RenderWidgetHost; | 7 class RenderWidgetHost; |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 return backing_store; | 55 return backing_store; |
56 } | 56 } |
57 | 57 |
58 // static | 58 // static |
59 BackingStore* BackingStoreManager::PrepareBackingStore( | 59 BackingStore* BackingStoreManager::PrepareBackingStore( |
60 RenderWidgetHost* host, | 60 RenderWidgetHost* host, |
61 const gfx::Rect& backing_store_rect, | 61 const gfx::Rect& backing_store_rect, |
62 base::ProcessHandle process_handle, | 62 base::ProcessHandle process_handle, |
63 BitmapWireData bitmap_section, | 63 TransportDIB* bitmap, |
64 const gfx::Rect& bitmap_rect, | 64 const gfx::Rect& bitmap_rect, |
65 bool* needs_full_paint) { | 65 bool* needs_full_paint) { |
66 BackingStore* backing_store = GetBackingStore(host, | 66 BackingStore* backing_store = GetBackingStore(host, |
67 backing_store_rect.size()); | 67 backing_store_rect.size()); |
68 if (!backing_store) { | 68 if (!backing_store) { |
69 // We need to get Webkit to generate a new paint here, as we | 69 // We need to get Webkit to generate a new paint here, as we |
70 // don't have a previous snapshot. | 70 // don't have a previous snapshot. |
71 if (bitmap_rect != backing_store_rect) { | 71 if (bitmap_rect != backing_store_rect) { |
72 DCHECK(needs_full_paint != NULL); | 72 DCHECK(needs_full_paint != NULL); |
73 *needs_full_paint = true; | 73 *needs_full_paint = true; |
74 } | 74 } |
75 backing_store = CreateBackingStore(host, backing_store_rect); | 75 backing_store = CreateBackingStore(host, backing_store_rect); |
76 } | 76 } |
77 | 77 |
78 DCHECK(backing_store != NULL); | 78 DCHECK(backing_store != NULL); |
79 backing_store->PaintRect(process_handle, bitmap_section, bitmap_rect); | 79 backing_store->PaintRect(process_handle, bitmap, bitmap_rect); |
80 return backing_store; | 80 return backing_store; |
81 } | 81 } |
82 | 82 |
83 // static | 83 // static |
84 BackingStore* BackingStoreManager::Lookup(RenderWidgetHost* host) { | 84 BackingStore* BackingStoreManager::Lookup(RenderWidgetHost* host) { |
85 if (cache) { | 85 if (cache) { |
86 BackingStoreCache::iterator it = cache->Peek(host); | 86 BackingStoreCache::iterator it = cache->Peek(host); |
87 if (it != cache->end()) | 87 if (it != cache->end()) |
88 return it->second; | 88 return it->second; |
89 } | 89 } |
90 return NULL; | 90 return NULL; |
91 } | 91 } |
92 | 92 |
93 // static | 93 // static |
94 void BackingStoreManager::RemoveBackingStore(RenderWidgetHost* host) { | 94 void BackingStoreManager::RemoveBackingStore(RenderWidgetHost* host) { |
95 if (!cache) | 95 if (!cache) |
96 return; | 96 return; |
97 | 97 |
98 BackingStoreCache::iterator it = cache->Peek(host); | 98 BackingStoreCache::iterator it = cache->Peek(host); |
99 if (it == cache->end()) | 99 if (it == cache->end()) |
100 return; | 100 return; |
101 | 101 |
102 cache->Erase(it); | 102 cache->Erase(it); |
103 | 103 |
104 if (cache->empty()) { | 104 if (cache->empty()) { |
105 delete cache; | 105 delete cache; |
106 cache = NULL; | 106 cache = NULL; |
107 } | 107 } |
108 } | 108 } |
OLD | NEW |