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

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

Issue 1427543002: Modified old wait sync point functions to also accept new sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Folded sync_point into sync_tokens Created 5 years, 1 month 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 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 "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 renderer.SetVisible(false); 922 renderer.SetVisible(false);
923 EXPECT_TRUE(context->last_call_was_set_visibility()); 923 EXPECT_TRUE(context->last_call_was_set_visibility());
924 } 924 }
925 925
926 class TextureStateTrackingContext : public TestWebGraphicsContext3D { 926 class TextureStateTrackingContext : public TestWebGraphicsContext3D {
927 public: 927 public:
928 TextureStateTrackingContext() : active_texture_(GL_INVALID_ENUM) { 928 TextureStateTrackingContext() : active_texture_(GL_INVALID_ENUM) {
929 test_capabilities_.gpu.egl_image_external = true; 929 test_capabilities_.gpu.egl_image_external = true;
930 } 930 }
931 931
932 MOCK_METHOD1(waitSyncPoint, void(unsigned sync_point)); 932 MOCK_METHOD1(waitSyncToken, void(const GLbyte* sync_token));
933 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); 933 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param));
934 MOCK_METHOD4(drawElements, 934 MOCK_METHOD4(drawElements,
935 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); 935 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset));
936 936
937 virtual void activeTexture(GLenum texture) { 937 virtual void activeTexture(GLenum texture) {
938 EXPECT_NE(texture, active_texture_); 938 EXPECT_NE(texture, active_texture_);
939 active_texture_ = texture; 939 active_texture_ = texture;
940 } 940 }
941 941
942 GLenum active_texture() const { return active_texture_; } 942 GLenum active_texture() const { return active_texture_; }
(...skipping 23 matching lines...) Expand all
966 &settings, 966 &settings,
967 output_surface.get(), 967 output_surface.get(),
968 resource_provider.get()); 968 resource_provider.get());
969 969
970 // During initialization we are allowed to set any texture parameters. 970 // During initialization we are allowed to set any texture parameters.
971 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); 971 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber());
972 972
973 RenderPass* root_pass = 973 RenderPass* root_pass =
974 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 1), 974 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 1),
975 gfx::Rect(100, 100), gfx::Transform()); 975 gfx::Rect(100, 100), gfx::Transform());
976 uint32_t mailbox_sync_point; 976 unsigned mailbox_sync_point;
977 AddOneOfEveryQuadType(root_pass, resource_provider.get(), RenderPassId(0, 0), 977 AddOneOfEveryQuadType(root_pass, resource_provider.get(), RenderPassId(0, 0),
978 &mailbox_sync_point); 978 &mailbox_sync_point);
979 979
980 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); 980 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_);
981 981
982 // Set up expected texture filter state transitions that match the quads 982 // Set up expected texture filter state transitions that match the quads
983 // created in AppendOneOfEveryQuadType(). 983 // created in AppendOneOfEveryQuadType().
984 Mock::VerifyAndClearExpectations(context); 984 Mock::VerifyAndClearExpectations(context);
985 { 985 {
986 InSequence sequence; 986 InSequence sequence;
987 987
988 // The sync points for all quads are waited on first. This sync point is 988 // The sync points for all quads are waited on first. This sync point is
989 // for a texture quad drawn later in the frame. 989 // for a texture quad drawn later in the frame.
990 EXPECT_CALL(*context, waitSyncPoint(mailbox_sync_point)).Times(1); 990 gpu::SyncToken mailbox_sync_token(mailbox_sync_point);
991 EXPECT_CALL(*context, waitSyncToken(mailbox_sync_token.GetConstData()))
992 .Times(1);
991 993
992 // yuv_quad is drawn with the default linear filter. 994 // yuv_quad is drawn with the default linear filter.
993 EXPECT_CALL(*context, drawElements(_, _, _, _)); 995 EXPECT_CALL(*context, drawElements(_, _, _, _));
994 996
995 // tile_quad is drawn with GL_NEAREST because it is not transformed or 997 // tile_quad is drawn with GL_NEAREST because it is not transformed or
996 // scaled. 998 // scaled.
997 EXPECT_CALL( 999 EXPECT_CALL(
998 *context, 1000 *context,
999 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); 1001 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
1000 EXPECT_CALL( 1002 EXPECT_CALL(
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 : OverlayProcessor(surface) {} 2018 : OverlayProcessor(surface) {}
2017 ~TestOverlayProcessor() override {} 2019 ~TestOverlayProcessor() override {}
2018 void Initialize() override { 2020 void Initialize() override {
2019 strategy_ = new Strategy(); 2021 strategy_ = new Strategy();
2020 strategies_.push_back(make_scoped_ptr(strategy_)); 2022 strategies_.push_back(make_scoped_ptr(strategy_));
2021 } 2023 }
2022 2024
2023 Strategy* strategy_; 2025 Strategy* strategy_;
2024 }; 2026 };
2025 2027
2026 void MailboxReleased(unsigned sync_point, 2028 void MailboxReleased(const gpu::SyncToken& sync_token,
2027 bool lost_resource, 2029 bool lost_resource,
2028 BlockingTaskRunner* main_thread_task_runner) { 2030 BlockingTaskRunner* main_thread_task_runner) {}
2029 }
2030 2031
2031 void IgnoreCopyResult(scoped_ptr<CopyOutputResult> result) { 2032 void IgnoreCopyResult(scoped_ptr<CopyOutputResult> result) {
2032 } 2033 }
2033 2034
2034 TEST_F(GLRendererTest, DontOverlayWithCopyRequests) { 2035 TEST_F(GLRendererTest, DontOverlayWithCopyRequests) {
2035 scoped_ptr<DiscardCheckingContext> context_owned(new DiscardCheckingContext); 2036 scoped_ptr<DiscardCheckingContext> context_owned(new DiscardCheckingContext);
2036 FakeOutputSurfaceClient output_surface_client; 2037 FakeOutputSurfaceClient output_surface_client;
2037 scoped_ptr<OutputSurface> output_surface( 2038 scoped_ptr<OutputSurface> output_surface(
2038 FakeOutputSurface::Create3d(context_owned.Pass())); 2039 FakeOutputSurface::Create3d(context_owned.Pass()));
2039 CHECK(output_surface->BindToClient(&output_surface_client)); 2040 CHECK(output_surface->BindToClient(&output_surface_client));
(...skipping 16 matching lines...) Expand all
2056 renderer.SetOverlayProcessor(processor); 2057 renderer.SetOverlayProcessor(processor);
2057 2058
2058 gfx::Rect viewport_rect(1, 1); 2059 gfx::Rect viewport_rect(1, 1);
2059 RenderPass* root_pass = 2060 RenderPass* root_pass =
2060 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0), 2061 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0),
2061 viewport_rect, gfx::Transform()); 2062 viewport_rect, gfx::Transform());
2062 root_pass->has_transparent_background = false; 2063 root_pass->has_transparent_background = false;
2063 root_pass->copy_requests.push_back( 2064 root_pass->copy_requests.push_back(
2064 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreCopyResult))); 2065 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreCopyResult)));
2065 2066
2066 unsigned sync_point = 0;
2067 TextureMailbox mailbox = 2067 TextureMailbox mailbox =
2068 TextureMailbox(gpu::Mailbox::Generate(), GL_TEXTURE_2D, sync_point, 2068 TextureMailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), GL_TEXTURE_2D,
2069 gfx::Size(256, 256), true); 2069 gfx::Size(256, 256), true);
2070 scoped_ptr<SingleReleaseCallbackImpl> release_callback = 2070 scoped_ptr<SingleReleaseCallbackImpl> release_callback =
2071 SingleReleaseCallbackImpl::Create(base::Bind(&MailboxReleased)); 2071 SingleReleaseCallbackImpl::Create(base::Bind(&MailboxReleased));
2072 ResourceId resource_id = resource_provider->CreateResourceFromTextureMailbox( 2072 ResourceId resource_id = resource_provider->CreateResourceFromTextureMailbox(
2073 mailbox, release_callback.Pass()); 2073 mailbox, release_callback.Pass());
2074 bool premultiplied_alpha = false; 2074 bool premultiplied_alpha = false;
2075 bool flipped = false; 2075 bool flipped = false;
2076 bool nearest_neighbor = false; 2076 bool nearest_neighbor = false;
2077 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; 2077 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f};
2078 2078
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 : OverlayProcessor(surface) {} 2132 : OverlayProcessor(surface) {}
2133 2133
2134 void Initialize() override { 2134 void Initialize() override {
2135 strategies_.push_back( 2135 strategies_.push_back(
2136 make_scoped_ptr(new OverlayStrategySingleOnTop(&validator_))); 2136 make_scoped_ptr(new OverlayStrategySingleOnTop(&validator_)));
2137 } 2137 }
2138 2138
2139 SingleOverlayValidator validator_; 2139 SingleOverlayValidator validator_;
2140 }; 2140 };
2141 2141
2142 class WaitSyncPointCountingContext : public TestWebGraphicsContext3D { 2142 class WaitSyncTokenCountingContext : public TestWebGraphicsContext3D {
2143 public: 2143 public:
2144 MOCK_METHOD1(waitSyncPoint, void(unsigned sync_point)); 2144 MOCK_METHOD1(waitSyncToken, void(const GLbyte* sync_Token));
piman 2015/10/29 00:08:20 nit: sync_token
David Yen 2015/10/29 17:08:08 Done.
2145 }; 2145 };
2146 2146
2147 class MockOverlayScheduler { 2147 class MockOverlayScheduler {
2148 public: 2148 public:
2149 MOCK_METHOD5(Schedule, 2149 MOCK_METHOD5(Schedule,
2150 void(int plane_z_order, 2150 void(int plane_z_order,
2151 gfx::OverlayTransform plane_transform, 2151 gfx::OverlayTransform plane_transform,
2152 unsigned overlay_texture_id, 2152 unsigned overlay_texture_id,
2153 const gfx::Rect& display_bounds, 2153 const gfx::Rect& display_bounds,
2154 const gfx::RectF& uv_rect)); 2154 const gfx::RectF& uv_rect));
2155 }; 2155 };
2156 2156
2157 TEST_F(GLRendererTest, OverlaySyncPointsAreProcessed) { 2157 TEST_F(GLRendererTest, OverlaySyncTokensAreProcessed) {
2158 scoped_ptr<WaitSyncPointCountingContext> context_owned( 2158 scoped_ptr<WaitSyncTokenCountingContext> context_owned(
2159 new WaitSyncPointCountingContext); 2159 new WaitSyncTokenCountingContext);
2160 WaitSyncPointCountingContext* context = context_owned.get(); 2160 WaitSyncTokenCountingContext* context = context_owned.get();
2161 2161
2162 MockOverlayScheduler overlay_scheduler; 2162 MockOverlayScheduler overlay_scheduler;
2163 scoped_refptr<TestContextProvider> context_provider = 2163 scoped_refptr<TestContextProvider> context_provider =
2164 TestContextProvider::Create(context_owned.Pass()); 2164 TestContextProvider::Create(context_owned.Pass());
2165 context_provider->support()->SetScheduleOverlayPlaneCallback(base::Bind( 2165 context_provider->support()->SetScheduleOverlayPlaneCallback(base::Bind(
2166 &MockOverlayScheduler::Schedule, base::Unretained(&overlay_scheduler))); 2166 &MockOverlayScheduler::Schedule, base::Unretained(&overlay_scheduler)));
2167 2167
2168 FakeOutputSurfaceClient output_surface_client; 2168 FakeOutputSurfaceClient output_surface_client;
2169 scoped_ptr<OutputSurface> output_surface( 2169 scoped_ptr<OutputSurface> output_surface(
2170 FakeOutputSurface::Create3d(context_provider)); 2170 FakeOutputSurface::Create3d(context_provider));
(...skipping 15 matching lines...) Expand all
2186 new SingleOverlayOnTopProcessor(output_surface.get()); 2186 new SingleOverlayOnTopProcessor(output_surface.get());
2187 processor->Initialize(); 2187 processor->Initialize();
2188 renderer.SetOverlayProcessor(processor); 2188 renderer.SetOverlayProcessor(processor);
2189 2189
2190 gfx::Rect viewport_rect(1, 1); 2190 gfx::Rect viewport_rect(1, 1);
2191 RenderPass* root_pass = 2191 RenderPass* root_pass =
2192 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0), 2192 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0),
2193 viewport_rect, gfx::Transform()); 2193 viewport_rect, gfx::Transform());
2194 root_pass->has_transparent_background = false; 2194 root_pass->has_transparent_background = false;
2195 2195
2196 unsigned sync_point = 29; 2196 gpu::SyncToken sync_token(29);
2197 TextureMailbox mailbox = 2197 TextureMailbox mailbox =
2198 TextureMailbox(gpu::Mailbox::Generate(), GL_TEXTURE_2D, sync_point, 2198 TextureMailbox(gpu::Mailbox::Generate(), sync_token, GL_TEXTURE_2D,
2199 gfx::Size(256, 256), true); 2199 gfx::Size(256, 256), true);
2200 scoped_ptr<SingleReleaseCallbackImpl> release_callback = 2200 scoped_ptr<SingleReleaseCallbackImpl> release_callback =
2201 SingleReleaseCallbackImpl::Create(base::Bind(&MailboxReleased)); 2201 SingleReleaseCallbackImpl::Create(base::Bind(&MailboxReleased));
2202 ResourceId resource_id = resource_provider->CreateResourceFromTextureMailbox( 2202 ResourceId resource_id = resource_provider->CreateResourceFromTextureMailbox(
2203 mailbox, release_callback.Pass()); 2203 mailbox, release_callback.Pass());
2204 bool premultiplied_alpha = false; 2204 bool premultiplied_alpha = false;
2205 bool flipped = false; 2205 bool flipped = false;
2206 bool nearest_neighbor = false; 2206 bool nearest_neighbor = false;
2207 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; 2207 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f};
2208 gfx::PointF uv_top_left(0, 0); 2208 gfx::PointF uv_top_left(0, 0);
2209 gfx::PointF uv_bottom_right(1, 1); 2209 gfx::PointF uv_bottom_right(1, 1);
2210 2210
2211 TextureDrawQuad* overlay_quad = 2211 TextureDrawQuad* overlay_quad =
2212 root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 2212 root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
2213 SharedQuadState* shared_state = root_pass->CreateAndAppendSharedQuadState(); 2213 SharedQuadState* shared_state = root_pass->CreateAndAppendSharedQuadState();
2214 shared_state->SetAll(gfx::Transform(), viewport_rect.size(), viewport_rect, 2214 shared_state->SetAll(gfx::Transform(), viewport_rect.size(), viewport_rect,
2215 viewport_rect, false, 1, SkXfermode::kSrcOver_Mode, 0); 2215 viewport_rect, false, 1, SkXfermode::kSrcOver_Mode, 0);
2216 overlay_quad->SetNew(shared_state, viewport_rect, viewport_rect, 2216 overlay_quad->SetNew(shared_state, viewport_rect, viewport_rect,
2217 viewport_rect, resource_id, premultiplied_alpha, 2217 viewport_rect, resource_id, premultiplied_alpha,
2218 uv_top_left, uv_bottom_right, SK_ColorTRANSPARENT, 2218 uv_top_left, uv_bottom_right, SK_ColorTRANSPARENT,
2219 vertex_opacity, flipped, nearest_neighbor); 2219 vertex_opacity, flipped, nearest_neighbor);
2220 2220
2221 // Verify that overlay_quad actually gets turned into an overlay, and even 2221 // Verify that overlay_quad actually gets turned into an overlay, and even
2222 // though it's not drawn, that its sync point is waited on. 2222 // though it's not drawn, that its sync point is waited on.
2223 EXPECT_CALL(*context, waitSyncPoint(sync_point)).Times(1); 2223 EXPECT_CALL(*context, waitSyncToken(sync_token.GetConstData())).Times(1);
2224 EXPECT_CALL(overlay_scheduler, 2224 EXPECT_CALL(overlay_scheduler,
2225 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect, 2225 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect,
2226 BoundingRect(uv_top_left, uv_bottom_right))).Times(1); 2226 BoundingRect(uv_top_left, uv_bottom_right))).Times(1);
2227 2227
2228 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2228 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2229 viewport_rect, false); 2229 viewport_rect, false);
2230 } 2230 }
2231 2231
2232 } // namespace 2232 } // namespace
2233 } // namespace cc 2233 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698