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

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

Issue 1985973002: Defer compositor context creation to the thread. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: contextfactory: . 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
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 void reset() { discarded_ = 0; } 1132 void reset() { discarded_ = 0; }
1133 1133
1134 private: 1134 private:
1135 int discarded_; 1135 int discarded_;
1136 }; 1136 };
1137 1137
1138 class NonReshapableOutputSurface : public FakeOutputSurface { 1138 class NonReshapableOutputSurface : public FakeOutputSurface {
1139 public: 1139 public:
1140 explicit NonReshapableOutputSurface( 1140 explicit NonReshapableOutputSurface(
1141 std::unique_ptr<TestWebGraphicsContext3D> context3d) 1141 std::unique_ptr<TestWebGraphicsContext3D> context3d)
1142 : FakeOutputSurface(TestContextProvider::Create(std::move(context3d)), 1142 : FakeOutputSurface(base::MakeUnique<TestContextProvider::Factory>(
1143 std::move(context3d)),
1143 false) { 1144 false) {
1144 surface_size_ = gfx::Size(500, 500); 1145 surface_size_ = gfx::Size(500, 500);
1145 } 1146 }
1146 void Reshape(const gfx::Size& size, 1147 void Reshape(const gfx::Size& size,
1147 float scale_factor, 1148 float scale_factor,
1148 bool has_alpha) override {} 1149 bool has_alpha) override {}
1149 void set_fixed_size(const gfx::Size& size) { surface_size_ = size; } 1150 void set_fixed_size(const gfx::Size& size) { surface_size_ = size; }
1150 }; 1151 };
1151 1152
1152 TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { 1153 TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) {
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 MOCK_METHOD2(bindFramebuffer, void(GLenum target, GLuint framebuffer)); 1756 MOCK_METHOD2(bindFramebuffer, void(GLenum target, GLuint framebuffer));
1756 MOCK_METHOD3(reshapeWithScaleFactor, 1757 MOCK_METHOD3(reshapeWithScaleFactor,
1757 void(int width, int height, float scale_factor)); 1758 void(int width, int height, float scale_factor));
1758 MOCK_METHOD4(drawElements, 1759 MOCK_METHOD4(drawElements,
1759 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); 1760 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset));
1760 }; 1761 };
1761 1762
1762 class MockOutputSurface : public OutputSurface { 1763 class MockOutputSurface : public OutputSurface {
1763 public: 1764 public:
1764 MockOutputSurface() 1765 MockOutputSurface()
1765 : OutputSurface(TestContextProvider::Create( 1766 : OutputSurface(base::MakeUnique<TestContextProvider::Factory>(
1766 std::unique_ptr<TestWebGraphicsContext3D>( 1767 base::MakeUnique<StrictMock<OutputSurfaceMockContext>>())) {
1767 new StrictMock<OutputSurfaceMockContext>))) {
1768 surface_size_ = gfx::Size(100, 100); 1768 surface_size_ = gfx::Size(100, 100);
1769 } 1769 }
1770 virtual ~MockOutputSurface() {} 1770 virtual ~MockOutputSurface() {}
1771 1771
1772 MOCK_METHOD0(EnsureBackbuffer, void()); 1772 MOCK_METHOD0(EnsureBackbuffer, void());
1773 MOCK_METHOD0(DiscardBackbuffer, void()); 1773 MOCK_METHOD0(DiscardBackbuffer, void());
1774 MOCK_METHOD3(Reshape, 1774 MOCK_METHOD3(Reshape,
1775 void(const gfx::Size& size, float scale_factor, bool has_alpha)); 1775 void(const gfx::Size& size, float scale_factor, bool has_alpha));
1776 MOCK_METHOD0(BindFramebuffer, void()); 1776 MOCK_METHOD0(BindFramebuffer, void());
1777 MOCK_METHOD1(SwapBuffers, void(CompositorFrame* frame)); 1777 MOCK_METHOD1(SwapBuffers, void(CompositorFrame* frame));
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 const gfx::Rect& display_bounds, 2076 const gfx::Rect& display_bounds,
2077 const gfx::RectF& uv_rect)); 2077 const gfx::RectF& uv_rect));
2078 }; 2078 };
2079 2079
2080 TEST_F(GLRendererTest, OverlaySyncTokensAreProcessed) { 2080 TEST_F(GLRendererTest, OverlaySyncTokensAreProcessed) {
2081 std::unique_ptr<WaitSyncTokenCountingContext> context_owned( 2081 std::unique_ptr<WaitSyncTokenCountingContext> context_owned(
2082 new WaitSyncTokenCountingContext); 2082 new WaitSyncTokenCountingContext);
2083 WaitSyncTokenCountingContext* context = context_owned.get(); 2083 WaitSyncTokenCountingContext* context = context_owned.get();
2084 2084
2085 MockOverlayScheduler overlay_scheduler; 2085 MockOverlayScheduler overlay_scheduler;
2086 scoped_refptr<TestContextProvider> context_provider = 2086 FakeOutputSurfaceClient output_surface_client;
2087 TestContextProvider::Create(std::move(context_owned)); 2087 std::unique_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2088 base::MakeUnique<TestContextProvider::Factory>(
2089 std::move(context_owned))));
2090 CHECK(output_surface->BindToClient(&output_surface_client));
2091 TestContextProvider* context_provider =
2092 static_cast<TestContextProvider*>(output_surface->context_provider());
2093
2088 context_provider->support()->SetScheduleOverlayPlaneCallback(base::Bind( 2094 context_provider->support()->SetScheduleOverlayPlaneCallback(base::Bind(
2089 &MockOverlayScheduler::Schedule, base::Unretained(&overlay_scheduler))); 2095 &MockOverlayScheduler::Schedule, base::Unretained(&overlay_scheduler)));
2090 2096
2091 FakeOutputSurfaceClient output_surface_client;
2092 std::unique_ptr<OutputSurface> output_surface(
2093 FakeOutputSurface::Create3d(context_provider));
2094 CHECK(output_surface->BindToClient(&output_surface_client));
2095
2096 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( 2097 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
2097 new TestSharedBitmapManager()); 2098 new TestSharedBitmapManager());
2098 std::unique_ptr<ResourceProvider> resource_provider = 2099 std::unique_ptr<ResourceProvider> resource_provider =
2099 FakeResourceProvider::Create(output_surface.get(), 2100 FakeResourceProvider::Create(output_surface.get(),
2100 shared_bitmap_manager.get()); 2101 shared_bitmap_manager.get());
2101 std::unique_ptr<TextureMailboxDeleter> mailbox_deleter( 2102 std::unique_ptr<TextureMailboxDeleter> mailbox_deleter(
2102 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get())); 2103 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get()));
2103 2104
2104 RendererSettings settings; 2105 RendererSettings settings;
2105 FakeRendererClient renderer_client; 2106 FakeRendererClient renderer_client;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 EXPECT_CALL(overlay_scheduler, 2150 EXPECT_CALL(overlay_scheduler,
2150 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect, 2151 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect,
2151 BoundingRect(uv_top_left, uv_bottom_right))).Times(1); 2152 BoundingRect(uv_top_left, uv_bottom_right))).Times(1);
2152 2153
2153 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2154 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2154 viewport_rect, false); 2155 viewport_rect, false);
2155 } 2156 }
2156 2157
2157 } // namespace 2158 } // namespace
2158 } // namespace cc 2159 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698