| OLD | NEW |
| 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 "ui/gfx/image/image_skia.h" | 5 #include "ui/gfx/image/image_skia.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 // so other thread cannot read/modify it. | 383 // so other thread cannot read/modify it. |
| 384 image.image_reps(); | 384 image.image_reps(); |
| 385 test::TestOnThread image_on_thread2(&image); | 385 test::TestOnThread image_on_thread2(&image); |
| 386 image_on_thread2.StartAndJoin(); | 386 image_on_thread2.StartAndJoin(); |
| 387 EXPECT_FALSE(image_on_thread2.can_read()); | 387 EXPECT_FALSE(image_on_thread2.can_read()); |
| 388 EXPECT_FALSE(image_on_thread2.can_modify()); | 388 EXPECT_FALSE(image_on_thread2.can_modify()); |
| 389 EXPECT_TRUE(image.CanRead()); | 389 EXPECT_TRUE(image.CanRead()); |
| 390 EXPECT_TRUE(image.CanModify()); | 390 EXPECT_TRUE(image.CanModify()); |
| 391 | 391 |
| 392 image.DetachStorageFromThread(); | 392 image.DetachStorageFromThread(); |
| 393 scoped_ptr<ImageSkia> deep_copy(image.DeepCopy()); | 393 std::unique_ptr<ImageSkia> deep_copy(image.DeepCopy()); |
| 394 EXPECT_FALSE(deep_copy->IsThreadSafe()); | 394 EXPECT_FALSE(deep_copy->IsThreadSafe()); |
| 395 test::TestOnThread deepcopy_on_thread(deep_copy.get()); | 395 test::TestOnThread deepcopy_on_thread(deep_copy.get()); |
| 396 deepcopy_on_thread.StartAndJoin(); | 396 deepcopy_on_thread.StartAndJoin(); |
| 397 EXPECT_TRUE(deepcopy_on_thread.can_read()); | 397 EXPECT_TRUE(deepcopy_on_thread.can_read()); |
| 398 EXPECT_TRUE(deepcopy_on_thread.can_modify()); | 398 EXPECT_TRUE(deepcopy_on_thread.can_modify()); |
| 399 EXPECT_FALSE(deep_copy->CanRead()); | 399 EXPECT_FALSE(deep_copy->CanRead()); |
| 400 EXPECT_FALSE(deep_copy->CanModify()); | 400 EXPECT_FALSE(deep_copy->CanModify()); |
| 401 | 401 |
| 402 scoped_ptr<ImageSkia> deep_copy2(image.DeepCopy()); | 402 std::unique_ptr<ImageSkia> deep_copy2(image.DeepCopy()); |
| 403 EXPECT_EQ(1U, deep_copy2->image_reps().size()); | 403 EXPECT_EQ(1U, deep_copy2->image_reps().size()); |
| 404 // Access it from current thread so that it can't be | 404 // Access it from current thread so that it can't be |
| 405 // accessed from another thread. | 405 // accessed from another thread. |
| 406 deep_copy2->image_reps(); | 406 deep_copy2->image_reps(); |
| 407 EXPECT_FALSE(deep_copy2->IsThreadSafe()); | 407 EXPECT_FALSE(deep_copy2->IsThreadSafe()); |
| 408 test::TestOnThread deepcopy2_on_thread(deep_copy2.get()); | 408 test::TestOnThread deepcopy2_on_thread(deep_copy2.get()); |
| 409 deepcopy2_on_thread.StartAndJoin(); | 409 deepcopy2_on_thread.StartAndJoin(); |
| 410 EXPECT_FALSE(deepcopy2_on_thread.can_read()); | 410 EXPECT_FALSE(deepcopy2_on_thread.can_read()); |
| 411 EXPECT_FALSE(deepcopy2_on_thread.can_modify()); | 411 EXPECT_FALSE(deepcopy2_on_thread.can_modify()); |
| 412 EXPECT_TRUE(deep_copy2->CanRead()); | 412 EXPECT_TRUE(deep_copy2->CanRead()); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 EXPECT_EQ(1U, image.image_reps().size()); | 623 EXPECT_EQ(1U, image.image_reps().size()); |
| 624 | 624 |
| 625 const ImageSkiaRep& rep12 = image.GetRepresentation(1.2f); | 625 const ImageSkiaRep& rep12 = image.GetRepresentation(1.2f); |
| 626 EXPECT_EQ(1.0f, rep12.scale()); | 626 EXPECT_EQ(1.0f, rep12.scale()); |
| 627 EXPECT_EQ("100x200", rep12.pixel_size().ToString()); | 627 EXPECT_EQ("100x200", rep12.pixel_size().ToString()); |
| 628 EXPECT_TRUE(rep12.unscaled()); | 628 EXPECT_TRUE(rep12.unscaled()); |
| 629 EXPECT_EQ(1U, image.image_reps().size()); | 629 EXPECT_EQ(1U, image.image_reps().size()); |
| 630 } | 630 } |
| 631 | 631 |
| 632 } // namespace gfx | 632 } // namespace gfx |
| OLD | NEW |