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 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2634 template<> | 2634 template<> |
2635 bool IsSoftwareRenderer<SoftwareRenderer>() { | 2635 bool IsSoftwareRenderer<SoftwareRenderer>() { |
2636 return true; | 2636 return true; |
2637 } | 2637 } |
2638 | 2638 |
2639 template<> | 2639 template<> |
2640 bool IsSoftwareRenderer<SoftwareRendererWithExpandedViewport>() { | 2640 bool IsSoftwareRenderer<SoftwareRendererWithExpandedViewport>() { |
2641 return true; | 2641 return true; |
2642 } | 2642 } |
2643 | 2643 |
| 2644 void draw_point_color(SkCanvas* canvas, SkScalar x, SkScalar y, SkColor color) { |
| 2645 SkPaint paint; |
| 2646 paint.setColor(color); |
| 2647 canvas->drawPoint(x, y, paint); |
| 2648 } |
| 2649 |
2644 // If we disable image filtering, then a 2x2 bitmap should appear as four | 2650 // If we disable image filtering, then a 2x2 bitmap should appear as four |
2645 // huge sharp squares. | 2651 // huge sharp squares. |
2646 TYPED_TEST(SoftwareRendererPixelTest, PictureDrawQuadDisableImageFiltering) { | 2652 TYPED_TEST(SoftwareRendererPixelTest, PictureDrawQuadDisableImageFiltering) { |
2647 // We only care about this in software mode since bilinear filtering is | 2653 // We only care about this in software mode since bilinear filtering is |
2648 // cheap in hardware. | 2654 // cheap in hardware. |
2649 if (!IsSoftwareRenderer<TypeParam>()) | 2655 if (!IsSoftwareRenderer<TypeParam>()) |
2650 return; | 2656 return; |
2651 | 2657 |
2652 gfx::Rect viewport(this->device_viewport_size_); | 2658 gfx::Rect viewport(this->device_viewport_size_); |
2653 ResourceFormat texture_format = RGBA_8888; | 2659 ResourceFormat texture_format = RGBA_8888; |
2654 bool nearest_neighbor = false; | 2660 bool nearest_neighbor = false; |
2655 | 2661 |
2656 int id = 1; | 2662 int id = 1; |
2657 gfx::Transform transform_to_root; | 2663 gfx::Transform transform_to_root; |
2658 std::unique_ptr<RenderPass> pass = | 2664 std::unique_ptr<RenderPass> pass = |
2659 CreateTestRenderPass(id, viewport, transform_to_root); | 2665 CreateTestRenderPass(id, viewport, transform_to_root); |
2660 | 2666 |
2661 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(2, 2); | 2667 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(2, 2); |
2662 ASSERT_NE(surface, nullptr); | 2668 ASSERT_NE(surface, nullptr); |
2663 SkCanvas* canvas = surface->getCanvas(); | 2669 SkCanvas* canvas = surface->getCanvas(); |
2664 canvas->drawPoint(0, 0, SK_ColorGREEN); | 2670 draw_point_color(canvas, 0, 0, SK_ColorGREEN); |
2665 canvas->drawPoint(0, 1, SK_ColorBLUE); | 2671 draw_point_color(canvas, 0, 1, SK_ColorBLUE); |
2666 canvas->drawPoint(1, 0, SK_ColorBLUE); | 2672 draw_point_color(canvas, 1, 0, SK_ColorBLUE); |
2667 canvas->drawPoint(1, 1, SK_ColorGREEN); | 2673 draw_point_color(canvas, 1, 1, SK_ColorGREEN); |
2668 | 2674 |
2669 std::unique_ptr<FakeRecordingSource> recording = | 2675 std::unique_ptr<FakeRecordingSource> recording = |
2670 FakeRecordingSource::CreateFilledRecordingSource(viewport.size()); | 2676 FakeRecordingSource::CreateFilledRecordingSource(viewport.size()); |
2671 PaintFlags flags; | 2677 PaintFlags flags; |
2672 flags.setFilterQuality(kLow_SkFilterQuality); | 2678 flags.setFilterQuality(kLow_SkFilterQuality); |
2673 recording->add_draw_image_with_flags(surface->makeImageSnapshot(), | 2679 recording->add_draw_image_with_flags(surface->makeImageSnapshot(), |
2674 gfx::Point(), flags); | 2680 gfx::Point(), flags); |
2675 recording->Rerecord(); | 2681 recording->Rerecord(); |
2676 scoped_refptr<FakeRasterSource> raster_source = | 2682 scoped_refptr<FakeRasterSource> raster_source = |
2677 FakeRasterSource::CreateFromRecordingSource(recording.get(), false); | 2683 FakeRasterSource::CreateFromRecordingSource(recording.get(), false); |
(...skipping 25 matching lines...) Expand all Loading... |
2703 bool nearest_neighbor = true; | 2709 bool nearest_neighbor = true; |
2704 | 2710 |
2705 int id = 1; | 2711 int id = 1; |
2706 gfx::Transform transform_to_root; | 2712 gfx::Transform transform_to_root; |
2707 std::unique_ptr<RenderPass> pass = | 2713 std::unique_ptr<RenderPass> pass = |
2708 CreateTestRenderPass(id, viewport, transform_to_root); | 2714 CreateTestRenderPass(id, viewport, transform_to_root); |
2709 | 2715 |
2710 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(2, 2); | 2716 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(2, 2); |
2711 ASSERT_NE(surface, nullptr); | 2717 ASSERT_NE(surface, nullptr); |
2712 SkCanvas* canvas = surface->getCanvas(); | 2718 SkCanvas* canvas = surface->getCanvas(); |
2713 canvas->drawPoint(0, 0, SK_ColorGREEN); | 2719 draw_point_color(canvas, 0, 0, SK_ColorGREEN); |
2714 canvas->drawPoint(0, 1, SK_ColorBLUE); | 2720 draw_point_color(canvas, 0, 1, SK_ColorBLUE); |
2715 canvas->drawPoint(1, 0, SK_ColorBLUE); | 2721 draw_point_color(canvas, 1, 0, SK_ColorBLUE); |
2716 canvas->drawPoint(1, 1, SK_ColorGREEN); | 2722 draw_point_color(canvas, 1, 1, SK_ColorGREEN); |
2717 | 2723 |
2718 std::unique_ptr<FakeRecordingSource> recording = | 2724 std::unique_ptr<FakeRecordingSource> recording = |
2719 FakeRecordingSource::CreateFilledRecordingSource(viewport.size()); | 2725 FakeRecordingSource::CreateFilledRecordingSource(viewport.size()); |
2720 PaintFlags flags; | 2726 PaintFlags flags; |
2721 flags.setFilterQuality(kLow_SkFilterQuality); | 2727 flags.setFilterQuality(kLow_SkFilterQuality); |
2722 recording->add_draw_image_with_flags(surface->makeImageSnapshot(), | 2728 recording->add_draw_image_with_flags(surface->makeImageSnapshot(), |
2723 gfx::Point(), flags); | 2729 gfx::Point(), flags); |
2724 recording->Rerecord(); | 2730 recording->Rerecord(); |
2725 scoped_refptr<FakeRasterSource> raster_source = | 2731 scoped_refptr<FakeRasterSource> raster_source = |
2726 FakeRasterSource::CreateFromRecordingSource(recording.get(), false); | 2732 FakeRasterSource::CreateFromRecordingSource(recording.get(), false); |
(...skipping 20 matching lines...) Expand all Loading... |
2747 TYPED_TEST(RendererPixelTest, TileDrawQuadNearestNeighbor) { | 2753 TYPED_TEST(RendererPixelTest, TileDrawQuadNearestNeighbor) { |
2748 gfx::Rect viewport(this->device_viewport_size_); | 2754 gfx::Rect viewport(this->device_viewport_size_); |
2749 bool swizzle_contents = true; | 2755 bool swizzle_contents = true; |
2750 bool nearest_neighbor = true; | 2756 bool nearest_neighbor = true; |
2751 | 2757 |
2752 SkBitmap bitmap; | 2758 SkBitmap bitmap; |
2753 bitmap.allocN32Pixels(2, 2); | 2759 bitmap.allocN32Pixels(2, 2); |
2754 { | 2760 { |
2755 SkAutoLockPixels lock(bitmap); | 2761 SkAutoLockPixels lock(bitmap); |
2756 SkCanvas canvas(bitmap); | 2762 SkCanvas canvas(bitmap); |
2757 canvas.drawPoint(0, 0, SK_ColorGREEN); | 2763 draw_point_color(&canvas, 0, 0, SK_ColorGREEN); |
2758 canvas.drawPoint(0, 1, SK_ColorBLUE); | 2764 draw_point_color(&canvas, 0, 1, SK_ColorBLUE); |
2759 canvas.drawPoint(1, 0, SK_ColorBLUE); | 2765 draw_point_color(&canvas, 1, 0, SK_ColorBLUE); |
2760 canvas.drawPoint(1, 1, SK_ColorGREEN); | 2766 draw_point_color(&canvas, 1, 1, SK_ColorGREEN); |
2761 } | 2767 } |
2762 | 2768 |
2763 gfx::Size tile_size(2, 2); | 2769 gfx::Size tile_size(2, 2); |
2764 ResourceId resource = this->resource_provider_->CreateResource( | 2770 ResourceId resource = this->resource_provider_->CreateResource( |
2765 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, | 2771 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
2766 gfx::ColorSpace()); | 2772 gfx::ColorSpace()); |
2767 | 2773 |
2768 { | 2774 { |
2769 SkAutoLockPixels lock(bitmap); | 2775 SkAutoLockPixels lock(bitmap); |
2770 this->resource_provider_->CopyToResource( | 2776 this->resource_provider_->CopyToResource( |
(...skipping 27 matching lines...) Expand all Loading... |
2798 // TextureDrawQuad. | 2804 // TextureDrawQuad. |
2799 TYPED_TEST(SoftwareRendererPixelTest, TextureDrawQuadNearestNeighbor) { | 2805 TYPED_TEST(SoftwareRendererPixelTest, TextureDrawQuadNearestNeighbor) { |
2800 gfx::Rect viewport(this->device_viewport_size_); | 2806 gfx::Rect viewport(this->device_viewport_size_); |
2801 bool nearest_neighbor = true; | 2807 bool nearest_neighbor = true; |
2802 | 2808 |
2803 SkBitmap bitmap; | 2809 SkBitmap bitmap; |
2804 bitmap.allocN32Pixels(2, 2); | 2810 bitmap.allocN32Pixels(2, 2); |
2805 { | 2811 { |
2806 SkAutoLockPixels lock(bitmap); | 2812 SkAutoLockPixels lock(bitmap); |
2807 SkCanvas canvas(bitmap); | 2813 SkCanvas canvas(bitmap); |
2808 canvas.drawPoint(0, 0, SK_ColorGREEN); | 2814 draw_point_color(&canvas, 0, 0, SK_ColorGREEN); |
2809 canvas.drawPoint(0, 1, SK_ColorBLUE); | 2815 draw_point_color(&canvas, 0, 1, SK_ColorBLUE); |
2810 canvas.drawPoint(1, 0, SK_ColorBLUE); | 2816 draw_point_color(&canvas, 1, 0, SK_ColorBLUE); |
2811 canvas.drawPoint(1, 1, SK_ColorGREEN); | 2817 draw_point_color(&canvas, 1, 1, SK_ColorGREEN); |
2812 } | 2818 } |
2813 | 2819 |
2814 gfx::Size tile_size(2, 2); | 2820 gfx::Size tile_size(2, 2); |
2815 ResourceId resource = this->resource_provider_->CreateResource( | 2821 ResourceId resource = this->resource_provider_->CreateResource( |
2816 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, | 2822 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
2817 gfx::ColorSpace()); | 2823 gfx::ColorSpace()); |
2818 | 2824 |
2819 { | 2825 { |
2820 SkAutoLockPixels lock(bitmap); | 2826 SkAutoLockPixels lock(bitmap); |
2821 this->resource_provider_->CopyToResource( | 2827 this->resource_provider_->CopyToResource( |
(...skipping 28 matching lines...) Expand all Loading... |
2850 // the TextureDrawQuad. | 2856 // the TextureDrawQuad. |
2851 TYPED_TEST(SoftwareRendererPixelTest, TextureDrawQuadLinear) { | 2857 TYPED_TEST(SoftwareRendererPixelTest, TextureDrawQuadLinear) { |
2852 gfx::Rect viewport(this->device_viewport_size_); | 2858 gfx::Rect viewport(this->device_viewport_size_); |
2853 bool nearest_neighbor = false; | 2859 bool nearest_neighbor = false; |
2854 | 2860 |
2855 SkBitmap bitmap; | 2861 SkBitmap bitmap; |
2856 bitmap.allocN32Pixels(2, 2); | 2862 bitmap.allocN32Pixels(2, 2); |
2857 { | 2863 { |
2858 SkAutoLockPixels lock(bitmap); | 2864 SkAutoLockPixels lock(bitmap); |
2859 SkCanvas canvas(bitmap); | 2865 SkCanvas canvas(bitmap); |
2860 canvas.drawPoint(0, 0, SK_ColorGREEN); | 2866 draw_point_color(&canvas, 0, 0, SK_ColorGREEN); |
2861 canvas.drawPoint(0, 1, SK_ColorBLUE); | 2867 draw_point_color(&canvas, 0, 1, SK_ColorBLUE); |
2862 canvas.drawPoint(1, 0, SK_ColorBLUE); | 2868 draw_point_color(&canvas, 1, 0, SK_ColorBLUE); |
2863 canvas.drawPoint(1, 1, SK_ColorGREEN); | 2869 draw_point_color(&canvas, 1, 1, SK_ColorGREEN); |
2864 } | 2870 } |
2865 | 2871 |
2866 gfx::Size tile_size(2, 2); | 2872 gfx::Size tile_size(2, 2); |
2867 ResourceId resource = this->resource_provider_->CreateResource( | 2873 ResourceId resource = this->resource_provider_->CreateResource( |
2868 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, | 2874 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
2869 gfx::ColorSpace()); | 2875 gfx::ColorSpace()); |
2870 | 2876 |
2871 { | 2877 { |
2872 SkAutoLockPixels lock(bitmap); | 2878 SkAutoLockPixels lock(bitmap); |
2873 this->resource_provider_->CopyToResource( | 2879 this->resource_provider_->CopyToResource( |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3327 | 3333 |
3328 EXPECT_TRUE(this->RunPixelTest(&pass_list, base::FilePath(FILE_PATH_LITERAL( | 3334 EXPECT_TRUE(this->RunPixelTest(&pass_list, base::FilePath(FILE_PATH_LITERAL( |
3329 "translucent_rectangles.png")), | 3335 "translucent_rectangles.png")), |
3330 ExactPixelComparator(true))); | 3336 ExactPixelComparator(true))); |
3331 } | 3337 } |
3332 | 3338 |
3333 #endif // !defined(OS_ANDROID) | 3339 #endif // !defined(OS_ANDROID) |
3334 | 3340 |
3335 } // namespace | 3341 } // namespace |
3336 } // namespace cc | 3342 } // namespace cc |
OLD | NEW |