Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: cc/output/renderer_pixeltest.cc

Issue 1643653002: cc: make partially-resident textures use 1 - y, not h - y. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More plausible mask fix; new test Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/test/data/mask_middle.png » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "cc/output/gl_renderer.h" 9 #include "cc/output/gl_renderer.h"
10 #include "cc/quads/draw_quad.h" 10 #include "cc/quads/draw_quad.h"
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 RenderPassList pass_list; 1726 RenderPassList pass_list;
1727 pass_list.push_back(std::move(child_pass)); 1727 pass_list.push_back(std::move(child_pass));
1728 pass_list.push_back(std::move(root_pass)); 1728 pass_list.push_back(std::move(root_pass));
1729 1729
1730 EXPECT_TRUE(this->RunPixelTest( 1730 EXPECT_TRUE(this->RunPixelTest(
1731 &pass_list, 1731 &pass_list,
1732 base::FilePath(FILE_PATH_LITERAL("mask_bottom_right.png")), 1732 base::FilePath(FILE_PATH_LITERAL("mask_bottom_right.png")),
1733 ExactPixelComparator(true))); 1733 ExactPixelComparator(true)));
1734 } 1734 }
1735 1735
1736 // This tests the case where we have a RenderPass with a mask, but the quad
1737 // for the masked surface does not include the full surface texture.
1738 TYPED_TEST(RendererPixelTest, RenderPassAndMaskWithPartialQuad2) {
1739 gfx::Rect viewport_rect(this->device_viewport_size_);
1740
1741 RenderPassId root_pass_id(1, 1);
1742 scoped_ptr<RenderPass> root_pass =
1743 CreateTestRootRenderPass(root_pass_id, viewport_rect);
1744 SharedQuadState* root_pass_shared_state = CreateTestSharedQuadState(
1745 gfx::Transform(), viewport_rect, root_pass.get());
1746
1747 RenderPassId child_pass_id(2, 2);
1748 gfx::Transform transform_to_root;
1749 scoped_ptr<RenderPass> child_pass =
1750 CreateTestRenderPass(child_pass_id, viewport_rect, transform_to_root);
1751 SharedQuadState* child_pass_shared_state = CreateTestSharedQuadState(
1752 gfx::Transform(), viewport_rect, child_pass.get());
1753
1754 // The child render pass is just a green box.
1755 static const SkColor kCSSGreen = 0xff008000;
1756 SolidColorDrawQuad* green =
1757 child_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
1758 green->SetNew(child_pass_shared_state, viewport_rect, viewport_rect,
1759 kCSSGreen, false);
1760
1761 // Make a mask.
1762 gfx::Rect mask_rect = viewport_rect;
1763 SkBitmap bitmap;
1764 bitmap.allocPixels(
1765 SkImageInfo::MakeN32Premul(mask_rect.width(), mask_rect.height()));
1766 SkCanvas canvas(bitmap);
1767 SkPaint paint;
1768 paint.setStyle(SkPaint::kStroke_Style);
1769 paint.setStrokeWidth(SkIntToScalar(4));
1770 paint.setColor(SK_ColorWHITE);
1771 canvas.clear(SK_ColorTRANSPARENT);
1772 gfx::Rect rect = mask_rect;
1773 while (!rect.IsEmpty()) {
1774 rect.Inset(6, 6, 4, 4);
1775 canvas.drawRect(
1776 SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()),
1777 paint);
1778 rect.Inset(6, 6, 4, 4);
1779 }
1780
1781 ResourceId mask_resource_id = this->resource_provider_->CreateResource(
1782 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888);
1783 {
1784 SkAutoLockPixels lock(bitmap);
1785 this->resource_provider_->CopyToResource(
1786 mask_resource_id, reinterpret_cast<uint8_t*>(bitmap.getPixels()),
1787 mask_rect.size());
1788 }
1789
1790 // This RenderPassDrawQuad does not include the full |viewport_rect| which is
1791 // the size of the child render pass.
1792 gfx::Rect sub_rect = gfx::Rect(50, 20, 200, 60);
1793 EXPECT_NE(sub_rect.x(), child_pass->output_rect.x());
1794 EXPECT_NE(sub_rect.y(), child_pass->output_rect.y());
1795 EXPECT_NE(sub_rect.right(), child_pass->output_rect.right());
1796 EXPECT_NE(sub_rect.bottom(), child_pass->output_rect.bottom());
1797
1798 // Set up a mask on the RenderPassDrawQuad.
1799 RenderPassDrawQuad* mask_quad =
1800 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
1801 mask_quad->SetNew(root_pass_shared_state, sub_rect, sub_rect, child_pass_id,
1802 mask_resource_id,
1803 gfx::Vector2dF(2.f / mask_rect.width(),
1804 2.f / mask_rect.height()), // mask_uv_scale
1805 gfx::Size(mask_rect.size()), // mask_texture_size
1806 FilterOperations(), // foreground filters
1807 gfx::Vector2dF(), // filters scale
1808 FilterOperations()); // background filters
1809
1810 // White background behind the masked render pass.
1811 SolidColorDrawQuad* white =
1812 root_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
1813 white->SetNew(root_pass_shared_state, viewport_rect, viewport_rect,
1814 SK_ColorWHITE, false);
1815
1816 RenderPassList pass_list;
1817 pass_list.push_back(std::move(child_pass));
1818 pass_list.push_back(std::move(root_pass));
1819
1820 EXPECT_TRUE(this->RunPixelTest(
1821 &pass_list, base::FilePath(FILE_PATH_LITERAL("mask_middle.png")),
1822 ExactPixelComparator(true)));
1823 }
1824
1736 template <typename RendererType> 1825 template <typename RendererType>
1737 class RendererPixelTestWithBackgroundFilter 1826 class RendererPixelTestWithBackgroundFilter
1738 : public RendererPixelTest<RendererType> { 1827 : public RendererPixelTest<RendererType> {
1739 protected: 1828 protected:
1740 void SetUpRenderPassList() { 1829 void SetUpRenderPassList() {
1741 gfx::Rect device_viewport_rect(this->device_viewport_size_); 1830 gfx::Rect device_viewport_rect(this->device_viewport_size_);
1742 1831
1743 RenderPassId root_id(1, 1); 1832 RenderPassId root_id(1, 1);
1744 scoped_ptr<RenderPass> root_pass = 1833 scoped_ptr<RenderPass> root_pass =
1745 CreateTestRootRenderPass(root_id, device_viewport_rect); 1834 CreateTestRootRenderPass(root_id, device_viewport_rect);
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2973 3062
2974 EXPECT_TRUE(this->RunPixelTest( 3063 EXPECT_TRUE(this->RunPixelTest(
2975 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), 3064 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")),
2976 FuzzyPixelOffByOneComparator(true))); 3065 FuzzyPixelOffByOneComparator(true)));
2977 } 3066 }
2978 3067
2979 #endif // !defined(OS_ANDROID) 3068 #endif // !defined(OS_ANDROID)
2980 3069
2981 } // namespace 3070 } // namespace
2982 } // namespace cc 3071 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/test/data/mask_middle.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698