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

Side by Side Diff: cc/resources/video_resource_updater_unittest.cc

Issue 1476523005: Verify returned frames from media::VideoFrame::Wrap*() methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: posciak@ comments. Created 4 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "cc/resources/resource_provider.h" 10 #include "cc/resources/resource_provider.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 output_surface_software_.get(), shared_bitmap_manager_.get()); 80 output_surface_software_.get(), shared_bitmap_manager_.get());
81 } 81 }
82 82
83 scoped_refptr<media::VideoFrame> CreateTestYUVVideoFrame() { 83 scoped_refptr<media::VideoFrame> CreateTestYUVVideoFrame() {
84 const int kDimension = 10; 84 const int kDimension = 10;
85 gfx::Size size(kDimension, kDimension); 85 gfx::Size size(kDimension, kDimension);
86 static uint8_t y_data[kDimension * kDimension] = {0}; 86 static uint8_t y_data[kDimension * kDimension] = {0};
87 static uint8_t u_data[kDimension * kDimension / 2] = {0}; 87 static uint8_t u_data[kDimension * kDimension / 2] = {0};
88 static uint8_t v_data[kDimension * kDimension / 2] = {0}; 88 static uint8_t v_data[kDimension * kDimension / 2] = {0};
89 89
90 return media::VideoFrame::WrapExternalYuvData( 90 scoped_refptr<media::VideoFrame> video_frame =
91 media::PIXEL_FORMAT_YV16, // format 91 media::VideoFrame::WrapExternalYuvData(
92 size, // coded_size 92 media::PIXEL_FORMAT_YV16, // format
93 gfx::Rect(size), // visible_rect 93 size, // coded_size
94 size, // natural_size 94 gfx::Rect(size), // visible_rect
95 size.width(), // y_stride 95 size, // natural_size
96 size.width() / 2, // u_stride 96 size.width(), // y_stride
97 size.width() / 2, // v_stride 97 size.width() / 2, // u_stride
98 y_data, // y_data 98 size.width() / 2, // v_stride
99 u_data, // u_data 99 y_data, // y_data
100 v_data, // v_data 100 u_data, // u_data
101 base::TimeDelta()); // timestamp 101 v_data, // v_data
102 base::TimeDelta()); // timestamp
103 EXPECT_NE(nullptr, video_frame.get());
DaleCurtis 2016/01/14 23:27:04 EXPECT_TRUE like you've used in most other places.
emircan 2016/01/15 00:28:28 Done.
104 return video_frame;
102 } 105 }
103 106
104 static void ReleaseMailboxCB(const gpu::SyncToken& sync_token) {} 107 static void ReleaseMailboxCB(const gpu::SyncToken& sync_token) {}
105 108
106 scoped_refptr<media::VideoFrame> CreateTestRGBAHardwareVideoFrame() { 109 scoped_refptr<media::VideoFrame> CreateTestRGBAHardwareVideoFrame() {
107 const int kDimension = 10; 110 const int kDimension = 10;
108 gfx::Size size(kDimension, kDimension); 111 gfx::Size size(kDimension, kDimension);
109 112
110 gpu::Mailbox mailbox; 113 gpu::Mailbox mailbox;
111 mailbox.name[0] = 51; 114 mailbox.name[0] = 51;
112 115
113 const gpu::SyncToken sync_token(7); 116 const gpu::SyncToken sync_token(7);
114 const unsigned target = GL_TEXTURE_2D; 117 const unsigned target = GL_TEXTURE_2D;
115 return media::VideoFrame::WrapNativeTexture( 118 scoped_refptr<media::VideoFrame> video_frame =
116 media::PIXEL_FORMAT_ARGB, 119 media::VideoFrame::WrapNativeTexture(
117 gpu::MailboxHolder(mailbox, sync_token, target), 120 media::PIXEL_FORMAT_ARGB,
118 base::Bind(&ReleaseMailboxCB), 121 gpu::MailboxHolder(mailbox, sync_token, target),
119 size, // coded_size 122 base::Bind(&ReleaseMailboxCB),
120 gfx::Rect(size), // visible_rect 123 size, // coded_size
121 size, // natural_size 124 gfx::Rect(size), // visible_rect
122 base::TimeDelta()); // timestamp 125 size, // natural_size
126 base::TimeDelta()); // timestamp
127 EXPECT_NE(nullptr, video_frame.get());
DaleCurtis 2016/01/14 23:27:04 EXPECT_TRUE, remove get.
emircan 2016/01/15 00:28:27 Done.
128 return video_frame;
123 } 129 }
124 130
125 scoped_refptr<media::VideoFrame> CreateTestYUVHardareVideoFrame() { 131 scoped_refptr<media::VideoFrame> CreateTestYUVHardareVideoFrame() {
126 const int kDimension = 10; 132 const int kDimension = 10;
127 gfx::Size size(kDimension, kDimension); 133 gfx::Size size(kDimension, kDimension);
128 134
129 const int kPlanesNum = 3; 135 const int kPlanesNum = 3;
130 gpu::Mailbox mailbox[kPlanesNum]; 136 gpu::Mailbox mailbox[kPlanesNum];
131 for (int i = 0; i < kPlanesNum; ++i) { 137 for (int i = 0; i < kPlanesNum; ++i) {
132 mailbox[i].name[0] = 50 + 1; 138 mailbox[i].name[0] = 50 + 1;
133 } 139 }
134 const gpu::SyncToken sync_token(7); 140 const gpu::SyncToken sync_token(7);
135 const unsigned target = GL_TEXTURE_RECTANGLE_ARB; 141 const unsigned target = GL_TEXTURE_RECTANGLE_ARB;
136 return media::VideoFrame::WrapYUV420NativeTextures( 142 scoped_refptr<media::VideoFrame> video_frame =
137 gpu::MailboxHolder(mailbox[media::VideoFrame::kYPlane], sync_token, 143 media::VideoFrame::WrapYUV420NativeTextures(
138 target), 144 gpu::MailboxHolder(mailbox[media::VideoFrame::kYPlane], sync_token,
139 gpu::MailboxHolder(mailbox[media::VideoFrame::kUPlane], sync_token, 145 target),
140 target), 146 gpu::MailboxHolder(mailbox[media::VideoFrame::kUPlane], sync_token,
141 gpu::MailboxHolder(mailbox[media::VideoFrame::kVPlane], sync_token, 147 target),
142 target), 148 gpu::MailboxHolder(mailbox[media::VideoFrame::kVPlane], sync_token,
143 base::Bind(&ReleaseMailboxCB), 149 target),
144 size, // coded_size 150 base::Bind(&ReleaseMailboxCB),
145 gfx::Rect(size), // visible_rect 151 size, // coded_size
146 size, // natural_size 152 gfx::Rect(size), // visible_rect
147 base::TimeDelta()); // timestamp 153 size, // natural_size
154 base::TimeDelta()); // timestamp
155 EXPECT_NE(nullptr, video_frame.get());
DaleCurtis 2016/01/14 23:27:04 EXPECT_TRUE, remove get.
emircan 2016/01/15 00:28:28 Done.
156 return video_frame;
148 } 157 }
149 158
150 WebGraphicsContext3DUploadCounter* context3d_; 159 WebGraphicsContext3DUploadCounter* context3d_;
151 FakeOutputSurfaceClient client_; 160 FakeOutputSurfaceClient client_;
152 scoped_ptr<FakeOutputSurface> output_surface3d_; 161 scoped_ptr<FakeOutputSurface> output_surface3d_;
153 scoped_ptr<FakeOutputSurface> output_surface_software_; 162 scoped_ptr<FakeOutputSurface> output_surface_software_;
154 scoped_ptr<SharedBitmapManagerAllocationCounter> shared_bitmap_manager_; 163 scoped_ptr<SharedBitmapManagerAllocationCounter> shared_bitmap_manager_;
155 scoped_ptr<ResourceProvider> resource_provider3d_; 164 scoped_ptr<ResourceProvider> resource_provider3d_;
156 scoped_ptr<ResourceProvider> resource_provider_software_; 165 scoped_ptr<ResourceProvider> resource_provider_software_;
157 }; 166 };
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 319
311 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame); 320 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame);
312 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); 321 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type);
313 EXPECT_TRUE(resources.read_lock_fences_enabled); 322 EXPECT_TRUE(resources.read_lock_fences_enabled);
314 EXPECT_EQ(3u, resources.mailboxes.size()); 323 EXPECT_EQ(3u, resources.mailboxes.size());
315 EXPECT_EQ(3u, resources.release_callbacks.size()); 324 EXPECT_EQ(3u, resources.release_callbacks.size());
316 EXPECT_EQ(0u, resources.software_resources.size()); 325 EXPECT_EQ(0u, resources.software_resources.size());
317 } 326 }
318 } // namespace 327 } // namespace
319 } // namespace cc 328 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698