| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "skia/ext/bitmap_platform_device_mac.h" | 5 #include "skia/ext/bitmap_platform_device_mac.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "skia/ext/skia_utils_mac.h" | 8 #include "skia/ext/skia_utils_mac.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/skia/include/core/SkMatrix.h" | 10 #include "third_party/skia/include/core/SkMatrix.h" |
| 11 #include "third_party/skia/include/core/SkRegion.h" | 11 #include "third_party/skia/include/core/SkRegion.h" |
| 12 #include "third_party/skia/include/core/SkClipStack.h" | 12 #include "third_party/skia/include/core/SkClipStack.h" |
| 13 | 13 |
| 14 namespace skia { | 14 namespace skia { |
| 15 | 15 |
| 16 const int kWidth = 400; | 16 const int kWidth = 400; |
| 17 const int kHeight = 300; | 17 const int kHeight = 300; |
| 18 | 18 |
| 19 class BitmapPlatformDeviceMacTest : public testing::Test { | 19 class BitmapPlatformDeviceMacTest : public testing::Test { |
| 20 public: | 20 public: |
| 21 BitmapPlatformDeviceMacTest() { | 21 BitmapPlatformDeviceMacTest() { |
| 22 bitmap_.reset(BitmapPlatformDevice::Create( | 22 bitmap_.reset(BitmapPlatformDevice::Create( |
| 23 NULL, kWidth, kHeight, /*is_opaque=*/true)); | 23 NULL, kWidth, kHeight, /*is_opaque=*/true)); |
| 24 bitmap_->accessBitmap(true).eraseARGB(0, 0, 0, 0); |
| 24 } | 25 } |
| 25 | 26 |
| 26 scoped_ptr<BitmapPlatformDevice> bitmap_; | 27 scoped_ptr<BitmapPlatformDevice> bitmap_; |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithTranslate) { | 30 TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithTranslate) { |
| 30 SkMatrix transform; | 31 SkMatrix transform; |
| 31 transform.setTranslate(50, 140); | 32 transform.setTranslate(50, 140); |
| 32 | 33 |
| 33 SkClipStack ignore; | 34 SkClipStack ignore; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 60 CGContextRef context = bitmap_->GetBitmapContext(); | 61 CGContextRef context = bitmap_->GetBitmapContext(); |
| 61 SkRect clip_rect = gfx::CGRectToSkRect(CGContextGetClipBoundingBox(context)); | 62 SkRect clip_rect = gfx::CGRectToSkRect(CGContextGetClipBoundingBox(context)); |
| 62 transform.mapRect(&clip_rect); | 63 transform.mapRect(&clip_rect); |
| 63 EXPECT_EQ(0, clip_rect.fLeft); | 64 EXPECT_EQ(0, clip_rect.fLeft); |
| 64 EXPECT_EQ(0, clip_rect.fTop); | 65 EXPECT_EQ(0, clip_rect.fTop); |
| 65 EXPECT_EQ(kWidth, clip_rect.width()); | 66 EXPECT_EQ(kWidth, clip_rect.width()); |
| 66 EXPECT_EQ(kHeight, clip_rect.height()); | 67 EXPECT_EQ(kHeight, clip_rect.height()); |
| 67 } | 68 } |
| 68 | 69 |
| 69 } // namespace skia | 70 } // namespace skia |
| OLD | NEW |