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

Side by Side Diff: cc/layer_sorter_unittest.cc

Issue 11362024: added fix that deals with precision in layer sorter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comments and formatting as requested by reviewers 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 | « cc/layer_sorter.cc ('k') | 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer_sorter.h" 7 #include "cc/layer_sorter.h"
8 8
9 #include "cc/layer_impl.h" 9 #include "cc/layer_impl.h"
10 #include "cc/math_util.h" 10 #include "cc/math_util.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 layerSorter.sort(layerList.begin(), layerList.end()); 257 layerSorter.sort(layerList.begin(), layerList.end());
258 258
259 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); 259 ASSERT_EQ(static_cast<size_t>(5), layerList.size());
260 EXPECT_EQ(3, layerList[0]->id()); 260 EXPECT_EQ(3, layerList[0]->id());
261 EXPECT_EQ(4, layerList[1]->id()); 261 EXPECT_EQ(4, layerList[1]->id());
262 EXPECT_EQ(1, layerList[2]->id()); 262 EXPECT_EQ(1, layerList[2]->id());
263 EXPECT_EQ(2, layerList[3]->id()); 263 EXPECT_EQ(2, layerList[3]->id());
264 EXPECT_EQ(5, layerList[4]->id()); 264 EXPECT_EQ(5, layerList[4]->id());
265 } 265 }
266 266
267 TEST(LayerSorterTest, verifyConcidentLayerPrecisionLossResultsInDocumentOrder)
268 {
269 DebugScopedSetImplThread thisScopeIsOnImplThread;
270
271 scoped_ptr<LayerImpl> layer1 = LayerImpl::create(1);
272 scoped_ptr<LayerImpl> layer2 = LayerImpl::create(2);
273
274 // Layer 1 should occur of layer 2 in paint. However, due to numeric
275 // issues in the sorter, it will puts the layers in the wrong order
276 // in some situations. Here we test a patch that results in in
277 // document order rather than calculated order when numeric percision
278 // is suspect in calculated order.
279
280 WebTransformationMatrix BehindMatrix;
281 BehindMatrix.translate3d(0, 0, 0.999999f);
282 BehindMatrix.rotate3d(38.5f, 77.0f, 0);
283 WebTransformationMatrix FrontMatrix;
284 FrontMatrix.translate3d(0, 0, 1.0f);
285 FrontMatrix.rotate3d(38.5f, 77.0f, 0);
286
287 layer1->setBounds(IntSize(10, 10));
288 layer1->setContentBounds(IntSize(10, 10));
289 layer1->setDrawTransform(BehindMatrix);
290 layer1->setDrawsContent(true);
291
292 layer2->setBounds(IntSize(10, 10));
293 layer2->setContentBounds(IntSize(10, 10));
294 layer2->setDrawTransform(FrontMatrix);
295 layer2->setDrawsContent(true);
296
297 std::vector<LayerImpl*> layerList;
298 layerList.push_back(layer1.get());
299 layerList.push_back(layer2.get());
300
301 ASSERT_EQ(static_cast<size_t>(2), layerList.size());
302 EXPECT_EQ(1, layerList[0]->id());
303 EXPECT_EQ(2, layerList[1]->id());
304
305 LayerSorter layerSorter;
306 layerSorter.sort(layerList.begin(), layerList.end());
307
308 ASSERT_EQ(static_cast<size_t>(2), layerList.size());
309 EXPECT_EQ(1, layerList[0]->id());
310 EXPECT_EQ(2, layerList[1]->id());
311 EXPECT_FALSE(1.0f == 0.999999f);
enne (OOO) 2012/11/01 22:55:23 As I think about it, I'm not sure this is worth as
312 }
313
267 } // namespace 314 } // namespace
OLDNEW
« no previous file with comments | « cc/layer_sorter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698