| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "cc/raster/image_hijack_canvas.h" | 4 #include "cc/raster/image_hijack_canvas.h" |
| 5 | 5 |
| 6 #include "cc/test/skia_common.h" | 6 #include "cc/test/skia_common.h" |
| 7 #include "cc/tiles/image_decode_cache.h" | 7 #include "cc/tiles/image_decode_cache.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 DecodedDrawImage(const DrawImage& image)); | 25 DecodedDrawImage(const DrawImage& image)); |
| 26 MOCK_METHOD2(DrawWithImageFinished, | 26 MOCK_METHOD2(DrawWithImageFinished, |
| 27 void(const DrawImage& image, | 27 void(const DrawImage& image, |
| 28 const DecodedDrawImage& decoded_image)); | 28 const DecodedDrawImage& decoded_image)); |
| 29 MOCK_METHOD0(ReduceCacheUsage, void()); | 29 MOCK_METHOD0(ReduceCacheUsage, void()); |
| 30 MOCK_METHOD1(SetShouldAggressivelyFreeResources, | 30 MOCK_METHOD1(SetShouldAggressivelyFreeResources, |
| 31 void(bool aggressively_free_resources)); | 31 void(bool aggressively_free_resources)); |
| 32 MOCK_METHOD0(ClearCache, void()); | 32 MOCK_METHOD0(ClearCache, void()); |
| 33 MOCK_METHOD2(GetOutOfRasterDecodeTaskForImageAndRef, | 33 MOCK_METHOD2(GetOutOfRasterDecodeTaskForImageAndRef, |
| 34 bool(const DrawImage& image, scoped_refptr<TileTask>* task)); | 34 bool(const DrawImage& image, scoped_refptr<TileTask>* task)); |
| 35 MOCK_CONST_METHOD0(GetMaximumMemoryLimitBytes, size_t()); |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 TEST(ImageHijackCanvasTest, NonLazyImagesSkipped) { | 38 TEST(ImageHijackCanvasTest, NonLazyImagesSkipped) { |
| 38 // Use a strict mock so that if *any* ImageDecodeCache methods are called, we | 39 // Use a strict mock so that if *any* ImageDecodeCache methods are called, we |
| 39 // will hit an error. | 40 // will hit an error. |
| 40 testing::StrictMock<MockImageDecodeCache> image_decode_cache; | 41 testing::StrictMock<MockImageDecodeCache> image_decode_cache; |
| 41 ImageIdFlatSet images_to_skip; | 42 ImageIdFlatSet images_to_skip; |
| 42 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateSRGB(); | 43 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateSRGB(); |
| 43 ImageHijackCanvas canvas(100, 100, &image_decode_cache, &images_to_skip, | 44 ImageHijackCanvas canvas(100, 100, &image_decode_cache, &images_to_skip, |
| 44 target_color_space); | 45 target_color_space); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 canvas.drawImageRect(image, SkRect::MakeXYWH(0, 0, 10, 10), | 84 canvas.drawImageRect(image, SkRect::MakeXYWH(0, 0, 10, 10), |
| 84 SkRect::MakeXYWH(10, 10, 10, 10), &paint); | 85 SkRect::MakeXYWH(10, 10, 10, 10), &paint); |
| 85 paint.setShader(image->makeShader(SkShader::kClamp_TileMode, | 86 paint.setShader(image->makeShader(SkShader::kClamp_TileMode, |
| 86 SkShader::kClamp_TileMode, nullptr)); | 87 SkShader::kClamp_TileMode, nullptr)); |
| 87 canvas.drawRect(SkRect::MakeXYWH(10, 10, 10, 10), paint); | 88 canvas.drawRect(SkRect::MakeXYWH(10, 10, 10, 10), paint); |
| 88 } | 89 } |
| 89 | 90 |
| 90 } // namespace | 91 } // namespace |
| 91 | 92 |
| 92 } // namespace cc | 93 } // namespace cc |
| OLD | NEW |