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

Side by Side Diff: content/browser/renderer_host/offscreen_canvas_surface_manager_unittest.cc

Issue 2644653003: Make OffscreenCanvas animation in sync with its placeholder canvas's parent frame rate (Closed)
Patch Set: rebase again Created 3 years, 10 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 (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/browser/compositor/test/no_transport_image_transport_factory.h " 5 #include "content/browser/compositor/test/no_transport_image_transport_factory.h "
6 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h" 6 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h"
7 #include "content/browser/renderer_host/offscreen_canvas_surface_manager.h" 7 #include "content/browser/renderer_host/offscreen_canvas_surface_manager.h"
8 #include "content/public/test/test_browser_thread.h" 8 #include "content/public/test/test_browser_thread.h"
9 #include "mojo/public/cpp/bindings/binding.h" 9 #include "mojo/public/cpp/bindings/binding.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // This test mimics the workflow of OffscreenCanvas.commit() on renderer 68 // This test mimics the workflow of OffscreenCanvas.commit() on renderer
69 // process. 69 // process.
70 TEST_F(OffscreenCanvasSurfaceManagerTest, 70 TEST_F(OffscreenCanvasSurfaceManagerTest,
71 SingleHTMLCanvasElementTransferToOffscreen) { 71 SingleHTMLCanvasElementTransferToOffscreen) {
72 blink::mojom::OffscreenCanvasSurfaceClientPtr client; 72 blink::mojom::OffscreenCanvasSurfaceClientPtr client;
73 cc::FrameSinkId frame_sink_id(3, 3); 73 cc::FrameSinkId frame_sink_id(3, 3);
74 cc::SurfaceIdAllocator surface_id_allocator; 74 cc::SurfaceIdAllocator surface_id_allocator;
75 cc::LocalSurfaceId current_local_surface_id( 75 cc::LocalSurfaceId current_local_surface_id(
76 surface_id_allocator.GenerateId()); 76 surface_id_allocator.GenerateId());
77 77
78 auto surface_impl = base::WrapUnique( 78 auto surface_impl = base::WrapUnique(new OffscreenCanvasSurfaceImpl(
79 new OffscreenCanvasSurfaceImpl(frame_sink_id, std::move(client))); 79 cc::FrameSinkId(), frame_sink_id, std::move(client)));
80 EXPECT_EQ(1, this->getNumSurfaceImplInstances()); 80 EXPECT_EQ(1, this->getNumSurfaceImplInstances());
81 EXPECT_EQ(surface_impl.get(), 81 EXPECT_EQ(surface_impl.get(),
82 OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance( 82 OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance(
83 frame_sink_id)); 83 frame_sink_id));
84 84
85 this->OnSurfaceCreated( 85 this->OnSurfaceCreated(
86 cc::SurfaceId(frame_sink_id, current_local_surface_id)); 86 cc::SurfaceId(frame_sink_id, current_local_surface_id));
87 EXPECT_EQ(current_local_surface_id, surface_impl->current_local_surface_id()); 87 EXPECT_EQ(current_local_surface_id, surface_impl->current_local_surface_id());
88 88
89 surface_impl = nullptr; 89 surface_impl = nullptr;
90 EXPECT_EQ(0, this->getNumSurfaceImplInstances()); 90 EXPECT_EQ(0, this->getNumSurfaceImplInstances());
91 } 91 }
92 92
93 TEST_F(OffscreenCanvasSurfaceManagerTest, 93 TEST_F(OffscreenCanvasSurfaceManagerTest,
94 MultiHTMLCanvasElementTransferToOffscreen) { 94 MultiHTMLCanvasElementTransferToOffscreen) {
95 blink::mojom::OffscreenCanvasSurfaceClientPtr client_a; 95 blink::mojom::OffscreenCanvasSurfaceClientPtr client_a;
96 cc::FrameSinkId dummy_parent_frame_sink_id(0, 0);
96 cc::FrameSinkId frame_sink_id_a(3, 3); 97 cc::FrameSinkId frame_sink_id_a(3, 3);
97 cc::SurfaceIdAllocator surface_id_allocator; 98 cc::SurfaceIdAllocator surface_id_allocator;
98 auto surface_impl_a = base::WrapUnique( 99 auto surface_impl_a = base::WrapUnique(new OffscreenCanvasSurfaceImpl(
99 new OffscreenCanvasSurfaceImpl(frame_sink_id_a, std::move(client_a))); 100 dummy_parent_frame_sink_id, frame_sink_id_a, std::move(client_a)));
100 101
101 blink::mojom::OffscreenCanvasSurfaceClientPtr client_b; 102 blink::mojom::OffscreenCanvasSurfaceClientPtr client_b;
102 cc::FrameSinkId frame_sink_id_b(4, 4); 103 cc::FrameSinkId frame_sink_id_b(4, 4);
103 104
104 auto surface_impl_b = base::WrapUnique( 105 auto surface_impl_b = base::WrapUnique(new OffscreenCanvasSurfaceImpl(
105 new OffscreenCanvasSurfaceImpl(frame_sink_id_b, std::move(client_b))); 106 dummy_parent_frame_sink_id, frame_sink_id_b, std::move(client_b)));
106 107
107 EXPECT_EQ(2, this->getNumSurfaceImplInstances()); 108 EXPECT_EQ(2, this->getNumSurfaceImplInstances());
108 EXPECT_EQ(surface_impl_a.get(), 109 EXPECT_EQ(surface_impl_a.get(),
109 OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance( 110 OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance(
110 frame_sink_id_a)); 111 frame_sink_id_a));
111 EXPECT_EQ(surface_impl_b.get(), 112 EXPECT_EQ(surface_impl_b.get(),
112 OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance( 113 OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance(
113 frame_sink_id_b)); 114 frame_sink_id_b));
114 115
115 surface_impl_a = nullptr; 116 surface_impl_a = nullptr;
116 EXPECT_EQ(1, this->getNumSurfaceImplInstances()); 117 EXPECT_EQ(1, this->getNumSurfaceImplInstances());
117 surface_impl_b = nullptr; 118 surface_impl_b = nullptr;
118 EXPECT_EQ(0, this->getNumSurfaceImplInstances()); 119 EXPECT_EQ(0, this->getNumSurfaceImplInstances());
119 } 120 }
120 121
121 } // namespace content 122 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/offscreen_canvas_surface_manager.cc ('k') | content/renderer/gpu/render_widget_compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698