Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: chrome/browser/renderer_host/backing_store.cc

Issue 108040: Send array of paint rects and bitmaps as opposed to a Union (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/sys_info.h" 7 #include "base/sys_info.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/chrome_constants.h" 9 #include "chrome/common/chrome_constants.h"
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 cache->Put(host, backing_store); 44 cache->Put(host, backing_store);
45 } 45 }
46 return backing_store; 46 return backing_store;
47 } 47 }
48 48
49 } // namespace 49 } // namespace
50 50
51 // BackingStoreManager --------------------------------------------------------- 51 // BackingStoreManager ---------------------------------------------------------
52 52
53 // static 53 // static
54 int BackingStore::kMaxBitmapLengthAllowed = 100000;
55
54 BackingStore* BackingStoreManager::GetBackingStore( 56 BackingStore* BackingStoreManager::GetBackingStore(
55 RenderWidgetHost* host, 57 RenderWidgetHost* host,
56 const gfx::Size& desired_size) { 58 const gfx::Size& desired_size) {
57 BackingStore* backing_store = Lookup(host); 59 BackingStore* backing_store = Lookup(host);
58 if (backing_store) { 60 if (backing_store) {
59 // If we already have a backing store, then make sure it is the correct 61 // If we already have a backing store, then make sure it is the correct
60 // size. 62 // size.
61 if (backing_store->size() == desired_size) 63 if (backing_store->size() == desired_size)
62 return backing_store; 64 return backing_store;
63 backing_store = NULL; 65 backing_store = NULL;
64 } 66 }
65 67
66 return backing_store; 68 return backing_store;
67 } 69 }
68 70
69 // static 71 // static
70 BackingStore* BackingStoreManager::PrepareBackingStore( 72 BackingStore* BackingStoreManager::PrepareBackingStore(
71 RenderWidgetHost* host, 73 RenderWidgetHost* host,
72 const gfx::Size& backing_store_size, 74 const gfx::Size& backing_store_size,
73 base::ProcessHandle process_handle, 75 base::ProcessHandle process_handle,
74 TransportDIB* bitmap, 76 TransportDIB* bitmap,
75 const gfx::Rect& bitmap_rect, 77 const gfx::Rect& bitmap_rect,
78 const gfx::Rect& paint_rect,
76 bool* needs_full_paint) { 79 bool* needs_full_paint) {
77 BackingStore* backing_store = GetBackingStore(host, backing_store_size); 80 BackingStore* backing_store = GetBackingStore(host, backing_store_size);
78 if (!backing_store) { 81 if (!backing_store) {
79 // We need to get Webkit to generate a new paint here, as we 82 // We need to get Webkit to generate a new paint here, as we
80 // don't have a previous snapshot. 83 // don't have a previous snapshot.
81 if (bitmap_rect.size() != backing_store_size || 84 if (paint_rect.size() != backing_store_size ||
82 bitmap_rect.x() != 0 || bitmap_rect.y() != 0) { 85 paint_rect.x() != 0 || paint_rect.y() != 0) {
83 DCHECK(needs_full_paint != NULL); 86 DCHECK(needs_full_paint != NULL);
84 *needs_full_paint = true; 87 *needs_full_paint = true;
85 } 88 }
86 backing_store = CreateBackingStore(host, backing_store_size); 89 backing_store = CreateBackingStore(host, backing_store_size);
87 } 90 }
88 91
89 DCHECK(backing_store != NULL); 92 DCHECK(backing_store != NULL);
90 backing_store->PaintRect(process_handle, bitmap, bitmap_rect); 93 backing_store->PaintRect(process_handle, bitmap, bitmap_rect, paint_rect);
91 return backing_store; 94 return backing_store;
92 } 95 }
93 96
94 // static 97 // static
95 BackingStore* BackingStoreManager::Lookup(RenderWidgetHost* host) { 98 BackingStore* BackingStoreManager::Lookup(RenderWidgetHost* host) {
96 if (cache) { 99 if (cache) {
97 BackingStoreCache::iterator it = cache->Peek(host); 100 BackingStoreCache::iterator it = cache->Peek(host);
98 if (it != cache->end()) 101 if (it != cache->end())
99 return it->second; 102 return it->second;
100 } 103 }
101 return NULL; 104 return NULL;
102 } 105 }
103 106
104 // static 107 // static
105 void BackingStoreManager::RemoveBackingStore(RenderWidgetHost* host) { 108 void BackingStoreManager::RemoveBackingStore(RenderWidgetHost* host) {
106 if (!cache) 109 if (!cache)
107 return; 110 return;
108 111
109 BackingStoreCache::iterator it = cache->Peek(host); 112 BackingStoreCache::iterator it = cache->Peek(host);
110 if (it == cache->end()) 113 if (it == cache->end())
111 return; 114 return;
112 115
113 cache->Erase(it); 116 cache->Erase(it);
114 117
115 if (cache->empty()) { 118 if (cache->empty()) {
116 delete cache; 119 delete cache;
117 cache = NULL; 120 cache = NULL;
118 } 121 }
119 } 122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698