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

Side by Side Diff: cc/surfaces/surface_aggregator_unittest.cc

Issue 1968363002: SurfaceAggregator should check whether output is secure when drawin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « cc/surfaces/surface_aggregator_perftest.cc ('k') | cc/test/fake_proxy.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "cc/surfaces/surface_aggregator.h" 5 #include "cc/surfaces/surface_aggregator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 output_surface_ = FakeOutputSurface::CreateSoftware( 1869 output_surface_ = FakeOutputSurface::CreateSoftware(
1870 base::WrapUnique(new SoftwareOutputDevice)); 1870 base::WrapUnique(new SoftwareOutputDevice));
1871 output_surface_->BindToClient(&output_surface_client_); 1871 output_surface_->BindToClient(&output_surface_client_);
1872 shared_bitmap_manager_.reset(new TestSharedBitmapManager); 1872 shared_bitmap_manager_.reset(new TestSharedBitmapManager);
1873 1873
1874 resource_provider_ = FakeResourceProvider::Create( 1874 resource_provider_ = FakeResourceProvider::Create(
1875 output_surface_.get(), shared_bitmap_manager_.get()); 1875 output_surface_.get(), shared_bitmap_manager_.get());
1876 1876
1877 aggregator_.reset( 1877 aggregator_.reset(
1878 new SurfaceAggregator(&manager_, resource_provider_.get(), false)); 1878 new SurfaceAggregator(&manager_, resource_provider_.get(), false));
1879 aggregator_->set_output_is_secure(true);
1879 } 1880 }
1880 1881
1881 protected: 1882 protected:
1882 SurfaceManager manager_; 1883 SurfaceManager manager_;
1883 FakeOutputSurfaceClient output_surface_client_; 1884 FakeOutputSurfaceClient output_surface_client_;
1884 std::unique_ptr<OutputSurface> output_surface_; 1885 std::unique_ptr<OutputSurface> output_surface_;
1885 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; 1886 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_;
1886 std::unique_ptr<ResourceProvider> resource_provider_; 1887 std::unique_ptr<ResourceProvider> resource_provider_;
1887 std::unique_ptr<SurfaceAggregator> aggregator_; 1888 std::unique_ptr<SurfaceAggregator> aggregator_;
1888 }; 1889 };
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 const gfx::Rect opaque_rect; 1938 const gfx::Rect opaque_rect;
1938 const gfx::Rect visible_rect; 1939 const gfx::Rect visible_rect;
1939 bool needs_blending = false; 1940 bool needs_blending = false;
1940 bool premultiplied_alpha = false; 1941 bool premultiplied_alpha = false;
1941 const gfx::PointF uv_top_left; 1942 const gfx::PointF uv_top_left;
1942 const gfx::PointF uv_bottom_right; 1943 const gfx::PointF uv_bottom_right;
1943 SkColor background_color = SK_ColorGREEN; 1944 SkColor background_color = SK_ColorGREEN;
1944 const float vertex_opacity[4] = {0.f, 0.f, 1.f, 1.f}; 1945 const float vertex_opacity[4] = {0.f, 0.f, 1.f, 1.f};
1945 bool flipped = false; 1946 bool flipped = false;
1946 bool nearest_neighbor = false; 1947 bool nearest_neighbor = false;
1948 bool secure_output_only = true;
1947 quad->SetAll(sqs, rect, opaque_rect, visible_rect, needs_blending, 1949 quad->SetAll(sqs, rect, opaque_rect, visible_rect, needs_blending,
1948 resource_ids[i], gfx::Size(), premultiplied_alpha, uv_top_left, 1950 resource_ids[i], gfx::Size(), premultiplied_alpha, uv_top_left,
1949 uv_bottom_right, background_color, vertex_opacity, flipped, 1951 uv_bottom_right, background_color, vertex_opacity, flipped,
1950 nearest_neighbor); 1952 nearest_neighbor, secure_output_only);
1951 } 1953 }
1952 frame_data->render_pass_list.push_back(std::move(pass)); 1954 frame_data->render_pass_list.push_back(std::move(pass));
1953 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); 1955 std::unique_ptr<CompositorFrame> frame(new CompositorFrame);
1954 frame->delegated_frame_data = std::move(frame_data); 1956 frame->delegated_frame_data = std::move(frame_data);
1955 factory->SubmitCompositorFrame(surface_id, std::move(frame), 1957 factory->SubmitCompositorFrame(surface_id, std::move(frame),
1956 SurfaceFactory::DrawCallback()); 1958 SurfaceFactory::DrawCallback());
1957 } 1959 }
1958 1960
1959 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { 1961 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) {
1960 ResourceTrackingSurfaceFactoryClient client; 1962 ResourceTrackingSurfaceFactoryClient client;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 pass_list = &frame->delegated_frame_data->render_pass_list; 2105 pass_list = &frame->delegated_frame_data->render_pass_list;
2104 ASSERT_EQ(1u, pass_list->size()); 2106 ASSERT_EQ(1u, pass_list->size());
2105 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); 2107 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size());
2106 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); 2108 EXPECT_EQ(9u, pass_list->back()->quad_list.size());
2107 2109
2108 factory.Destroy(root_surface_id); 2110 factory.Destroy(root_surface_id);
2109 factory.Destroy(child_surface_id); 2111 factory.Destroy(child_surface_id);
2110 factory.Destroy(middle_surface_id); 2112 factory.Destroy(middle_surface_id);
2111 } 2113 }
2112 2114
2115 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) {
2116 ResourceTrackingSurfaceFactoryClient client;
2117 SurfaceFactory factory(&manager_, &client);
2118 SurfaceId surface1_id(7u);
2119 factory.Create(surface1_id);
2120
2121 SurfaceId surface2_id(8u);
2122 factory.Create(surface2_id);
2123
2124 ResourceId ids[] = {11, 12, 13};
2125 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
2126 &factory, surface1_id);
2127
2128 std::unique_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface1_id);
2129
2130 RenderPass* render_pass =
2131 frame->delegated_frame_data->render_pass_list.back().get();
2132
2133 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material);
2134
2135 {
2136 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
2137 std::unique_ptr<RenderPass> pass = RenderPass::Create();
2138 pass->id = RenderPassId(1, 1);
2139 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
2140 sqs->opacity = 1.f;
2141 SurfaceDrawQuad* surface_quad =
2142 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
2143 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1),
2144 surface1_id);
2145 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest());
2146
2147 frame_data->render_pass_list.push_back(std::move(pass));
2148 std::unique_ptr<CompositorFrame> frame(new CompositorFrame);
2149 frame->delegated_frame_data = std::move(frame_data);
2150 factory.SubmitCompositorFrame(surface2_id, std::move(frame),
2151 SurfaceFactory::DrawCallback());
2152 }
2153
2154 frame = aggregator_->Aggregate(surface2_id);
2155 EXPECT_EQ(1u, frame->delegated_frame_data->render_pass_list.size());
2156 render_pass = frame->delegated_frame_data->render_pass_list.front().get();
2157
2158 // Parent has copy request, so texture should not be drawn.
2159 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material);
2160
2161 frame = aggregator_->Aggregate(surface2_id);
2162 EXPECT_EQ(1u, frame->delegated_frame_data->render_pass_list.size());
2163 render_pass = frame->delegated_frame_data->render_pass_list.front().get();
2164
2165 // Copy request has been executed earlier, so texture should be drawn.
2166 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT,
2167 render_pass->quad_list.front()->material);
2168
2169 aggregator_->set_output_is_secure(false);
2170
2171 frame = aggregator_->Aggregate(surface2_id);
2172 render_pass = frame->delegated_frame_data->render_pass_list.back().get();
2173
2174 // Output is insecure, so texture should be drawn.
2175 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material);
2176
2177 factory.Destroy(surface1_id);
2178 factory.Destroy(surface2_id);
2179 }
2180
2113 } // namespace 2181 } // namespace
2114 } // namespace cc 2182 } // namespace cc
2115 2183
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator_perftest.cc ('k') | cc/test/fake_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698