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 // TODO(awalker): clean up the const/non-const reference handling in this test | 5 // TODO(awalker): clean up the const/non-const reference handling in this test |
6 | 6 |
7 #include "skia/ext/platform_canvas.h" | 7 #include "skia/ext/platform_canvas.h" |
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 EXPECT_TRUE(0 != platform_bitmap->GetSurface()); | 411 EXPECT_TRUE(0 != platform_bitmap->GetSurface()); |
412 EXPECT_FALSE(platform_bitmap->GetBitmap().empty()); | 412 EXPECT_FALSE(platform_bitmap->GetBitmap().empty()); |
413 EXPECT_FALSE(platform_bitmap->GetBitmap().isNull()); | 413 EXPECT_FALSE(platform_bitmap->GetBitmap().isNull()); |
414 EXPECT_EQ(kWidth, platform_bitmap->GetBitmap().width()); | 414 EXPECT_EQ(kWidth, platform_bitmap->GetBitmap().width()); |
415 EXPECT_EQ(kHeight, platform_bitmap->GetBitmap().height()); | 415 EXPECT_EQ(kHeight, platform_bitmap->GetBitmap().height()); |
416 EXPECT_LE(static_cast<size_t>(platform_bitmap->GetBitmap().width()*4), | 416 EXPECT_LE(static_cast<size_t>(platform_bitmap->GetBitmap().width()*4), |
417 platform_bitmap->GetBitmap().rowBytes()); | 417 platform_bitmap->GetBitmap().rowBytes()); |
418 EXPECT_EQ(kN32_SkColorType, // Same for all platforms. | 418 EXPECT_EQ(kN32_SkColorType, // Same for all platforms. |
419 platform_bitmap->GetBitmap().colorType()); | 419 platform_bitmap->GetBitmap().colorType()); |
420 EXPECT_TRUE(platform_bitmap->GetBitmap().lockPixelsAreWritable()); | 420 EXPECT_TRUE(platform_bitmap->GetBitmap().lockPixelsAreWritable()); |
| 421 #if defined(SK_DEBUG) |
421 EXPECT_TRUE(platform_bitmap->GetBitmap().pixelRef()->isLocked()); | 422 EXPECT_TRUE(platform_bitmap->GetBitmap().pixelRef()->isLocked()); |
| 423 #endif |
422 EXPECT_TRUE(platform_bitmap->GetBitmap().pixelRef()->unique()); | 424 EXPECT_TRUE(platform_bitmap->GetBitmap().pixelRef()->unique()); |
423 | 425 |
424 *(platform_bitmap->GetBitmap().getAddr32(10, 20)) = 0xDEED1020; | 426 *(platform_bitmap->GetBitmap().getAddr32(10, 20)) = 0xDEED1020; |
425 *(platform_bitmap->GetBitmap().getAddr32(20, 30)) = 0xDEED2030; | 427 *(platform_bitmap->GetBitmap().getAddr32(20, 30)) = 0xDEED2030; |
426 | 428 |
427 SkBitmap sk_bitmap = platform_bitmap->GetBitmap(); | 429 SkBitmap sk_bitmap = platform_bitmap->GetBitmap(); |
428 sk_bitmap.lockPixels(); | 430 sk_bitmap.lockPixels(); |
429 | 431 |
430 EXPECT_FALSE(platform_bitmap->GetBitmap().pixelRef()->unique()); | 432 EXPECT_FALSE(platform_bitmap->GetBitmap().pixelRef()->unique()); |
431 EXPECT_FALSE(sk_bitmap.pixelRef()->unique()); | 433 EXPECT_FALSE(sk_bitmap.pixelRef()->unique()); |
(...skipping 18 matching lines...) Expand all Loading... |
450 | 452 |
451 sk_bitmap.lockPixels(); | 453 sk_bitmap.lockPixels(); |
452 EXPECT_EQ(0xDEED1020, *sk_bitmap.getAddr32(10, 20)); | 454 EXPECT_EQ(0xDEED1020, *sk_bitmap.getAddr32(10, 20)); |
453 EXPECT_EQ(0xDEED2030, *sk_bitmap.getAddr32(20, 30)); | 455 EXPECT_EQ(0xDEED2030, *sk_bitmap.getAddr32(20, 30)); |
454 EXPECT_EQ(0xDEED3040, *sk_bitmap.getAddr32(30, 40)); | 456 EXPECT_EQ(0xDEED3040, *sk_bitmap.getAddr32(30, 40)); |
455 sk_bitmap.unlockPixels(); | 457 sk_bitmap.unlockPixels(); |
456 } | 458 } |
457 | 459 |
458 | 460 |
459 } // namespace skia | 461 } // namespace skia |
OLD | NEW |