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

Side by Side Diff: ui/compositor/layer_unittest.cc

Issue 11359172: ui: Remove implicit flooring in skia rect conversion methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make root window transform in tests produce an integer result Created 8 years, 1 month 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 | « ui/aura/window_unittest.cc ('k') | ui/gfx/rect_conversions.h » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 void SetSchedulePaintRect(const gfx::Rect& rect) { 1031 void SetSchedulePaintRect(const gfx::Rect& rect) {
1032 schedule_paint_rect_ = rect; 1032 schedule_paint_rect_ = rect;
1033 } 1033 }
1034 1034
1035 int GetPaintCountAndClear() { 1035 int GetPaintCountAndClear() {
1036 int value = paint_count_; 1036 int value = paint_count_;
1037 paint_count_ = 0; 1037 paint_count_ = 0;
1038 return value; 1038 return value;
1039 } 1039 }
1040 1040
1041 const gfx::Rect& last_clip_rect() const { return last_clip_rect_; } 1041 const gfx::RectF& last_clip_rect() const { return last_clip_rect_; }
1042 1042
1043 private: 1043 private:
1044 // Overridden from LayerDelegate: 1044 // Overridden from LayerDelegate:
1045 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { 1045 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE {
1046 paint_count_++; 1046 paint_count_++;
1047 if (!schedule_paint_rect_.IsEmpty()) { 1047 if (!schedule_paint_rect_.IsEmpty()) {
1048 layer_->SchedulePaint(schedule_paint_rect_); 1048 layer_->SchedulePaint(schedule_paint_rect_);
1049 schedule_paint_rect_ = gfx::Rect(); 1049 schedule_paint_rect_ = gfx::Rect();
1050 } 1050 }
1051 SkRect sk_clip_rect; 1051 SkRect sk_clip_rect;
1052 if (canvas->sk_canvas()->getClipBounds(&sk_clip_rect)) 1052 if (canvas->sk_canvas()->getClipBounds(&sk_clip_rect))
1053 last_clip_rect_ = gfx::SkRectToRect(sk_clip_rect); 1053 last_clip_rect_ = gfx::SkRectToRectF(sk_clip_rect);
1054 } 1054 }
1055 1055
1056 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE { 1056 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE {
1057 } 1057 }
1058 1058
1059 virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE { 1059 virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE {
1060 return base::Closure(); 1060 return base::Closure();
1061 } 1061 }
1062 1062
1063 int paint_count_; 1063 int paint_count_;
1064 Layer* layer_; 1064 Layer* layer_;
1065 gfx::Rect schedule_paint_rect_; 1065 gfx::Rect schedule_paint_rect_;
1066 gfx::Rect last_clip_rect_; 1066 gfx::RectF last_clip_rect_;
1067 1067
1068 DISALLOW_COPY_AND_ASSIGN(SchedulePaintLayerDelegate); 1068 DISALLOW_COPY_AND_ASSIGN(SchedulePaintLayerDelegate);
1069 }; 1069 };
1070 1070
1071 } // namespace 1071 } // namespace
1072 1072
1073 // Verifies that if SchedulePaint is invoked during painting the layer is still 1073 // Verifies that if SchedulePaint is invoked during painting the layer is still
1074 // marked dirty. 1074 // marked dirty.
1075 TEST_F(LayerWithDelegateTest, SchedulePaintFromOnPaintLayer) { 1075 TEST_F(LayerWithDelegateTest, SchedulePaintFromOnPaintLayer) {
1076 scoped_ptr<Layer> root(CreateColorLayer(SK_ColorRED, 1076 scoped_ptr<Layer> root(CreateColorLayer(SK_ColorRED,
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 1296
1297 // Resize layer. 1297 // Resize layer.
1298 child->SetBounds(gfx::Rect(200, 200, 400, 400)); 1298 child->SetBounds(gfx::Rect(200, 200, 400, 400));
1299 child->SetVisible(true); 1299 child->SetVisible(true);
1300 EXPECT_TRUE(schedule_draw_invoked_); 1300 EXPECT_TRUE(schedule_draw_invoked_);
1301 DrawTree(root.get()); 1301 DrawTree(root.get());
1302 EXPECT_TRUE(delegate.painted()); 1302 EXPECT_TRUE(delegate.painted());
1303 } 1303 }
1304 1304
1305 } // namespace ui 1305 } // namespace ui
OLDNEW
« no previous file with comments | « ui/aura/window_unittest.cc ('k') | ui/gfx/rect_conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698