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

Side by Side Diff: components/exo/buffer_unittest.cc

Issue 2626293005: exo::CompositorFrameSink uses CompositorFrameSinkHolder* instead of mojo interface pointer (Closed)
Patch Set: Addressed nit Created 3 years, 11 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 | « no previous file | components/exo/compositor_frame_sink.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <GLES2/gl2extchromium.h> 5 #include <GLES2/gl2extchromium.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "cc/output/context_provider.h" 8 #include "cc/output/context_provider.h"
9 #include "cc/resources/single_release_callback.h" 9 #include "cc/resources/single_release_callback.h"
10 #include "components/exo/buffer.h" 10 #include "components/exo/buffer.h"
(...skipping 14 matching lines...) Expand all
25 25
26 void Release(int* release_call_count) { 26 void Release(int* release_call_count) {
27 (*release_call_count)++; 27 (*release_call_count)++;
28 } 28 }
29 29
30 TEST_F(BufferTest, ReleaseCallback) { 30 TEST_F(BufferTest, ReleaseCallback) {
31 gfx::Size buffer_size(256, 256); 31 gfx::Size buffer_size(256, 256);
32 std::unique_ptr<Buffer> buffer( 32 std::unique_ptr<Buffer> buffer(
33 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 33 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
34 std::unique_ptr<Surface> surface(new Surface); 34 std::unique_ptr<Surface> surface(new Surface);
35 const cc::FrameSinkId arbitrary_frame_sink_id(1, 1);
35 scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder = 36 scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder =
36 new CompositorFrameSinkHolder(surface.get(), nullptr, nullptr); 37 new CompositorFrameSinkHolder(surface.get(), arbitrary_frame_sink_id,
38 aura::Env::GetInstance()
39 ->context_factory_private()
40 ->GetSurfaceManager());
37 41
38 // Set the release callback. 42 // Set the release callback.
39 int release_call_count = 0; 43 int release_call_count = 0;
40 buffer->set_release_callback( 44 buffer->set_release_callback(
41 base::Bind(&Release, base::Unretained(&release_call_count))); 45 base::Bind(&Release, base::Unretained(&release_call_count)));
42 46
43 buffer->OnAttach(); 47 buffer->OnAttach();
44 cc::TransferableResource resource; 48 cc::TransferableResource resource;
45 // Produce a transferable resource for the contents of the buffer. 49 // Produce a transferable resource for the contents of the buffer.
46 bool rv = buffer->ProduceTransferableResource( 50 bool rv = buffer->ProduceTransferableResource(
(...skipping 14 matching lines...) Expand all
61 buffer->OnDetach(); 65 buffer->OnDetach();
62 66
63 // Release() should have been called exactly once. 67 // Release() should have been called exactly once.
64 ASSERT_EQ(release_call_count, 1); 68 ASSERT_EQ(release_call_count, 1);
65 } 69 }
66 70
67 TEST_F(BufferTest, IsLost) { 71 TEST_F(BufferTest, IsLost) {
68 gfx::Size buffer_size(256, 256); 72 gfx::Size buffer_size(256, 256);
69 std::unique_ptr<Buffer> buffer( 73 std::unique_ptr<Buffer> buffer(
70 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 74 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
75 const cc::FrameSinkId arbitrary_frame_sink_id(1, 1);
71 std::unique_ptr<Surface> surface(new Surface); 76 std::unique_ptr<Surface> surface(new Surface);
72 scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder = 77 scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder =
73 new CompositorFrameSinkHolder(surface.get(), nullptr, nullptr); 78 new CompositorFrameSinkHolder(surface.get(), arbitrary_frame_sink_id,
79 aura::Env::GetInstance()
80 ->context_factory_private()
81 ->GetSurfaceManager());
74 cc::ResourceId resource_id = 0; 82 cc::ResourceId resource_id = 0;
75 83
76 buffer->OnAttach(); 84 buffer->OnAttach();
77 // Acquire a texture transferable resource for the contents of the buffer. 85 // Acquire a texture transferable resource for the contents of the buffer.
78 cc::TransferableResource resource; 86 cc::TransferableResource resource;
79 bool rv = buffer->ProduceTransferableResource( 87 bool rv = buffer->ProduceTransferableResource(
80 compositor_frame_sink_holder.get(), resource_id, false, true, &resource); 88 compositor_frame_sink_holder.get(), resource_id, false, true, &resource);
81 ASSERT_TRUE(rv); 89 ASSERT_TRUE(rv);
82 90
83 scoped_refptr<cc::ContextProvider> context_provider = 91 scoped_refptr<cc::ContextProvider> context_provider =
(...skipping 30 matching lines...) Expand all
114 returned_resource2.id = resource_id; 122 returned_resource2.id = resource_id;
115 returned_resource2.sync_token = gpu::SyncToken(); 123 returned_resource2.sync_token = gpu::SyncToken();
116 returned_resource2.lost = false; 124 returned_resource2.lost = false;
117 cc::ReturnedResourceArray resources2 = {returned_resource2}; 125 cc::ReturnedResourceArray resources2 = {returned_resource2};
118 compositor_frame_sink_holder->ReclaimResources(resources2); 126 compositor_frame_sink_holder->ReclaimResources(resources2);
119 RunAllPendingInMessageLoop(); 127 RunAllPendingInMessageLoop();
120 } 128 }
121 129
122 } // namespace 130 } // namespace
123 } // namespace exo 131 } // namespace exo
OLDNEW
« no previous file with comments | « no previous file | components/exo/compositor_frame_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698