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

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

Issue 210413003: Drop software resources sent to a GL delegated renderer. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; 1160 ResourceProvider::ResourceId mapped_id1 = resource_map[id1];
1161 EXPECT_EQ(0u, mapped_id1); 1161 EXPECT_EQ(0u, mapped_id1);
1162 1162
1163 resource_provider_->DestroyChild(child_id); 1163 resource_provider_->DestroyChild(child_id);
1164 EXPECT_EQ(0u, resource_provider_->num_resources()); 1164 EXPECT_EQ(0u, resource_provider_->num_resources());
1165 1165
1166 ASSERT_EQ(1u, returned_to_child.size()); 1166 ASSERT_EQ(1u, returned_to_child.size());
1167 EXPECT_FALSE(returned_to_child[0].lost); 1167 EXPECT_FALSE(returned_to_child[0].lost);
1168 } 1168 }
1169 1169
1170 TEST_P(ResourceProviderTest, TransferSoftwareToGL) {
1171 if (GetParam() != ResourceProvider::GLTexture)
1172 return;
1173
1174 scoped_ptr<ResourceProviderContext> child_context_owned(
1175 ResourceProviderContext::Create(shared_data_.get()));
1176
1177 FakeOutputSurfaceClient child_output_surface_client;
1178 scoped_ptr<FakeOutputSurface> child_output_surface =
1179 FakeOutputSurface::CreateSoftware(
1180 make_scoped_ptr(new SoftwareOutputDevice));
1181 FakeOutputSurfaceClient parent_output_surface_client;
1182 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1183
1184 scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create(
1185 child_output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1));
1186
1187 gfx::Size size(1, 1);
1188 ResourceFormat format = RGBA_8888;
1189 size_t pixel_size = TextureSizeBytes(size, format);
1190 ASSERT_EQ(4U, pixel_size);
1191
1192 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource(
1193 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
1194 uint8_t data1[4] = {1, 2, 3, 4};
1195 gfx::Rect rect(size);
1196 child_resource_provider->SetPixels(id1, data1, rect, rect, gfx::Vector2d());
1197
1198 ReturnedResourceArray returned_to_child;
1199 int child_id =
1200 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child));
1201 {
1202 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1203 resource_ids_to_transfer.push_back(id1);
1204 TransferableResourceArray list;
1205 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer,
1206 &list);
1207 ASSERT_EQ(1u, list.size());
1208 EXPECT_EQ(0u, list[0].mailbox_holder.sync_point);
1209 EXPECT_EQ(0u, list[0].mailbox_holder.texture_target);
1210 EXPECT_TRUE(child_resource_provider->InUseByConsumer(id1));
1211 resource_provider_->ReceiveFromChild(child_id, list);
1212 }
1213
1214 EXPECT_EQ(0u, resource_provider_->num_resources());
danakj 2014/03/25 21:12:47 Can you throw a comment in at each step in the tes
1215 ASSERT_EQ(1u, returned_to_child.size());
1216 EXPECT_EQ(returned_to_child[0].id, id1);
1217 ResourceProvider::ResourceIdMap resource_map =
1218 resource_provider_->GetChildToParentMap(child_id);
1219 ResourceProvider::ResourceId mapped_id1 = resource_map[id1];
1220 EXPECT_EQ(0u, mapped_id1);
1221
1222 resource_provider_->DestroyChild(child_id);
1223 EXPECT_EQ(0u, resource_provider_->num_resources());
1224
1225 ASSERT_EQ(1u, returned_to_child.size());
1226 EXPECT_FALSE(returned_to_child[0].lost);
1227 }
1228
1170 TEST_P(ResourceProviderTest, TransferInvalidSoftware) { 1229 TEST_P(ResourceProviderTest, TransferInvalidSoftware) {
1171 if (GetParam() != ResourceProvider::Bitmap) 1230 if (GetParam() != ResourceProvider::Bitmap)
1172 return; 1231 return;
1173 1232
1174 gfx::Size size(1, 1); 1233 gfx::Size size(1, 1);
1175 ResourceFormat format = RGBA_8888; 1234 ResourceFormat format = RGBA_8888;
1176 size_t pixel_size = TextureSizeBytes(size, format); 1235 size_t pixel_size = TextureSizeBytes(size, format);
1177 ASSERT_EQ(4U, pixel_size); 1236 ASSERT_EQ(4U, pixel_size);
1178 1237
1179 ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( 1238 ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource(
(...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after
3264 resource_provider->AllocateForTesting(id); 3323 resource_provider->AllocateForTesting(id);
3265 Mock::VerifyAndClearExpectations(context); 3324 Mock::VerifyAndClearExpectations(context);
3266 3325
3267 DCHECK_EQ(10u, context->PeekTextureId()); 3326 DCHECK_EQ(10u, context->PeekTextureId());
3268 resource_provider->DeleteResource(id); 3327 resource_provider->DeleteResource(id);
3269 } 3328 }
3270 } 3329 }
3271 3330
3272 } // namespace 3331 } // namespace
3273 } // namespace cc 3332 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698