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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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->allocPixels(info); | 70 bitmap->allocPixels(info); |
71 bitmap->pixelRef()->setImmutable(); | 71 bitmap->pixelRef()->setImmutable(); |
72 bitmap->pixelRef()->setURI(uri); | 72 bitmap->pixelRef()->setURI(uri); |
73 } | 73 } |
74 | 74 |
75 SkCanvas* StartRecording(SkPictureRecorder* recorder, gfx::Rect layer_rect) { | 75 SkCanvas* StartRecording(SkPictureRecorder* recorder, gfx::Rect layer_rect) { |
76 SkCanvas* canvas = recorder->beginRecording( | 76 SkCanvas* canvas = |
77 layer_rect.width(), | 77 recorder->beginRecording(layer_rect.width(), layer_rect.height()); |
78 layer_rect.height(), | |
79 NULL, | |
80 SkPicture::kUsePathBoundsForClip_RecordingFlag); | |
81 | 78 |
82 canvas->save(); | 79 canvas->save(); |
83 canvas->translate(-layer_rect.x(), -layer_rect.y()); | 80 canvas->translate(-layer_rect.x(), -layer_rect.y()); |
84 canvas->clipRect(SkRect::MakeXYWH( | 81 canvas->clipRect(SkRect::MakeXYWH( |
85 layer_rect.x(), layer_rect.y(), layer_rect.width(), layer_rect.height())); | 82 layer_rect.x(), layer_rect.y(), layer_rect.width(), layer_rect.height())); |
86 | 83 |
87 return canvas; | 84 return canvas; |
88 } | 85 } |
89 | 86 |
90 SkPicture* StopRecording(SkPictureRecorder* recorder, SkCanvas* canvas) { | 87 SkPicture* StopRecording(SkPictureRecorder* recorder, SkCanvas* canvas) { |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 EXPECT_EQ(3u, pixel_refs.size()); | 665 EXPECT_EQ(3u, pixel_refs.size()); |
669 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), | 666 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), |
670 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); | 667 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); |
671 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40), | 668 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40), |
672 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); | 669 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); |
673 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145), | 670 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145), |
674 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); | 671 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); |
675 } | 672 } |
676 | 673 |
677 } // namespace skia | 674 } // namespace skia |
OLD | NEW |