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

Side by Side Diff: cc/resource_provider_unittest.cc

Issue 11368043: cc: Avoid using upload term in relation to resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « cc/resource_provider.cc ('k') | cc/resource_update_controller.cc » ('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 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/resource_provider.h" 7 #include "cc/resource_provider.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "cc/graphics_context.h" 10 #include "cc/graphics_context.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 WGC3Denum format = GL_RGBA; 312 WGC3Denum format = GL_RGBA;
313 int pool = 1; 313 int pool = 1;
314 size_t pixelSize = textureSize(size, format); 314 size_t pixelSize = textureSize(size, format);
315 ASSERT_EQ(4U, pixelSize); 315 ASSERT_EQ(4U, pixelSize);
316 316
317 ResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, s ize, format, ResourceProvider::TextureUsageAny); 317 ResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, s ize, format, ResourceProvider::TextureUsageAny);
318 expectNumResources(1); 318 expectNumResources(1);
319 319
320 uint8_t data[4] = {1, 2, 3, 4}; 320 uint8_t data[4] = {1, 2, 3, 4};
321 gfx::Rect rect(gfx::Point(), size); 321 gfx::Rect rect(gfx::Point(), size);
322 m_resourceProvider->upload(id, data, rect, rect, gfx::Vector2d()); 322 m_resourceProvider->setPixels(id, data, rect, rect, gfx::Vector2d());
323 323
324 uint8_t result[4] = {0}; 324 uint8_t result[4] = {0};
325 getResourcePixels(id, size, format, result); 325 getResourcePixels(id, size, format, result);
326 EXPECT_EQ(0, memcmp(data, result, pixelSize)); 326 EXPECT_EQ(0, memcmp(data, result, pixelSize));
327 327
328 m_resourceProvider->deleteResource(id); 328 m_resourceProvider->deleteResource(id);
329 expectNumResources(0); 329 expectNumResources(0);
330 } 330 }
331 331
332 TEST_P(ResourceProviderTest, DeleteOwnedResources) 332 TEST_P(ResourceProviderTest, DeleteOwnedResources)
(...skipping 19 matching lines...) Expand all
352 gfx::Size size(2, 2); 352 gfx::Size size(2, 2);
353 WGC3Denum format = GL_RGBA; 353 WGC3Denum format = GL_RGBA;
354 int pool = 1; 354 int pool = 1;
355 size_t pixelSize = textureSize(size, format); 355 size_t pixelSize = textureSize(size, format);
356 ASSERT_EQ(16U, pixelSize); 356 ASSERT_EQ(16U, pixelSize);
357 357
358 ResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, s ize, format, ResourceProvider::TextureUsageAny); 358 ResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, s ize, format, ResourceProvider::TextureUsageAny);
359 359
360 uint8_t image[16] = {0}; 360 uint8_t image[16] = {0};
361 gfx::Rect imageRect(gfx::Point(), size); 361 gfx::Rect imageRect(gfx::Point(), size);
362 m_resourceProvider->upload(id, image, imageRect, imageRect, gfx::Vector2d()) ; 362 m_resourceProvider->setPixels(id, image, imageRect, imageRect, gfx::Vector2d ());
363 363
364 for (uint8_t i = 0 ; i < pixelSize; ++i) 364 for (uint8_t i = 0 ; i < pixelSize; ++i)
365 image[i] = i; 365 image[i] = i;
366 366
367 uint8_t result[16] = {0}; 367 uint8_t result[16] = {0};
368 { 368 {
369 gfx::Rect sourceRect(0, 0, 1, 1); 369 gfx::Rect sourceRect(0, 0, 1, 1);
370 gfx::Vector2d destOffset(0, 0); 370 gfx::Vector2d destOffset(0, 0);
371 m_resourceProvider->upload(id, image, imageRect, sourceRect, destOffset) ; 371 m_resourceProvider->setPixels(id, image, imageRect, sourceRect, destOffs et);
372 372
373 uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0, 373 uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0,
374 0, 0, 0, 0, 0, 0, 0, 0}; 374 0, 0, 0, 0, 0, 0, 0, 0};
375 getResourcePixels(id, size, format, result); 375 getResourcePixels(id, size, format, result);
376 EXPECT_EQ(0, memcmp(expected, result, pixelSize)); 376 EXPECT_EQ(0, memcmp(expected, result, pixelSize));
377 } 377 }
378 { 378 {
379 gfx::Rect sourceRect(0, 0, 1, 1); 379 gfx::Rect sourceRect(0, 0, 1, 1);
380 gfx::Vector2d destOffset(1, 1); 380 gfx::Vector2d destOffset(1, 1);
381 m_resourceProvider->upload(id, image, imageRect, sourceRect, destOffset) ; 381 m_resourceProvider->setPixels(id, image, imageRect, sourceRect, destOffs et);
382 382
383 uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0, 383 uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0,
384 0, 0, 0, 0, 0, 1, 2, 3}; 384 0, 0, 0, 0, 0, 1, 2, 3};
385 getResourcePixels(id, size, format, result); 385 getResourcePixels(id, size, format, result);
386 EXPECT_EQ(0, memcmp(expected, result, pixelSize)); 386 EXPECT_EQ(0, memcmp(expected, result, pixelSize));
387 } 387 }
388 { 388 {
389 gfx::Rect sourceRect(1, 0, 1, 1); 389 gfx::Rect sourceRect(1, 0, 1, 1);
390 gfx::Vector2d destOffset(0, 1); 390 gfx::Vector2d destOffset(0, 1);
391 m_resourceProvider->upload(id, image, imageRect, sourceRect, destOffset) ; 391 m_resourceProvider->setPixels(id, image, imageRect, sourceRect, destOffs et);
392 392
393 uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0, 393 uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0,
394 4, 5, 6, 7, 0, 1, 2, 3}; 394 4, 5, 6, 7, 0, 1, 2, 3};
395 getResourcePixels(id, size, format, result); 395 getResourcePixels(id, size, format, result);
396 EXPECT_EQ(0, memcmp(expected, result, pixelSize)); 396 EXPECT_EQ(0, memcmp(expected, result, pixelSize));
397 } 397 }
398 { 398 {
399 gfx::Rect offsetImageRect(gfx::Point(100, 100), size); 399 gfx::Rect offsetImageRect(gfx::Point(100, 100), size);
400 gfx::Rect sourceRect(100, 100, 1, 1); 400 gfx::Rect sourceRect(100, 100, 1, 1);
401 gfx::Vector2d destOffset(1, 0); 401 gfx::Vector2d destOffset(1, 0);
402 m_resourceProvider->upload(id, image, offsetImageRect, sourceRect, destO ffset); 402 m_resourceProvider->setPixels(id, image, offsetImageRect, sourceRect, de stOffset);
403 403
404 uint8_t expected[16] = {0, 1, 2, 3, 0, 1, 2, 3, 404 uint8_t expected[16] = {0, 1, 2, 3, 0, 1, 2, 3,
405 4, 5, 6, 7, 0, 1, 2, 3}; 405 4, 5, 6, 7, 0, 1, 2, 3};
406 getResourcePixels(id, size, format, result); 406 getResourcePixels(id, size, format, result);
407 EXPECT_EQ(0, memcmp(expected, result, pixelSize)); 407 EXPECT_EQ(0, memcmp(expected, result, pixelSize));
408 } 408 }
409 409
410 410
411 m_resourceProvider->deleteResource(id); 411 m_resourceProvider->deleteResource(id);
412 } 412 }
413 413
414 TEST_P(ResourceProviderTest, TransferResources) 414 TEST_P(ResourceProviderTest, TransferResources)
415 { 415 {
416 // Resource transfer is only supported with GL textures for now. 416 // Resource transfer is only supported with GL textures for now.
417 if (GetParam() != ResourceProvider::GLTexture) 417 if (GetParam() != ResourceProvider::GLTexture)
418 return; 418 return;
419 419
420 scoped_ptr<GraphicsContext> childContext(FakeWebCompositorOutputSurface::cre ate(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphi csContext3D>())); 420 scoped_ptr<GraphicsContext> childContext(FakeWebCompositorOutputSurface::cre ate(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphi csContext3D>()));
421 scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create( childContext.get())); 421 scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create( childContext.get()));
422 422
423 gfx::Size size(1, 1); 423 gfx::Size size(1, 1);
424 WGC3Denum format = GL_RGBA; 424 WGC3Denum format = GL_RGBA;
425 int pool = 1; 425 int pool = 1;
426 size_t pixelSize = textureSize(size, format); 426 size_t pixelSize = textureSize(size, format);
427 ASSERT_EQ(4U, pixelSize); 427 ASSERT_EQ(4U, pixelSize);
428 428
429 ResourceProvider::ResourceId id1 = childResourceProvider->createResource(poo l, size, format, ResourceProvider::TextureUsageAny); 429 ResourceProvider::ResourceId id1 = childResourceProvider->createResource(poo l, size, format, ResourceProvider::TextureUsageAny);
430 uint8_t data1[4] = {1, 2, 3, 4}; 430 uint8_t data1[4] = {1, 2, 3, 4};
431 gfx::Rect rect(gfx::Point(), size); 431 gfx::Rect rect(gfx::Point(), size);
432 childResourceProvider->upload(id1, data1, rect, rect, gfx::Vector2d()); 432 childResourceProvider->setPixels(id1, data1, rect, rect, gfx::Vector2d());
433 433
434 ResourceProvider::ResourceId id2 = childResourceProvider->createResource(poo l, size, format, ResourceProvider::TextureUsageAny); 434 ResourceProvider::ResourceId id2 = childResourceProvider->createResource(poo l, size, format, ResourceProvider::TextureUsageAny);
435 uint8_t data2[4] = {5, 5, 5, 5}; 435 uint8_t data2[4] = {5, 5, 5, 5};
436 childResourceProvider->upload(id2, data2, rect, rect, gfx::Vector2d()); 436 childResourceProvider->setPixels(id2, data2, rect, rect, gfx::Vector2d());
437 437
438 int childPool = 2; 438 int childPool = 2;
439 int childId = m_resourceProvider->createChild(childPool); 439 int childId = m_resourceProvider->createChild(childPool);
440 440
441 { 441 {
442 // Transfer some resources to the parent. 442 // Transfer some resources to the parent.
443 ResourceProvider::ResourceIdArray resourceIdsToTransfer; 443 ResourceProvider::ResourceIdArray resourceIdsToTransfer;
444 resourceIdsToTransfer.push_back(id1); 444 resourceIdsToTransfer.push_back(id1);
445 resourceIdsToTransfer.push_back(id2); 445 resourceIdsToTransfer.push_back(id2);
446 ResourceProvider::TransferableResourceList list = childResourceProvider- >prepareSendToParent(resourceIdsToTransfer); 446 ResourceProvider::TransferableResourceList list = childResourceProvider- >prepareSendToParent(resourceIdsToTransfer);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 539
540 gfx::Size size(1, 1); 540 gfx::Size size(1, 1);
541 WGC3Denum format = GL_RGBA; 541 WGC3Denum format = GL_RGBA;
542 int pool = 1; 542 int pool = 1;
543 size_t pixelSize = textureSize(size, format); 543 size_t pixelSize = textureSize(size, format);
544 ASSERT_EQ(4U, pixelSize); 544 ASSERT_EQ(4U, pixelSize);
545 545
546 ResourceProvider::ResourceId id = childResourceProvider->createResource(pool , size, format, ResourceProvider::TextureUsageAny); 546 ResourceProvider::ResourceId id = childResourceProvider->createResource(pool , size, format, ResourceProvider::TextureUsageAny);
547 uint8_t data[4] = {1, 2, 3, 4}; 547 uint8_t data[4] = {1, 2, 3, 4};
548 gfx::Rect rect(gfx::Point(), size); 548 gfx::Rect rect(gfx::Point(), size);
549 childResourceProvider->upload(id, data, rect, rect, gfx::Vector2d()); 549 childResourceProvider->setPixels(id, data, rect, rect, gfx::Vector2d());
550 550
551 int childPool = 2; 551 int childPool = 2;
552 int childId = m_resourceProvider->createChild(childPool); 552 int childId = m_resourceProvider->createChild(childPool);
553 553
554 { 554 {
555 // Transfer some resource to the parent. 555 // Transfer some resource to the parent.
556 ResourceProvider::ResourceIdArray resourceIdsToTransfer; 556 ResourceProvider::ResourceIdArray resourceIdsToTransfer;
557 resourceIdsToTransfer.push_back(id); 557 resourceIdsToTransfer.push_back(id);
558 ResourceProvider::TransferableResourceList list = childResourceProvider- >prepareSendToParent(resourceIdsToTransfer); 558 ResourceProvider::TransferableResourceList list = childResourceProvider- >prepareSendToParent(resourceIdsToTransfer);
559 EXPECT_NE(0u, list.syncPoint); 559 EXPECT_NE(0u, list.syncPoint);
(...skipping 20 matching lines...) Expand all
580 } 580 }
581 EXPECT_EQ(0u, childResourceProvider->numResources()); 581 EXPECT_EQ(0u, childResourceProvider->numResources());
582 } 582 }
583 583
584 INSTANTIATE_TEST_CASE_P(ResourceProviderTests, 584 INSTANTIATE_TEST_CASE_P(ResourceProviderTests,
585 ResourceProviderTest, 585 ResourceProviderTest,
586 ::testing::Values(ResourceProvider::GLTexture, 586 ::testing::Values(ResourceProvider::GLTexture,
587 ResourceProvider::Bitmap)); 587 ResourceProvider::Bitmap));
588 588
589 } // namespace 589 } // namespace
OLDNEW
« no previous file with comments | « cc/resource_provider.cc ('k') | cc/resource_update_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698