| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1979 rect.Inset(6, 6, 4, 4); | 1979 rect.Inset(6, 6, 4, 4); |
| 1980 canvas.drawRect( | 1980 canvas.drawRect( |
| 1981 SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()), | 1981 SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()), |
| 1982 flags); | 1982 flags); |
| 1983 rect.Inset(6, 6, 4, 4); | 1983 rect.Inset(6, 6, 4, 4); |
| 1984 } | 1984 } |
| 1985 | 1985 |
| 1986 ResourceId mask_resource_id = this->resource_provider_->CreateResource( | 1986 ResourceId mask_resource_id = this->resource_provider_->CreateResource( |
| 1987 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, | 1987 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 1988 gfx::ColorSpace()); | 1988 gfx::ColorSpace()); |
| 1989 { | 1989 |
| 1990 SkAutoLockPixels lock(bitmap); | 1990 this->resource_provider_->CopyToResource( |
| 1991 this->resource_provider_->CopyToResource( | 1991 mask_resource_id, reinterpret_cast<uint8_t*>(bitmap.getPixels()), |
| 1992 mask_resource_id, reinterpret_cast<uint8_t*>(bitmap.getPixels()), | 1992 mask_rect.size()); |
| 1993 mask_rect.size()); | |
| 1994 } | |
| 1995 | 1993 |
| 1996 // This RenderPassDrawQuad does not include the full |viewport_rect| which is | 1994 // This RenderPassDrawQuad does not include the full |viewport_rect| which is |
| 1997 // the size of the child render pass. | 1995 // the size of the child render pass. |
| 1998 gfx::Rect sub_rect = gfx::Rect(50, 50, 200, 100); | 1996 gfx::Rect sub_rect = gfx::Rect(50, 50, 200, 100); |
| 1999 EXPECT_NE(sub_rect.x(), child_pass->output_rect.x()); | 1997 EXPECT_NE(sub_rect.x(), child_pass->output_rect.x()); |
| 2000 EXPECT_NE(sub_rect.y(), child_pass->output_rect.y()); | 1998 EXPECT_NE(sub_rect.y(), child_pass->output_rect.y()); |
| 2001 EXPECT_NE(sub_rect.right(), child_pass->output_rect.right()); | 1999 EXPECT_NE(sub_rect.right(), child_pass->output_rect.right()); |
| 2002 EXPECT_NE(sub_rect.bottom(), child_pass->output_rect.bottom()); | 2000 EXPECT_NE(sub_rect.bottom(), child_pass->output_rect.bottom()); |
| 2003 | 2001 |
| 2004 // Set up a mask on the RenderPassDrawQuad. | 2002 // Set up a mask on the RenderPassDrawQuad. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2074 rect.Inset(6, 6, 4, 4); | 2072 rect.Inset(6, 6, 4, 4); |
| 2075 canvas.drawRect( | 2073 canvas.drawRect( |
| 2076 SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()), | 2074 SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()), |
| 2077 flags); | 2075 flags); |
| 2078 rect.Inset(6, 6, 4, 4); | 2076 rect.Inset(6, 6, 4, 4); |
| 2079 } | 2077 } |
| 2080 | 2078 |
| 2081 ResourceId mask_resource_id = this->resource_provider_->CreateResource( | 2079 ResourceId mask_resource_id = this->resource_provider_->CreateResource( |
| 2082 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, | 2080 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 2083 gfx::ColorSpace()); | 2081 gfx::ColorSpace()); |
| 2084 { | 2082 |
| 2085 SkAutoLockPixels lock(bitmap); | 2083 this->resource_provider_->CopyToResource( |
| 2086 this->resource_provider_->CopyToResource( | 2084 mask_resource_id, reinterpret_cast<uint8_t*>(bitmap.getPixels()), |
| 2087 mask_resource_id, reinterpret_cast<uint8_t*>(bitmap.getPixels()), | 2085 mask_rect.size()); |
| 2088 mask_rect.size()); | |
| 2089 } | |
| 2090 | 2086 |
| 2091 // This RenderPassDrawQuad does not include the full |viewport_rect| which is | 2087 // This RenderPassDrawQuad does not include the full |viewport_rect| which is |
| 2092 // the size of the child render pass. | 2088 // the size of the child render pass. |
| 2093 gfx::Rect sub_rect = gfx::Rect(50, 20, 200, 60); | 2089 gfx::Rect sub_rect = gfx::Rect(50, 20, 200, 60); |
| 2094 EXPECT_NE(sub_rect.x(), child_pass->output_rect.x()); | 2090 EXPECT_NE(sub_rect.x(), child_pass->output_rect.x()); |
| 2095 EXPECT_NE(sub_rect.y(), child_pass->output_rect.y()); | 2091 EXPECT_NE(sub_rect.y(), child_pass->output_rect.y()); |
| 2096 EXPECT_NE(sub_rect.right(), child_pass->output_rect.right()); | 2092 EXPECT_NE(sub_rect.right(), child_pass->output_rect.right()); |
| 2097 EXPECT_NE(sub_rect.bottom(), child_pass->output_rect.bottom()); | 2093 EXPECT_NE(sub_rect.bottom(), child_pass->output_rect.bottom()); |
| 2098 | 2094 |
| 2099 // Set up a mask on the RenderPassDrawQuad. | 2095 // Set up a mask on the RenderPassDrawQuad. |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2802 } | 2798 } |
| 2803 | 2799 |
| 2804 // This disables filtering by setting |nearest_neighbor| on the TileDrawQuad. | 2800 // This disables filtering by setting |nearest_neighbor| on the TileDrawQuad. |
| 2805 TYPED_TEST(RendererPixelTest, TileDrawQuadNearestNeighbor) { | 2801 TYPED_TEST(RendererPixelTest, TileDrawQuadNearestNeighbor) { |
| 2806 gfx::Rect viewport(this->device_viewport_size_); | 2802 gfx::Rect viewport(this->device_viewport_size_); |
| 2807 bool swizzle_contents = true; | 2803 bool swizzle_contents = true; |
| 2808 bool nearest_neighbor = true; | 2804 bool nearest_neighbor = true; |
| 2809 | 2805 |
| 2810 SkBitmap bitmap; | 2806 SkBitmap bitmap; |
| 2811 bitmap.allocN32Pixels(2, 2); | 2807 bitmap.allocN32Pixels(2, 2); |
| 2812 { | 2808 SkCanvas canvas(bitmap); |
| 2813 SkAutoLockPixels lock(bitmap); | 2809 draw_point_color(&canvas, 0, 0, SK_ColorGREEN); |
| 2814 SkCanvas canvas(bitmap); | 2810 draw_point_color(&canvas, 0, 1, SK_ColorBLUE); |
| 2815 draw_point_color(&canvas, 0, 0, SK_ColorGREEN); | 2811 draw_point_color(&canvas, 1, 0, SK_ColorBLUE); |
| 2816 draw_point_color(&canvas, 0, 1, SK_ColorBLUE); | 2812 draw_point_color(&canvas, 1, 1, SK_ColorGREEN); |
| 2817 draw_point_color(&canvas, 1, 0, SK_ColorBLUE); | |
| 2818 draw_point_color(&canvas, 1, 1, SK_ColorGREEN); | |
| 2819 } | |
| 2820 | 2813 |
| 2821 gfx::Size tile_size(2, 2); | 2814 gfx::Size tile_size(2, 2); |
| 2822 ResourceId resource = this->resource_provider_->CreateResource( | 2815 ResourceId resource = this->resource_provider_->CreateResource( |
| 2823 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, | 2816 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 2824 gfx::ColorSpace()); | 2817 gfx::ColorSpace()); |
| 2825 | 2818 |
| 2826 { | 2819 this->resource_provider_->CopyToResource( |
| 2827 SkAutoLockPixels lock(bitmap); | 2820 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); |
| 2828 this->resource_provider_->CopyToResource( | |
| 2829 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); | |
| 2830 } | |
| 2831 | 2821 |
| 2832 int id = 1; | 2822 int id = 1; |
| 2833 gfx::Transform transform_to_root; | 2823 gfx::Transform transform_to_root; |
| 2834 std::unique_ptr<RenderPass> pass = | 2824 std::unique_ptr<RenderPass> pass = |
| 2835 CreateTestRenderPass(id, viewport, transform_to_root); | 2825 CreateTestRenderPass(id, viewport, transform_to_root); |
| 2836 | 2826 |
| 2837 gfx::Transform quad_to_target_transform; | 2827 gfx::Transform quad_to_target_transform; |
| 2838 SharedQuadState* shared_state = | 2828 SharedQuadState* shared_state = |
| 2839 CreateTestSharedQuadState(quad_to_target_transform, viewport, pass.get()); | 2829 CreateTestSharedQuadState(quad_to_target_transform, viewport, pass.get()); |
| 2840 | 2830 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2853 } | 2843 } |
| 2854 | 2844 |
| 2855 // This disables filtering by setting |nearest_neighbor| to true on the | 2845 // This disables filtering by setting |nearest_neighbor| to true on the |
| 2856 // TextureDrawQuad. | 2846 // TextureDrawQuad. |
| 2857 TYPED_TEST(SoftwareRendererPixelTest, TextureDrawQuadNearestNeighbor) { | 2847 TYPED_TEST(SoftwareRendererPixelTest, TextureDrawQuadNearestNeighbor) { |
| 2858 gfx::Rect viewport(this->device_viewport_size_); | 2848 gfx::Rect viewport(this->device_viewport_size_); |
| 2859 bool nearest_neighbor = true; | 2849 bool nearest_neighbor = true; |
| 2860 | 2850 |
| 2861 SkBitmap bitmap; | 2851 SkBitmap bitmap; |
| 2862 bitmap.allocN32Pixels(2, 2); | 2852 bitmap.allocN32Pixels(2, 2); |
| 2863 { | 2853 SkCanvas canvas(bitmap); |
| 2864 SkAutoLockPixels lock(bitmap); | 2854 draw_point_color(&canvas, 0, 0, SK_ColorGREEN); |
| 2865 SkCanvas canvas(bitmap); | 2855 draw_point_color(&canvas, 0, 1, SK_ColorBLUE); |
| 2866 draw_point_color(&canvas, 0, 0, SK_ColorGREEN); | 2856 draw_point_color(&canvas, 1, 0, SK_ColorBLUE); |
| 2867 draw_point_color(&canvas, 0, 1, SK_ColorBLUE); | 2857 draw_point_color(&canvas, 1, 1, SK_ColorGREEN); |
| 2868 draw_point_color(&canvas, 1, 0, SK_ColorBLUE); | |
| 2869 draw_point_color(&canvas, 1, 1, SK_ColorGREEN); | |
| 2870 } | |
| 2871 | 2858 |
| 2872 gfx::Size tile_size(2, 2); | 2859 gfx::Size tile_size(2, 2); |
| 2873 ResourceId resource = this->resource_provider_->CreateResource( | 2860 ResourceId resource = this->resource_provider_->CreateResource( |
| 2874 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, | 2861 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 2875 gfx::ColorSpace()); | 2862 gfx::ColorSpace()); |
| 2876 | 2863 |
| 2877 { | 2864 this->resource_provider_->CopyToResource( |
| 2878 SkAutoLockPixels lock(bitmap); | 2865 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); |
| 2879 this->resource_provider_->CopyToResource( | |
| 2880 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); | |
| 2881 } | |
| 2882 | 2866 |
| 2883 int id = 1; | 2867 int id = 1; |
| 2884 gfx::Transform transform_to_root; | 2868 gfx::Transform transform_to_root; |
| 2885 std::unique_ptr<RenderPass> pass = | 2869 std::unique_ptr<RenderPass> pass = |
| 2886 CreateTestRenderPass(id, viewport, transform_to_root); | 2870 CreateTestRenderPass(id, viewport, transform_to_root); |
| 2887 | 2871 |
| 2888 gfx::Transform quad_to_target_transform; | 2872 gfx::Transform quad_to_target_transform; |
| 2889 SharedQuadState* shared_state = | 2873 SharedQuadState* shared_state = |
| 2890 CreateTestSharedQuadState(quad_to_target_transform, viewport, pass.get()); | 2874 CreateTestSharedQuadState(quad_to_target_transform, viewport, pass.get()); |
| 2891 | 2875 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2906 | 2890 |
| 2907 // This ensures filtering is enabled by setting |nearest_neighbor| to false on | 2891 // This ensures filtering is enabled by setting |nearest_neighbor| to false on |
| 2908 // the TextureDrawQuad. | 2892 // the TextureDrawQuad. |
| 2909 TYPED_TEST(SoftwareRendererPixelTest, TextureDrawQuadLinear) { | 2893 TYPED_TEST(SoftwareRendererPixelTest, TextureDrawQuadLinear) { |
| 2910 gfx::Rect viewport(this->device_viewport_size_); | 2894 gfx::Rect viewport(this->device_viewport_size_); |
| 2911 bool nearest_neighbor = false; | 2895 bool nearest_neighbor = false; |
| 2912 | 2896 |
| 2913 SkBitmap bitmap; | 2897 SkBitmap bitmap; |
| 2914 bitmap.allocN32Pixels(2, 2); | 2898 bitmap.allocN32Pixels(2, 2); |
| 2915 { | 2899 { |
| 2916 SkAutoLockPixels lock(bitmap); | |
| 2917 SkCanvas canvas(bitmap); | 2900 SkCanvas canvas(bitmap); |
| 2918 draw_point_color(&canvas, 0, 0, SK_ColorGREEN); | 2901 draw_point_color(&canvas, 0, 0, SK_ColorGREEN); |
| 2919 draw_point_color(&canvas, 0, 1, SK_ColorBLUE); | 2902 draw_point_color(&canvas, 0, 1, SK_ColorBLUE); |
| 2920 draw_point_color(&canvas, 1, 0, SK_ColorBLUE); | 2903 draw_point_color(&canvas, 1, 0, SK_ColorBLUE); |
| 2921 draw_point_color(&canvas, 1, 1, SK_ColorGREEN); | 2904 draw_point_color(&canvas, 1, 1, SK_ColorGREEN); |
| 2922 } | 2905 } |
| 2923 | 2906 |
| 2924 gfx::Size tile_size(2, 2); | 2907 gfx::Size tile_size(2, 2); |
| 2925 ResourceId resource = this->resource_provider_->CreateResource( | 2908 ResourceId resource = this->resource_provider_->CreateResource( |
| 2926 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, | 2909 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 2927 gfx::ColorSpace()); | 2910 gfx::ColorSpace()); |
| 2928 | 2911 |
| 2929 { | 2912 this->resource_provider_->CopyToResource( |
| 2930 SkAutoLockPixels lock(bitmap); | 2913 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); |
| 2931 this->resource_provider_->CopyToResource( | |
| 2932 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); | |
| 2933 } | |
| 2934 | 2914 |
| 2935 int id = 1; | 2915 int id = 1; |
| 2936 gfx::Transform transform_to_root; | 2916 gfx::Transform transform_to_root; |
| 2937 std::unique_ptr<RenderPass> pass = | 2917 std::unique_ptr<RenderPass> pass = |
| 2938 CreateTestRenderPass(id, viewport, transform_to_root); | 2918 CreateTestRenderPass(id, viewport, transform_to_root); |
| 2939 | 2919 |
| 2940 gfx::Transform quad_to_target_transform; | 2920 gfx::Transform quad_to_target_transform; |
| 2941 SharedQuadState* shared_state = | 2921 SharedQuadState* shared_state = |
| 2942 CreateTestSharedQuadState(quad_to_target_transform, viewport, pass.get()); | 2922 CreateTestSharedQuadState(quad_to_target_transform, viewport, pass.get()); |
| 2943 | 2923 |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3282 inset_rect.Inset(6, 6, 4, 4); | 3262 inset_rect.Inset(6, 6, 4, 4); |
| 3283 canvas.drawRect(SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), | 3263 canvas.drawRect(SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), |
| 3284 inset_rect.width(), inset_rect.height()), | 3264 inset_rect.width(), inset_rect.height()), |
| 3285 paint); | 3265 paint); |
| 3286 inset_rect.Inset(6, 6, 4, 4); | 3266 inset_rect.Inset(6, 6, 4, 4); |
| 3287 } | 3267 } |
| 3288 | 3268 |
| 3289 ResourceId resource = this->resource_provider_->CreateResource( | 3269 ResourceId resource = this->resource_provider_->CreateResource( |
| 3290 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, | 3270 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 3291 gfx::ColorSpace()); | 3271 gfx::ColorSpace()); |
| 3292 { | 3272 |
| 3293 SkAutoLockPixels lock(bitmap); | 3273 this->resource_provider_->CopyToResource( |
| 3294 this->resource_provider_->CopyToResource( | 3274 resource, reinterpret_cast<uint8_t*>(bitmap.getPixels()), |
| 3295 resource, reinterpret_cast<uint8_t*>(bitmap.getPixels()), | 3275 mask_rect.size()); |
| 3296 mask_rect.size()); | |
| 3297 } | |
| 3298 | 3276 |
| 3299 // Arbitrary dividing lengths to divide up the resource into 16 quads. | 3277 // Arbitrary dividing lengths to divide up the resource into 16 quads. |
| 3300 int widths[] = { | 3278 int widths[] = { |
| 3301 0, 60, 50, 40, | 3279 0, 60, 50, 40, |
| 3302 }; | 3280 }; |
| 3303 int heights[] = { | 3281 int heights[] = { |
| 3304 0, 10, 80, 50, | 3282 0, 10, 80, 50, |
| 3305 }; | 3283 }; |
| 3306 size_t num_quads = 4; | 3284 size_t num_quads = 4; |
| 3307 for (size_t i = 0; i < num_quads; ++i) { | 3285 for (size_t i = 0; i < num_quads; ++i) { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3574 INSTANTIATE_TEST_CASE_P( | 3552 INSTANTIATE_TEST_CASE_P( |
| 3575 ToColorSpace, | 3553 ToColorSpace, |
| 3576 ColorTransformPixelTest, | 3554 ColorTransformPixelTest, |
| 3577 testing::Combine(testing::ValuesIn(intermediate_color_spaces), | 3555 testing::Combine(testing::ValuesIn(intermediate_color_spaces), |
| 3578 testing::ValuesIn(dst_color_spaces))); | 3556 testing::ValuesIn(dst_color_spaces))); |
| 3579 | 3557 |
| 3580 #endif // !defined(OS_ANDROID) | 3558 #endif // !defined(OS_ANDROID) |
| 3581 | 3559 |
| 3582 } // namespace | 3560 } // namespace |
| 3583 } // namespace cc | 3561 } // namespace cc |
| OLD | NEW |