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

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

Issue 1469863003: Cleanup SurfaceVisibility code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase.. Created 5 years 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/test_context_support.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 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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 .Times(1); 842 .Times(1);
843 EXPECT_CALL(*context, clear(_)).Times(AnyNumber()); 843 EXPECT_CALL(*context, clear(_)).Times(AnyNumber());
844 renderer.DrawFrame(&render_passes_in_draw_order_, 844 renderer.DrawFrame(&render_passes_in_draw_order_,
845 1.f, 845 1.f,
846 viewport_rect, 846 viewport_rect,
847 viewport_rect, 847 viewport_rect,
848 false); 848 false);
849 Mock::VerifyAndClearExpectations(context); 849 Mock::VerifyAndClearExpectations(context);
850 } 850 }
851 851
852 class VisibilityChangeIsLastCallTrackingContext
853 : public TestWebGraphicsContext3D {
854 public:
855 VisibilityChangeIsLastCallTrackingContext()
856 : last_call_was_set_visibility_(false) {}
857
858 // TestWebGraphicsContext3D methods.
859 void flush() override { last_call_was_set_visibility_ = false; }
860 void deleteTexture(GLuint) override { last_call_was_set_visibility_ = false; }
861 void deleteFramebuffer(GLuint) override {
862 last_call_was_set_visibility_ = false;
863 }
864 void deleteQueryEXT(GLuint) override {
865 last_call_was_set_visibility_ = false;
866 }
867 void deleteRenderbuffer(GLuint) override {
868 last_call_was_set_visibility_ = false;
869 }
870
871 // Methods added for test.
872 void set_last_call_was_visibility(bool visible) {
873 DCHECK(last_call_was_set_visibility_ == false);
874 last_call_was_set_visibility_ = true;
875 }
876 bool last_call_was_set_visibility() const {
877 return last_call_was_set_visibility_;
878 }
879
880 private:
881 bool last_call_was_set_visibility_;
882 };
883
884 TEST_F(GLRendererTest, VisibilityChangeIsLastCall) {
885 scoped_ptr<VisibilityChangeIsLastCallTrackingContext> context_owned(
886 new VisibilityChangeIsLastCallTrackingContext);
887 VisibilityChangeIsLastCallTrackingContext* context = context_owned.get();
888
889 scoped_refptr<TestContextProvider> provider =
890 TestContextProvider::Create(std::move(context_owned));
891
892 provider->support()->SetSurfaceVisibleCallback(base::Bind(
893 &VisibilityChangeIsLastCallTrackingContext::set_last_call_was_visibility,
894 base::Unretained(context)));
895
896 FakeOutputSurfaceClient output_surface_client;
897 scoped_ptr<OutputSurface> output_surface(
898 FakeOutputSurface::Create3d(provider));
899 CHECK(output_surface->BindToClient(&output_surface_client));
900
901 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
902 new TestSharedBitmapManager());
903 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create(
904 output_surface.get(), shared_bitmap_manager.get());
905
906 RendererSettings settings;
907 FakeRendererClient renderer_client;
908 FakeRendererGL renderer(&renderer_client,
909 &settings,
910 output_surface.get(),
911 resource_provider.get());
912
913 gfx::Rect viewport_rect(1, 1);
914 AddRenderPass(&render_passes_in_draw_order_,
915 RenderPassId(1, 0),
916 viewport_rect,
917 gfx::Transform());
918
919 // Ensure that the call to SetSurfaceVisible is the last call issue to the
920 // GPU process, after glFlush is called, and after the RendererClient's
921 // SetManagedMemoryPolicy is called. Plumb this tracking between both the
922 // RenderClient and the Context by giving them both a pointer to a variable on
923 // the stack.
924 renderer.SetVisible(true);
925 renderer.DrawFrame(&render_passes_in_draw_order_,
926 1.f,
927 viewport_rect,
928 viewport_rect,
929 false);
930 renderer.SetVisible(false);
931 EXPECT_TRUE(context->last_call_was_set_visibility());
932 }
933
934 class TextureStateTrackingContext : public TestWebGraphicsContext3D { 852 class TextureStateTrackingContext : public TestWebGraphicsContext3D {
935 public: 853 public:
936 TextureStateTrackingContext() : active_texture_(GL_INVALID_ENUM) { 854 TextureStateTrackingContext() : active_texture_(GL_INVALID_ENUM) {
937 test_capabilities_.gpu.egl_image_external = true; 855 test_capabilities_.gpu.egl_image_external = true;
938 } 856 }
939 857
940 MOCK_METHOD1(waitSyncToken, void(const GLbyte* sync_token)); 858 MOCK_METHOD1(waitSyncToken, void(const GLbyte* sync_token));
941 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); 859 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param));
942 MOCK_METHOD4(drawElements, 860 MOCK_METHOD4(drawElements,
943 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); 861 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset));
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 EXPECT_CALL(overlay_scheduler, 2202 EXPECT_CALL(overlay_scheduler,
2285 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect, 2203 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect,
2286 BoundingRect(uv_top_left, uv_bottom_right))).Times(1); 2204 BoundingRect(uv_top_left, uv_bottom_right))).Times(1);
2287 2205
2288 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2206 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2289 viewport_rect, false); 2207 viewport_rect, false);
2290 } 2208 }
2291 2209
2292 } // namespace 2210 } // namespace
2293 } // namespace cc 2211 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/test/test_context_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698