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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp

Issue 2833883003: Skip paint chunks with effectively invisible opacity. (Closed)
Patch Set: Tweak comment. Created 3 years, 7 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
OLDNEW
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 4
5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/test/test_simple_task_runner.h" 9 #include "base/test/test_simple_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return paint_artifact_compositor_->GetExtraDataForTesting() 136 return paint_artifact_compositor_->GetExtraDataForTesting()
137 ->content_layers.size(); 137 ->content_layers.size();
138 } 138 }
139 139
140 cc::Layer* ContentLayerAt(unsigned index) { 140 cc::Layer* ContentLayerAt(unsigned index) {
141 return paint_artifact_compositor_->GetExtraDataForTesting() 141 return paint_artifact_compositor_->GetExtraDataForTesting()
142 ->content_layers[index] 142 ->content_layers[index]
143 .get(); 143 .get();
144 } 144 }
145 145
146 void AddSimpleRectChunk(TestPaintArtifact& artifact) {
147 artifact
148 .Chunk(TransformPaintPropertyNode::Root(),
149 ClipPaintPropertyNode::Root(), EffectPaintPropertyNode::Root())
150 .RectDrawing(FloatRect(100, 100, 200, 100), Color::kBlack);
151 }
152
153 void CreateSimpleArtifactWithOpacity(TestPaintArtifact& artifact,
154 float opacity,
155 bool include_preceding_chunk,
156 bool include_subsequent_chunk) {
157 if (include_preceding_chunk)
158 AddSimpleRectChunk(artifact);
159 RefPtr<EffectPaintPropertyNode> effect =
160 CreateOpacityOnlyEffect(EffectPaintPropertyNode::Root(), opacity);
161 artifact
162 .Chunk(TransformPaintPropertyNode::Root(),
163 ClipPaintPropertyNode::Root(), effect)
164 .RectDrawing(FloatRect(0, 0, 100, 100), Color::kBlack);
165 if (include_subsequent_chunk)
166 AddSimpleRectChunk(artifact);
167 Update(artifact.Build());
168 }
169
146 private: 170 private:
147 std::unique_ptr<PaintArtifactCompositor> paint_artifact_compositor_; 171 std::unique_ptr<PaintArtifactCompositor> paint_artifact_compositor_;
148 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 172 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
149 base::ThreadTaskRunnerHandle task_runner_handle_; 173 base::ThreadTaskRunnerHandle task_runner_handle_;
150 std::unique_ptr<WebLayerTreeViewWithCompositorFrameSink> web_layer_tree_view_; 174 std::unique_ptr<WebLayerTreeViewWithCompositorFrameSink> web_layer_tree_view_;
151 }; 175 };
152 176
153 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) { 177 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) {
154 PaintArtifact empty_artifact; 178 PaintArtifact empty_artifact;
155 Update(empty_artifact); 179 Update(empty_artifact);
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 CompositorElementIdSet composited_element_ids; 2092 CompositorElementIdSet composited_element_ids;
2069 Update(artifact.Build(), composited_element_ids); 2093 Update(artifact.Build(), composited_element_ids);
2070 2094
2071 EXPECT_EQ(2u, composited_element_ids.size()); 2095 EXPECT_EQ(2u, composited_element_ids.size());
2072 EXPECT_TRUE( 2096 EXPECT_TRUE(
2073 composited_element_ids.Contains(transform->GetCompositorElementId())); 2097 composited_element_ids.Contains(transform->GetCompositorElementId()));
2074 EXPECT_TRUE( 2098 EXPECT_TRUE(
2075 composited_element_ids.Contains(effect->GetCompositorElementId())); 2099 composited_element_ids.Contains(effect->GetCompositorElementId()));
2076 } 2100 }
2077 2101
2102 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SkipChunkWithOpacityZero) {
2103 {
2104 TestPaintArtifact artifact;
2105 CreateSimpleArtifactWithOpacity(artifact, 0, false, false);
2106 ASSERT_EQ(0u, ContentLayerCount());
2107 }
2108 {
2109 TestPaintArtifact artifact;
2110 CreateSimpleArtifactWithOpacity(artifact, 0, true, false);
2111 ASSERT_EQ(1u, ContentLayerCount());
2112 }
2113 {
2114 TestPaintArtifact artifact;
2115 CreateSimpleArtifactWithOpacity(artifact, 0, true, true);
2116 ASSERT_EQ(1u, ContentLayerCount());
2117 }
2118 {
2119 TestPaintArtifact artifact;
2120 CreateSimpleArtifactWithOpacity(artifact, 0, false, true);
2121 ASSERT_EQ(1u, ContentLayerCount());
2122 }
2123 }
2124
2125 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SkipChunkWithTinyOpacity) {
2126 {
2127 TestPaintArtifact artifact;
2128 CreateSimpleArtifactWithOpacity(artifact, 0.0003f, false, false);
2129 ASSERT_EQ(0u, ContentLayerCount());
2130 }
2131 {
2132 TestPaintArtifact artifact;
2133 CreateSimpleArtifactWithOpacity(artifact, 0.0003f, true, false);
2134 ASSERT_EQ(1u, ContentLayerCount());
2135 }
2136 {
2137 TestPaintArtifact artifact;
2138 CreateSimpleArtifactWithOpacity(artifact, 0.0003f, true, true);
2139 ASSERT_EQ(1u, ContentLayerCount());
2140 }
2141 {
2142 TestPaintArtifact artifact;
2143 CreateSimpleArtifactWithOpacity(artifact, 0.0003f, false, true);
2144 ASSERT_EQ(1u, ContentLayerCount());
2145 }
2146 }
2147
2148 TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
2149 DontSkipChunkWithMinimumOpacity) {
2150 {
2151 TestPaintArtifact artifact;
2152 CreateSimpleArtifactWithOpacity(artifact, 0.0004f, false, false);
2153 ASSERT_EQ(1u, ContentLayerCount());
2154 }
2155 {
2156 TestPaintArtifact artifact;
2157 CreateSimpleArtifactWithOpacity(artifact, 0.0004f, true, false);
2158 ASSERT_EQ(1u, ContentLayerCount());
2159 }
2160 {
2161 TestPaintArtifact artifact;
2162 CreateSimpleArtifactWithOpacity(artifact, 0.0004f, true, true);
2163 ASSERT_EQ(1u, ContentLayerCount());
2164 }
2165 {
2166 TestPaintArtifact artifact;
2167 CreateSimpleArtifactWithOpacity(artifact, 0.0004f, false, true);
2168 ASSERT_EQ(1u, ContentLayerCount());
2169 }
2170 }
2171
2172 TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
2173 DontSkipChunkWithAboveMinimumOpacity) {
2174 {
2175 TestPaintArtifact artifact;
2176 CreateSimpleArtifactWithOpacity(artifact, 0.3f, false, false);
2177 ASSERT_EQ(1u, ContentLayerCount());
2178 }
2179 {
2180 TestPaintArtifact artifact;
2181 CreateSimpleArtifactWithOpacity(artifact, 0.3f, true, false);
2182 ASSERT_EQ(1u, ContentLayerCount());
2183 }
2184 {
2185 TestPaintArtifact artifact;
2186 CreateSimpleArtifactWithOpacity(artifact, 0.3f, true, true);
2187 ASSERT_EQ(1u, ContentLayerCount());
2188 }
2189 {
2190 TestPaintArtifact artifact;
2191 CreateSimpleArtifactWithOpacity(artifact, 0.3f, false, true);
2192 ASSERT_EQ(1u, ContentLayerCount());
2193 }
2194 }
2195
2078 } // namespace blink 2196 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698