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

Side by Side Diff: cc/resources/video_resource_updater_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: rebase + autogen 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/resources/video_resource_updater.h" 5 #include "cc/resources/video_resource_updater.h"
6 6
7 #include "cc/resources/resource_provider.h" 7 #include "cc/resources/resource_provider.h"
8 #include "cc/test/fake_output_surface.h" 8 #include "cc/test/fake_output_surface.h"
9 #include "cc/test/fake_output_surface_client.h" 9 #include "cc/test/fake_output_surface_client.h"
10 #include "cc/test/fake_resource_provider.h" 10 #include "cc/test/fake_resource_provider.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 size, // natural_size 92 size, // natural_size
93 size.width(), // y_stride 93 size.width(), // y_stride
94 size.width() / 2, // u_stride 94 size.width() / 2, // u_stride
95 size.width() / 2, // v_stride 95 size.width() / 2, // v_stride
96 y_data, // y_data 96 y_data, // y_data
97 u_data, // u_data 97 u_data, // u_data
98 v_data, // v_data 98 v_data, // v_data
99 base::TimeDelta()); // timestamp 99 base::TimeDelta()); // timestamp
100 } 100 }
101 101
102 static void ReleaseMailboxCB(unsigned sync_point) {} 102 static void ReleaseMailboxCB(const gpu::SyncToken& sync_token) {}
103 103
104 scoped_refptr<media::VideoFrame> CreateTestRGBAHardwareVideoFrame() { 104 scoped_refptr<media::VideoFrame> CreateTestRGBAHardwareVideoFrame() {
105 const int kDimension = 10; 105 const int kDimension = 10;
106 gfx::Size size(kDimension, kDimension); 106 gfx::Size size(kDimension, kDimension);
107 107
108 gpu::Mailbox mailbox; 108 gpu::Mailbox mailbox;
109 mailbox.name[0] = 51; 109 mailbox.name[0] = 51;
110 110
111 const unsigned sync_point = 7; 111 const gpu::SyncToken sync_token(7);
112 const unsigned target = GL_TEXTURE_2D; 112 const unsigned target = GL_TEXTURE_2D;
113 return media::VideoFrame::WrapNativeTexture( 113 return media::VideoFrame::WrapNativeTexture(
114 media::PIXEL_FORMAT_ARGB, 114 media::PIXEL_FORMAT_ARGB,
115 gpu::MailboxHolder(mailbox, target, sync_point), 115 gpu::MailboxHolder(mailbox, sync_token, target),
116 base::Bind(&ReleaseMailboxCB), 116 base::Bind(&ReleaseMailboxCB),
117 size, // coded_size 117 size, // coded_size
118 gfx::Rect(size), // visible_rect 118 gfx::Rect(size), // visible_rect
119 size, // natural_size 119 size, // natural_size
120 base::TimeDelta()); // timestamp 120 base::TimeDelta()); // timestamp
121 } 121 }
122 122
123 scoped_refptr<media::VideoFrame> CreateTestYUVHardareVideoFrame() { 123 scoped_refptr<media::VideoFrame> CreateTestYUVHardareVideoFrame() {
124 const int kDimension = 10; 124 const int kDimension = 10;
125 gfx::Size size(kDimension, kDimension); 125 gfx::Size size(kDimension, kDimension);
126 126
127 const int kPlanesNum = 3; 127 const int kPlanesNum = 3;
128 gpu::Mailbox mailbox[kPlanesNum]; 128 gpu::Mailbox mailbox[kPlanesNum];
129 for (int i = 0; i < kPlanesNum; ++i) { 129 for (int i = 0; i < kPlanesNum; ++i) {
130 mailbox[i].name[0] = 50 + 1; 130 mailbox[i].name[0] = 50 + 1;
131 } 131 }
132 const unsigned sync_point = 7; 132 const gpu::SyncToken sync_token(7);
133 const unsigned target = GL_TEXTURE_RECTANGLE_ARB; 133 const unsigned target = GL_TEXTURE_RECTANGLE_ARB;
134 return media::VideoFrame::WrapYUV420NativeTextures( 134 return media::VideoFrame::WrapYUV420NativeTextures(
135 gpu::MailboxHolder(mailbox[media::VideoFrame::kYPlane], target, 135 gpu::MailboxHolder(mailbox[media::VideoFrame::kYPlane], sync_token,
136 sync_point), 136 target),
137 gpu::MailboxHolder(mailbox[media::VideoFrame::kUPlane], target, 137 gpu::MailboxHolder(mailbox[media::VideoFrame::kUPlane], sync_token,
138 sync_point), 138 target),
139 gpu::MailboxHolder(mailbox[media::VideoFrame::kVPlane], target, 139 gpu::MailboxHolder(mailbox[media::VideoFrame::kVPlane], sync_token,
140 sync_point), 140 target),
141 base::Bind(&ReleaseMailboxCB), 141 base::Bind(&ReleaseMailboxCB),
142 size, // coded_size 142 size, // coded_size
143 gfx::Rect(size), // visible_rect 143 gfx::Rect(size), // visible_rect
144 size, // natural_size 144 size, // natural_size
145 base::TimeDelta()); // timestamp 145 base::TimeDelta()); // timestamp
146 } 146 }
147 147
148 WebGraphicsContext3DUploadCounter* context3d_; 148 WebGraphicsContext3DUploadCounter* context3d_;
149 FakeOutputSurfaceClient client_; 149 FakeOutputSurfaceClient client_;
150 scoped_ptr<FakeOutputSurface> output_surface3d_; 150 scoped_ptr<FakeOutputSurface> output_surface3d_;
(...skipping 26 matching lines...) Expand all
177 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); 177 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type);
178 EXPECT_EQ(size_t(3), resources.mailboxes.size()); 178 EXPECT_EQ(size_t(3), resources.mailboxes.size());
179 EXPECT_EQ(size_t(3), resources.release_callbacks.size()); 179 EXPECT_EQ(size_t(3), resources.release_callbacks.size());
180 EXPECT_EQ(size_t(0), resources.software_resources.size()); 180 EXPECT_EQ(size_t(0), resources.software_resources.size());
181 // Expect exactly three texture uploads, one for each plane. 181 // Expect exactly three texture uploads, one for each plane.
182 EXPECT_EQ(3, context3d_->UploadCount()); 182 EXPECT_EQ(3, context3d_->UploadCount());
183 183
184 // Simulate the ResourceProvider releasing the resources back to the video 184 // Simulate the ResourceProvider releasing the resources back to the video
185 // updater. 185 // updater.
186 for (ReleaseCallbackImpl& release_callback : resources.release_callbacks) 186 for (ReleaseCallbackImpl& release_callback : resources.release_callbacks)
187 release_callback.Run(0, false, nullptr); 187 release_callback.Run(gpu::SyncToken(), false, nullptr);
188 188
189 // Allocate resources for the same frame. 189 // Allocate resources for the same frame.
190 context3d_->ResetUploadCount(); 190 context3d_->ResetUploadCount();
191 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame); 191 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame);
192 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); 192 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type);
193 EXPECT_EQ(size_t(3), resources.mailboxes.size()); 193 EXPECT_EQ(size_t(3), resources.mailboxes.size());
194 EXPECT_EQ(size_t(3), resources.release_callbacks.size()); 194 EXPECT_EQ(size_t(3), resources.release_callbacks.size());
195 // The data should be reused so expect no texture uploads. 195 // The data should be reused so expect no texture uploads.
196 EXPECT_EQ(0, context3d_->UploadCount()); 196 EXPECT_EQ(0, context3d_->UploadCount());
197 } 197 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 updater.CreateExternalResourcesFromVideoFrame(video_frame); 243 updater.CreateExternalResourcesFromVideoFrame(video_frame);
244 EXPECT_EQ(VideoFrameExternalResources::SOFTWARE_RESOURCE, resources.type); 244 EXPECT_EQ(VideoFrameExternalResources::SOFTWARE_RESOURCE, resources.type);
245 EXPECT_EQ(size_t(0), resources.mailboxes.size()); 245 EXPECT_EQ(size_t(0), resources.mailboxes.size());
246 EXPECT_EQ(size_t(0), resources.release_callbacks.size()); 246 EXPECT_EQ(size_t(0), resources.release_callbacks.size());
247 EXPECT_EQ(size_t(1), resources.software_resources.size()); 247 EXPECT_EQ(size_t(1), resources.software_resources.size());
248 // Expect exactly one allocated shared bitmap. 248 // Expect exactly one allocated shared bitmap.
249 EXPECT_EQ(1, shared_bitmap_manager_->AllocationCount()); 249 EXPECT_EQ(1, shared_bitmap_manager_->AllocationCount());
250 250
251 // Simulate the ResourceProvider releasing the resource back to the video 251 // Simulate the ResourceProvider releasing the resource back to the video
252 // updater. 252 // updater.
253 resources.software_release_callback.Run(0, false, nullptr); 253 resources.software_release_callback.Run(gpu::SyncToken(), false, nullptr);
254 254
255 // Allocate resources for the same frame. 255 // Allocate resources for the same frame.
256 shared_bitmap_manager_->ResetAllocationCount(); 256 shared_bitmap_manager_->ResetAllocationCount();
257 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame); 257 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame);
258 EXPECT_EQ(VideoFrameExternalResources::SOFTWARE_RESOURCE, resources.type); 258 EXPECT_EQ(VideoFrameExternalResources::SOFTWARE_RESOURCE, resources.type);
259 EXPECT_EQ(size_t(0), resources.mailboxes.size()); 259 EXPECT_EQ(size_t(0), resources.mailboxes.size());
260 EXPECT_EQ(size_t(0), resources.release_callbacks.size()); 260 EXPECT_EQ(size_t(0), resources.release_callbacks.size());
261 EXPECT_EQ(size_t(1), resources.software_resources.size()); 261 EXPECT_EQ(size_t(1), resources.software_resources.size());
262 // The data should be reused so expect no new allocations. 262 // The data should be reused so expect no new allocations.
263 EXPECT_EQ(0, shared_bitmap_manager_->AllocationCount()); 263 EXPECT_EQ(0, shared_bitmap_manager_->AllocationCount());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame); 309 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame);
310 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); 310 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type);
311 EXPECT_TRUE(resources.read_lock_fences_enabled); 311 EXPECT_TRUE(resources.read_lock_fences_enabled);
312 EXPECT_EQ(3u, resources.mailboxes.size()); 312 EXPECT_EQ(3u, resources.mailboxes.size());
313 EXPECT_EQ(3u, resources.release_callbacks.size()); 313 EXPECT_EQ(3u, resources.release_callbacks.size());
314 EXPECT_EQ(0u, resources.software_resources.size()); 314 EXPECT_EQ(0u, resources.software_resources.size());
315 } 315 }
316 } // namespace 316 } // namespace
317 } // namespace cc 317 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698