| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 return sizeof(SkShader::Context); | 56 return sizeof(SkShader::Context); |
| 57 } | 57 } |
| 58 | 58 |
| 59 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(TestDiscardableShader); | 59 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(TestDiscardableShader); |
| 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 bitmap->allocN32Pixels(size.width(), size.height()); |
| 67 size.width(), size.height(), kPMColor_SkColorType, kPremul_SkAlphaType | |
| 68 }; | |
| 69 | |
| 70 bitmap->allocPixels(info); | |
| 71 bitmap->pixelRef()->setImmutable(); | 67 bitmap->pixelRef()->setImmutable(); |
| 72 bitmap->pixelRef()->setURI(uri); | 68 bitmap->pixelRef()->setURI(uri); |
| 73 } | 69 } |
| 74 | 70 |
| 75 SkCanvas* StartRecording(SkPictureRecorder* recorder, gfx::Rect layer_rect) { | 71 SkCanvas* StartRecording(SkPictureRecorder* recorder, gfx::Rect layer_rect) { |
| 76 SkCanvas* canvas = | 72 SkCanvas* canvas = |
| 77 recorder->beginRecording(layer_rect.width(), layer_rect.height()); | 73 recorder->beginRecording(layer_rect.width(), layer_rect.height()); |
| 78 | 74 |
| 79 canvas->save(); | 75 canvas->save(); |
| 80 canvas->translate(-layer_rect.x(), -layer_rect.y()); | 76 canvas->translate(-layer_rect.x(), -layer_rect.y()); |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 EXPECT_EQ(3u, pixel_refs.size()); | 661 EXPECT_EQ(3u, pixel_refs.size()); |
| 666 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), | 662 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), |
| 667 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); | 663 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect)); |
| 668 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40), | 664 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 40, 40), |
| 669 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); | 665 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); |
| 670 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145), | 666 EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 55, 150, 145), |
| 671 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); | 667 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); |
| 672 } | 668 } |
| 673 | 669 |
| 674 } // namespace skia | 670 } // namespace skia |
| OLD | NEW |