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

Side by Side Diff: ui/gfx/image/image_unittest.cc

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: win fix after rebase Created 3 years, 8 months 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
« no previous file with comments | « ui/gfx/icon_util.cc ('k') | ui/gfx/image/image_unittest_util.cc » ('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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkPaint.h" 10 #include "third_party/skia/include/core/SkPaint.h"
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 499
500 EXPECT_TRUE(ns_image); 500 EXPECT_TRUE(ns_image);
501 base::mac::NSObjectRelease(ns_image); 501 base::mac::NSObjectRelease(ns_image);
502 } 502 }
503 #endif 503 #endif
504 504
505 TEST_F(ImageTest, CheckSkiaColor) { 505 TEST_F(ImageTest, CheckSkiaColor) {
506 gfx::Image image(gt::CreatePlatformImage()); 506 gfx::Image image(gt::CreatePlatformImage());
507 507
508 const SkBitmap* bitmap = image.ToSkBitmap(); 508 const SkBitmap* bitmap = image.ToSkBitmap();
509 SkAutoLockPixels auto_lock(*bitmap);
510 gt::CheckColors(bitmap->getColor(10, 10), SK_ColorGREEN); 509 gt::CheckColors(bitmap->getColor(10, 10), SK_ColorGREEN);
511 } 510 }
512 511
513 TEST_F(ImageTest, SkBitmapConversionPreservesOrientation) { 512 TEST_F(ImageTest, SkBitmapConversionPreservesOrientation) {
514 const int width = 50; 513 const int width = 50;
515 const int height = 50; 514 const int height = 50;
516 SkBitmap bitmap; 515 SkBitmap bitmap;
517 bitmap.allocN32Pixels(width, height); 516 bitmap.allocN32Pixels(width, height);
518 bitmap.eraseARGB(255, 0, 255, 0); 517 bitmap.eraseARGB(255, 0, 255, 0);
519 518
(...skipping 17 matching lines...) Expand all
537 gt::GetPlatformImageColor(gt::ToPlatformType(from_skbitmap), 10, 10), 536 gt::GetPlatformImageColor(gt::ToPlatformType(from_skbitmap), 10, 10),
538 SK_ColorRED); 537 SK_ColorRED);
539 gt::CheckColors( 538 gt::CheckColors(
540 gt::GetPlatformImageColor(gt::ToPlatformType(from_skbitmap), 10, 40), 539 gt::GetPlatformImageColor(gt::ToPlatformType(from_skbitmap), 10, 40),
541 SK_ColorGREEN); 540 SK_ColorGREEN);
542 } 541 }
543 542
544 // Force a conversion back to SkBitmap and check that the upper half is red. 543 // Force a conversion back to SkBitmap and check that the upper half is red.
545 gfx::Image from_platform(gt::CopyPlatformType(from_skbitmap)); 544 gfx::Image from_platform(gt::CopyPlatformType(from_skbitmap));
546 const SkBitmap* bitmap2 = from_platform.ToSkBitmap(); 545 const SkBitmap* bitmap2 = from_platform.ToSkBitmap();
547 SkAutoLockPixels auto_lock(*bitmap2);
548 { 546 {
549 SCOPED_TRACE("Checking color after conversion back to SkBitmap"); 547 SCOPED_TRACE("Checking color after conversion back to SkBitmap");
550 gt::CheckColors(bitmap2->getColor(10, 10), SK_ColorRED); 548 gt::CheckColors(bitmap2->getColor(10, 10), SK_ColorRED);
551 gt::CheckColors(bitmap2->getColor(10, 40), SK_ColorGREEN); 549 gt::CheckColors(bitmap2->getColor(10, 40), SK_ColorGREEN);
552 } 550 }
553 } 551 }
554 552
555 TEST_F(ImageTest, SkBitmapConversionPreservesTransparency) { 553 TEST_F(ImageTest, SkBitmapConversionPreservesTransparency) {
556 const int width = 50; 554 const int width = 50;
557 const int height = 50; 555 const int height = 50;
(...skipping 20 matching lines...) Expand all
578 gt::CheckColors( 576 gt::CheckColors(
579 gt::GetPlatformImageColor(gt::ToPlatformType(from_skbitmap), 10, 10), 577 gt::GetPlatformImageColor(gt::ToPlatformType(from_skbitmap), 10, 10),
580 SK_ColorRED); 578 SK_ColorRED);
581 gt::CheckIsTransparent( 579 gt::CheckIsTransparent(
582 gt::GetPlatformImageColor(gt::ToPlatformType(from_skbitmap), 10, 40)); 580 gt::GetPlatformImageColor(gt::ToPlatformType(from_skbitmap), 10, 40));
583 } 581 }
584 582
585 // Force a conversion back to SkBitmap and check that the upper half is red. 583 // Force a conversion back to SkBitmap and check that the upper half is red.
586 gfx::Image from_platform(gt::CopyPlatformType(from_skbitmap)); 584 gfx::Image from_platform(gt::CopyPlatformType(from_skbitmap));
587 const SkBitmap* bitmap2 = from_platform.ToSkBitmap(); 585 const SkBitmap* bitmap2 = from_platform.ToSkBitmap();
588 SkAutoLockPixels auto_lock(*bitmap2);
589 { 586 {
590 SCOPED_TRACE("Checking color after conversion back to SkBitmap"); 587 SCOPED_TRACE("Checking color after conversion back to SkBitmap");
591 gt::CheckColors(bitmap2->getColor(10, 10), SK_ColorRED); 588 gt::CheckColors(bitmap2->getColor(10, 10), SK_ColorRED);
592 gt::CheckIsTransparent(bitmap.getColor(10, 40)); 589 gt::CheckIsTransparent(bitmap.getColor(10, 40));
593 } 590 }
594 } 591 }
595 592
596 TEST_F(ImageTest, SwapRepresentations) { 593 TEST_F(ImageTest, SwapRepresentations) {
597 const size_t kRepCount = kUsesSkiaNatively ? 1U : 2U; 594 const size_t kRepCount = kUsesSkiaNatively ? 1U : 2U;
598 595
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 gfx::ImageSkiaRep(bitmap, 1.0f))); 702 gfx::ImageSkiaRep(bitmap, 1.0f)));
706 } 703 }
707 EXPECT_TRUE(!image.ToSkBitmap()->isNull()); 704 EXPECT_TRUE(!image.ToSkBitmap()->isNull());
708 } 705 }
709 706
710 // Integration tests with UI toolkit frameworks require linking against the 707 // Integration tests with UI toolkit frameworks require linking against the
711 // Views library and cannot be here (ui_base_unittests doesn't include it). They 708 // Views library and cannot be here (ui_base_unittests doesn't include it). They
712 // instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc. 709 // instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc.
713 710
714 } // namespace 711 } // namespace
OLDNEW
« no previous file with comments | « ui/gfx/icon_util.cc ('k') | ui/gfx/image/image_unittest_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698