| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_manager.h" | 5 #include "chrome/browser/renderer_host/backing_store_manager.h" |
| 6 | 6 |
| 7 #include "base/sys_info.h" | 7 #include "base/sys_info.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/browser/renderer_host/backing_store.h" | 10 #include "chrome/browser/renderer_host/backing_store.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 return backing_store; | 189 return backing_store; |
| 190 } | 190 } |
| 191 | 191 |
| 192 // static | 192 // static |
| 193 void BackingStoreManager::PrepareBackingStore( | 193 void BackingStoreManager::PrepareBackingStore( |
| 194 RenderWidgetHost* host, | 194 RenderWidgetHost* host, |
| 195 const gfx::Size& backing_store_size, | 195 const gfx::Size& backing_store_size, |
| 196 TransportDIB::Id bitmap, | 196 TransportDIB::Id bitmap, |
| 197 const gfx::Rect& bitmap_rect, | 197 const gfx::Rect& bitmap_rect, |
| 198 const std::vector<gfx::Rect>& copy_rects, | 198 const std::vector<gfx::Rect>& copy_rects, |
| 199 bool* needs_full_paint, | 199 bool* needs_full_paint) { |
| 200 bool* painted_synchronously) { | |
| 201 // Default to declaring we're done using the transport DIB so it can be freed. | |
| 202 *painted_synchronously = true; | |
| 203 | |
| 204 BackingStore* backing_store = GetBackingStore(host, backing_store_size); | 200 BackingStore* backing_store = GetBackingStore(host, backing_store_size); |
| 205 if (!backing_store) { | 201 if (!backing_store) { |
| 206 // We need to get Webkit to generate a new paint here, as we | 202 // We need to get Webkit to generate a new paint here, as we |
| 207 // don't have a previous snapshot. | 203 // don't have a previous snapshot. |
| 208 if (bitmap_rect.size() != backing_store_size || | 204 if (bitmap_rect.size() != backing_store_size || |
| 209 bitmap_rect.x() != 0 || bitmap_rect.y() != 0 || | 205 bitmap_rect.x() != 0 || bitmap_rect.y() != 0 || |
| 210 ComputeTotalArea(copy_rects) != backing_store_size.GetArea()) { | 206 ComputeTotalArea(copy_rects) != backing_store_size.GetArea()) { |
| 211 DCHECK(needs_full_paint != NULL); | 207 DCHECK(needs_full_paint != NULL); |
| 212 *needs_full_paint = true; | 208 *needs_full_paint = true; |
| 213 // Makes no sense to paint the transport dib if we are going | 209 // Makes no sense to paint the transport dib if we are going |
| 214 // to request a full paint. | 210 // to request a full paint. |
| 215 return; | 211 return; |
| 216 } | 212 } |
| 217 backing_store = CreateBackingStore(host, backing_store_size); | 213 backing_store = CreateBackingStore(host, backing_store_size); |
| 218 } | 214 } |
| 219 | 215 |
| 220 backing_store->PaintToBackingStore(host->process(), bitmap, | 216 backing_store->PaintToBackingStore(host->process(), bitmap, |
| 221 bitmap_rect, copy_rects, | 217 bitmap_rect, copy_rects); |
| 222 painted_synchronously); | |
| 223 } | 218 } |
| 224 | 219 |
| 225 // static | 220 // static |
| 226 BackingStore* BackingStoreManager::Lookup(RenderWidgetHost* host) { | 221 BackingStore* BackingStoreManager::Lookup(RenderWidgetHost* host) { |
| 227 if (large_cache) { | 222 if (large_cache) { |
| 228 BackingStoreCache::iterator it = large_cache->Get(host); | 223 BackingStoreCache::iterator it = large_cache->Get(host); |
| 229 if (it != large_cache->end()) | 224 if (it != large_cache->end()) |
| 230 return it->second; | 225 return it->second; |
| 231 | 226 |
| 232 // This moves host to the front of the MRU. | 227 // This moves host to the front of the MRU. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 size_t mem = 0; | 279 size_t mem = 0; |
| 285 BackingStoreCache::iterator it; | 280 BackingStoreCache::iterator it; |
| 286 for (it = large_cache->begin(); it != large_cache->end(); ++it) | 281 for (it = large_cache->begin(); it != large_cache->end(); ++it) |
| 287 mem += it->second->MemorySize(); | 282 mem += it->second->MemorySize(); |
| 288 | 283 |
| 289 for (it = small_cache->begin(); it != small_cache->end(); ++it) | 284 for (it = small_cache->begin(); it != small_cache->end(); ++it) |
| 290 mem += it->second->MemorySize(); | 285 mem += it->second->MemorySize(); |
| 291 | 286 |
| 292 return mem; | 287 return mem; |
| 293 } | 288 } |
| OLD | NEW |