OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "cc/test/geometry_test_utils.h" | 7 #include "cc/test/geometry_test_utils.h" |
8 #include "skia/ext/pixel_ref_utils.h" | 8 #include "skia/ext/pixel_ref_utils.h" |
9 #include "skia/ext/refptr.h" | 9 #include "skia/ext/refptr.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 private: | 61 private: |
62 SkBitmap bitmap_; | 62 SkBitmap bitmap_; |
63 }; | 63 }; |
64 | 64 |
65 void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) { | 65 void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) { |
66 const SkImageInfo info = { | 66 const SkImageInfo info = { |
67 size.width(), size.height(), kPMColor_SkColorType, kPremul_SkAlphaType | 67 size.width(), size.height(), kPMColor_SkColorType, kPremul_SkAlphaType |
68 }; | 68 }; |
69 | 69 |
70 bitmap->setConfig(info); | 70 bitmap->allocPixels(info); |
71 bitmap->allocPixels(); | |
72 bitmap->pixelRef()->setImmutable(); | 71 bitmap->pixelRef()->setImmutable(); |
73 bitmap->pixelRef()->setURI(uri); | 72 bitmap->pixelRef()->setURI(uri); |
74 } | 73 } |
75 | 74 |
76 SkCanvas* StartRecording(SkPictureRecorder* recorder, gfx::Rect layer_rect) { | 75 SkCanvas* StartRecording(SkPictureRecorder* recorder, gfx::Rect layer_rect) { |
77 SkCanvas* canvas = recorder->beginRecording( | 76 SkCanvas* canvas = recorder->beginRecording( |
78 layer_rect.width(), | 77 layer_rect.width(), |
79 layer_rect.height(), | 78 layer_rect.height(), |
80 NULL, | 79 NULL, |
81 SkPicture::kUsePathBoundsForClip_RecordingFlag); | 80 SkPicture::kUsePathBoundsForClip_RecordingFlag); |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 EXPECT_EQ(3u, pixel_refs.size()); | 668 EXPECT_EQ(3u, pixel_refs.size()); |
670 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), | 669 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), |
671 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); | 670 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); |
672 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40), | 671 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40), |
673 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); | 672 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); |
674 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145), | 673 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145), |
675 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); | 674 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); |
676 } | 675 } |
677 | 676 |
678 } // namespace skia | 677 } // namespace skia |
OLD | NEW |