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) | |
422 EXPECT_TRUE(platform_bitmap->GetBitmap().pixelRef()->isLocked()); | 421 EXPECT_TRUE(platform_bitmap->GetBitmap().pixelRef()->isLocked()); |
423 #endif | |
424 EXPECT_TRUE(platform_bitmap->GetBitmap().pixelRef()->unique()); | 422 EXPECT_TRUE(platform_bitmap->GetBitmap().pixelRef()->unique()); |
425 | 423 |
426 *(platform_bitmap->GetBitmap().getAddr32(10, 20)) = 0xDEED1020; | 424 *(platform_bitmap->GetBitmap().getAddr32(10, 20)) = 0xDEED1020; |
427 *(platform_bitmap->GetBitmap().getAddr32(20, 30)) = 0xDEED2030; | 425 *(platform_bitmap->GetBitmap().getAddr32(20, 30)) = 0xDEED2030; |
428 | 426 |
429 SkBitmap sk_bitmap = platform_bitmap->GetBitmap(); | 427 SkBitmap sk_bitmap = platform_bitmap->GetBitmap(); |
430 sk_bitmap.lockPixels(); | 428 sk_bitmap.lockPixels(); |
431 | 429 |
432 EXPECT_FALSE(platform_bitmap->GetBitmap().pixelRef()->unique()); | 430 EXPECT_FALSE(platform_bitmap->GetBitmap().pixelRef()->unique()); |
433 EXPECT_FALSE(sk_bitmap.pixelRef()->unique()); | 431 EXPECT_FALSE(sk_bitmap.pixelRef()->unique()); |
(...skipping 18 matching lines...) Expand all Loading... |
452 | 450 |
453 sk_bitmap.lockPixels(); | 451 sk_bitmap.lockPixels(); |
454 EXPECT_EQ(0xDEED1020, *sk_bitmap.getAddr32(10, 20)); | 452 EXPECT_EQ(0xDEED1020, *sk_bitmap.getAddr32(10, 20)); |
455 EXPECT_EQ(0xDEED2030, *sk_bitmap.getAddr32(20, 30)); | 453 EXPECT_EQ(0xDEED2030, *sk_bitmap.getAddr32(20, 30)); |
456 EXPECT_EQ(0xDEED3040, *sk_bitmap.getAddr32(30, 40)); | 454 EXPECT_EQ(0xDEED3040, *sk_bitmap.getAddr32(30, 40)); |
457 sk_bitmap.unlockPixels(); | 455 sk_bitmap.unlockPixels(); |
458 } | 456 } |
459 | 457 |
460 | 458 |
461 } // namespace skia | 459 } // namespace skia |
OLD | NEW |