| 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/render_widget_host.h" | 5 #include "chrome/browser/renderer_host/render_widget_host.h" |
| 6 | 6 |
| 7 #include "base/gfx/gdi_util.h" | 7 #include "base/gfx/gdi_util.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "chrome/app/chrome_dll_resource.h" | 9 #include "chrome/app/chrome_dll_resource.h" |
| 10 #include "chrome/browser/renderer_host/backing_store.h" | 10 #include "chrome/browser/renderer_host/backing_store.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 return; | 187 return; |
| 188 view_->SetIsLoading(is_loading); | 188 view_->SetIsLoading(is_loading); |
| 189 } | 189 } |
| 190 | 190 |
| 191 BackingStore* RenderWidgetHost::GetBackingStore() { | 191 BackingStore* RenderWidgetHost::GetBackingStore() { |
| 192 // We should not be asked to paint while we are hidden. If we are hidden, | 192 // We should not be asked to paint while we are hidden. If we are hidden, |
| 193 // then it means that our consumer failed to call WasRestored. | 193 // then it means that our consumer failed to call WasRestored. |
| 194 DCHECK(!is_hidden_) << "GetBackingStore called while hidden!"; | 194 DCHECK(!is_hidden_) << "GetBackingStore called while hidden!"; |
| 195 | 195 |
| 196 // We might have a cached backing store that we can reuse! | 196 // We might have a cached backing store that we can reuse! |
| 197 BackingStore* backing_store = | 197 BackingStore* backing_store = |
| 198 BackingStoreManager::GetBackingStore(this, current_size_); | 198 BackingStoreManager::GetBackingStore(this, current_size_); |
| 199 // If we fail to find a backing store in the cache, send out a request | 199 // If we fail to find a backing store in the cache, send out a request |
| 200 // to the renderer to paint the view if required. | 200 // to the renderer to paint the view if required. |
| 201 if (!backing_store && !repaint_ack_pending_ && !resize_ack_pending_ && | 201 if (!backing_store && !repaint_ack_pending_ && !resize_ack_pending_ && |
| 202 !view_being_painted_) { | 202 !view_being_painted_) { |
| 203 repaint_start_time_ = TimeTicks::Now(); | 203 repaint_start_time_ = TimeTicks::Now(); |
| 204 repaint_ack_pending_ = true; | 204 repaint_ack_pending_ = true; |
| 205 Send(new ViewMsg_Repaint(routing_id_, current_size_)); | 205 Send(new ViewMsg_Repaint(routing_id_, current_size_)); |
| 206 } | 206 } |
| 207 | 207 |
| 208 // When we have asked the RenderWidget to resize, and we are still waiting on | 208 // When we have asked the RenderWidget to resize, and we are still waiting on |
| 209 // a response, block for a little while to see if we can't get a response | 209 // a response, block for a little while to see if we can't get a response |
| 210 // before returning the old (incorrectly sized) backing store. | 210 // before returning the old (incorrectly sized) backing store. |
| 211 if (resize_ack_pending_ || !backing_store) { | 211 if (resize_ack_pending_ || !backing_store) { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 // view is restored. | 555 // view is restored. |
| 556 needs_repainting_on_restore_ = true; | 556 needs_repainting_on_restore_ = true; |
| 557 return; | 557 return; |
| 558 } | 558 } |
| 559 | 559 |
| 560 // We use the view size according to the render view, which may not be | 560 // We use the view size according to the render view, which may not be |
| 561 // quite the same as the size of our window. | 561 // quite the same as the size of our window. |
| 562 gfx::Rect view_rect(0, 0, view_size.width(), view_size.height()); | 562 gfx::Rect view_rect(0, 0, view_size.width(), view_size.height()); |
| 563 | 563 |
| 564 bool needs_full_paint = false; | 564 bool needs_full_paint = false; |
| 565 BackingStore* backing_store = | 565 BackingStore* backing_store = |
| 566 BackingStoreManager::PrepareBackingStore(this, view_rect, | 566 BackingStoreManager::PrepareBackingStore(this, view_rect, |
| 567 process_->process().handle(), | 567 process_->process().handle(), |
| 568 bitmap, bitmap_rect, | 568 bitmap, bitmap_rect, |
| 569 &needs_full_paint); | 569 &needs_full_paint); |
| 570 DCHECK(backing_store != NULL); | 570 DCHECK(backing_store != NULL); |
| 571 if (needs_full_paint) { | 571 if (needs_full_paint) { |
| 572 repaint_start_time_ = TimeTicks::Now(); | 572 repaint_start_time_ = TimeTicks::Now(); |
| 573 repaint_ack_pending_ = true; | 573 repaint_ack_pending_ = true; |
| 574 Send(new ViewMsg_Repaint(routing_id_, view_size)); | 574 Send(new ViewMsg_Repaint(routing_id_, view_size)); |
| 575 } | 575 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 590 | 590 |
| 591 // TODO(darin): do we need to do something else if our backing store is not | 591 // TODO(darin): do we need to do something else if our backing store is not |
| 592 // the same size as the advertised view? maybe we just assume there is a | 592 // the same size as the advertised view? maybe we just assume there is a |
| 593 // full paint on its way? | 593 // full paint on its way? |
| 594 BackingStore* backing_store = BackingStoreManager::Lookup(this); | 594 BackingStore* backing_store = BackingStoreManager::Lookup(this); |
| 595 if (!backing_store || (backing_store->size() != view_size)) | 595 if (!backing_store || (backing_store->size() != view_size)) |
| 596 return; | 596 return; |
| 597 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect, | 597 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect, |
| 598 dx, dy, clip_rect, view_size); | 598 dx, dy, clip_rect, view_size); |
| 599 } | 599 } |
| OLD | NEW |