OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/view.h" | 5 #include "views/view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 return; | 406 return; |
407 transform_.reset(NULL); | 407 transform_.reset(NULL); |
408 #if !defined(COMPOSITOR_2) | 408 #if !defined(COMPOSITOR_2) |
409 canvas_.reset(); | 409 canvas_.reset(); |
410 #else | 410 #else |
411 texture_.reset(); | 411 texture_.reset(); |
412 #endif | 412 #endif |
413 SchedulePaint(); | 413 SchedulePaint(); |
414 } else { | 414 } else { |
415 transform_.reset(new ui::Transform(transform)); | 415 transform_.reset(new ui::Transform(transform)); |
416 // TODO: this needs to trigger a paint on the widget. It shouldn't use | 416 #if defined(COMPOSITOR_2) |
417 // SchedulePaint as we don't want to mark the views dirty. | 417 if (!texture_.get()) { |
| 418 // We don't yet have a texture. SchedulePaint so one is created. |
| 419 SchedulePaint(); |
| 420 } else { |
| 421 // We have a texture. When the transform changes and the texture is up to |
| 422 // date we don't want to SchedulePaint as it'll trigger painting to the |
| 423 // texture. Instead we tell the Widget to paint, which makes the |
| 424 // compositor draw using the existing texture. |
| 425 // We schedule paint the complete bounds as compositor generally don't |
| 426 // support partial painting. |
| 427 Widget* widget = GetWidget(); |
| 428 if (widget) |
| 429 widget->SchedulePaintInRect(widget->GetRootView()->bounds()); |
| 430 } |
| 431 #endif |
418 } | 432 } |
419 } | 433 } |
420 | 434 |
421 // RTL positioning ------------------------------------------------------------- | 435 // RTL positioning ------------------------------------------------------------- |
422 | 436 |
423 gfx::Rect View::GetMirroredBounds() const { | 437 gfx::Rect View::GetMirroredBounds() const { |
424 gfx::Rect bounds(bounds_); | 438 gfx::Rect bounds(bounds_); |
425 bounds.set_x(GetMirroredX()); | 439 bounds.set_x(GetMirroredX()); |
426 return bounds; | 440 return bounds; |
427 } | 441 } |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 | 1176 |
1163 for (int i = 0, count = child_count(); i < count; ++i) | 1177 for (int i = 0, count = child_count(); i < count; ++i) |
1164 GetChildViewAt(i)->PaintComposite(); | 1178 GetChildViewAt(i)->PaintComposite(); |
1165 } | 1179 } |
1166 | 1180 |
1167 void View::PaintToTexture(const gfx::Rect& dirty_region) { | 1181 void View::PaintToTexture(const gfx::Rect& dirty_region) { |
1168 if (!IsVisible()) | 1182 if (!IsVisible()) |
1169 return; | 1183 return; |
1170 | 1184 |
1171 if (ShouldPaintToTexture() && texture_needs_updating_) { | 1185 if (ShouldPaintToTexture() && texture_needs_updating_) { |
1172 texture_clip_rect_ = dirty_region; | 1186 if (!texture_.get()) { |
1173 Paint(NULL); | 1187 // If we have no texture paint the whole view. We do this to handle two |
1174 texture_clip_rect_.SetRect(0, 0, 0, 0); | 1188 // cases: |
| 1189 // . Workaround for WidgetWin/WindowWin. In particular its possible to |
| 1190 // create the rootview at the non-client size, even though we'll never |
| 1191 // paint at that size. |
| 1192 // . In case the texture is recreated and a partial paint was scheduled. |
| 1193 Paint(NULL); |
| 1194 } else { |
| 1195 texture_clip_rect_ = dirty_region; |
| 1196 Paint(NULL); |
| 1197 texture_clip_rect_.SetRect(0, 0, 0, 0); |
| 1198 } |
1175 } else { | 1199 } else { |
1176 // Forward to all children as a descendant may be dirty and have a texture. | 1200 // Forward to all children as a descendant may be dirty and have a texture. |
1177 for (int i = child_count() - 1; i >= 0; --i) { | 1201 for (int i = child_count() - 1; i >= 0; --i) { |
1178 View* child_view = GetChildViewAt(i); | 1202 View* child_view = GetChildViewAt(i); |
1179 gfx::Rect child_dirty_rect(child_view->bounds().Intersect(dirty_region)); | 1203 gfx::Rect child_dirty_rect(child_view->bounds().Intersect(dirty_region)); |
1180 if (!child_dirty_rect.IsEmpty()) { | 1204 if (!child_dirty_rect.IsEmpty()) { |
1181 child_dirty_rect.Offset(-child_view->x(), -child_view->y()); | 1205 child_dirty_rect.Offset(-child_view->x(), -child_view->y()); |
1182 GetChildViewAt(i)->PaintToTexture(child_dirty_rect); | 1206 GetChildViewAt(i)->PaintToTexture(child_dirty_rect); |
1183 } | 1207 } |
1184 } | 1208 } |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 result.append(GetChildViewAt(i)->PrintViewGraph(false)); | 1875 result.append(GetChildViewAt(i)->PrintViewGraph(false)); |
1852 | 1876 |
1853 if (first) | 1877 if (first) |
1854 result.append("}\n"); | 1878 result.append("}\n"); |
1855 | 1879 |
1856 return result; | 1880 return result; |
1857 } | 1881 } |
1858 #endif | 1882 #endif |
1859 | 1883 |
1860 } // namespace views | 1884 } // namespace views |
OLD | NEW |