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

Side by Side Diff: views/view.cc

Issue 7056013: Two tweaks for accelerated painting: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaks Created 9 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 (!texture_.get()) {
Ben Goodger (Google) 2011/05/20 18:10:02 don't you need this to be #if defined(COMPOSITOR_2
417 // SchedulePaint as we don't want to mark the views dirty. 417 // We don't yet have a texture. SchedulePaint so one is created.
418 SchedulePaint();
419 } else {
420 // We have a texture. When the transform changes and the texture is up to
421 // date we don't want to SchedulePaint as it'll trigger painting to the
422 // texture. Instead we tell the Widget to paint, which makes the
423 // compositor draw using the existing texture.
424 // We schedule paint the complete bounds as compositor generally don't
425 // support partial painting.
426 Widget* widget = GetWidget();
427 if (widget)
428 widget->SchedulePaintInRect(widget->GetRootView()->bounds());
429 }
418 } 430 }
419 } 431 }
420 432
421 // RTL positioning ------------------------------------------------------------- 433 // RTL positioning -------------------------------------------------------------
422 434
423 gfx::Rect View::GetMirroredBounds() const { 435 gfx::Rect View::GetMirroredBounds() const {
424 gfx::Rect bounds(bounds_); 436 gfx::Rect bounds(bounds_);
425 bounds.set_x(GetMirroredX()); 437 bounds.set_x(GetMirroredX());
426 return bounds; 438 return bounds;
427 } 439 }
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 1174
1163 for (int i = 0, count = child_count(); i < count; ++i) 1175 for (int i = 0, count = child_count(); i < count; ++i)
1164 GetChildViewAt(i)->PaintComposite(); 1176 GetChildViewAt(i)->PaintComposite();
1165 } 1177 }
1166 1178
1167 void View::PaintToTexture(const gfx::Rect& dirty_region) { 1179 void View::PaintToTexture(const gfx::Rect& dirty_region) {
1168 if (!IsVisible()) 1180 if (!IsVisible())
1169 return; 1181 return;
1170 1182
1171 if (ShouldPaintToTexture() && texture_needs_updating_) { 1183 if (ShouldPaintToTexture() && texture_needs_updating_) {
1172 texture_clip_rect_ = dirty_region; 1184 if (!texture_.get()) {
Ben Goodger (Google) 2011/05/20 18:10:02 again with the ifdefs
1173 Paint(NULL); 1185 // If we have no texture paint the whole view. We do this to handle two
1174 texture_clip_rect_.SetRect(0, 0, 0, 0); 1186 // cases:
1187 // . Workaround for WidgetWin/WindowWin. In particular its possible to
1188 // create the rootview at the non-client size, even though we'll never
1189 // paint at that size.
1190 // . In case the texture is recreated and a partial paint was scheduled.
1191 Paint(NULL);
1192 } else {
1193 texture_clip_rect_ = dirty_region;
1194 Paint(NULL);
1195 texture_clip_rect_.SetRect(0, 0, 0, 0);
1196 }
1175 } else { 1197 } else {
1176 // Forward to all children as a descendant may be dirty and have a texture. 1198 // Forward to all children as a descendant may be dirty and have a texture.
1177 for (int i = child_count() - 1; i >= 0; --i) { 1199 for (int i = child_count() - 1; i >= 0; --i) {
1178 View* child_view = GetChildViewAt(i); 1200 View* child_view = GetChildViewAt(i);
1179 gfx::Rect child_dirty_rect(child_view->bounds().Intersect(dirty_region)); 1201 gfx::Rect child_dirty_rect(child_view->bounds().Intersect(dirty_region));
1180 if (!child_dirty_rect.IsEmpty()) { 1202 if (!child_dirty_rect.IsEmpty()) {
1181 child_dirty_rect.Offset(-child_view->x(), -child_view->y()); 1203 child_dirty_rect.Offset(-child_view->x(), -child_view->y());
1182 GetChildViewAt(i)->PaintToTexture(child_dirty_rect); 1204 GetChildViewAt(i)->PaintToTexture(child_dirty_rect);
1183 } 1205 }
1184 } 1206 }
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 result.append(GetChildViewAt(i)->PrintViewGraph(false)); 1873 result.append(GetChildViewAt(i)->PrintViewGraph(false));
1852 1874
1853 if (first) 1875 if (first)
1854 result.append("}\n"); 1876 result.append("}\n");
1855 1877
1856 return result; 1878 return result;
1857 } 1879 }
1858 #endif 1880 #endif
1859 1881
1860 } // namespace views 1882 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698