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

Unified Diff: cc/resource_provider_unittest.cc

Issue 11266030: Use gfx:: Geometry types for the resource provider and layer updater classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: uint8 Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resource_provider.cc ('k') | cc/resource_update.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resource_provider_unittest.cc
diff --git a/cc/resource_provider_unittest.cc b/cc/resource_provider_unittest.cc
index 493991b647fdd46fea0bd68c578edcfb6f42c6a5..f3c852f9116a36016e759374190966c8f14eca2f 100644
--- a/cc/resource_provider_unittest.cc
+++ b/cc/resource_provider_unittest.cc
@@ -23,7 +23,7 @@ using namespace WebKit;
namespace {
-size_t textureSize(const IntSize& size, WGC3Denum format)
+size_t textureSize(const gfx::Size& size, WGC3Denum format)
{
unsigned int componentsPerPixel = 4;
unsigned int bytesPerComponent = 1;
@@ -31,14 +31,14 @@ size_t textureSize(const IntSize& size, WGC3Denum format)
}
struct Texture {
- Texture(const IntSize& size, WGC3Denum format)
+ Texture(const gfx::Size& size, WGC3Denum format)
: size(size)
, format(format)
, data(new uint8_t[textureSize(size, format)])
{
}
- IntSize size;
+ gfx::Size size;
WGC3Denum format;
scoped_array<uint8_t> data;
};
@@ -154,7 +154,7 @@ public:
default:
NOTREACHED();
}
- allocateTexture(IntSize(width, height), format);
+ allocateTexture(gfx::Size(width, height), format);
}
virtual void texImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Denum format, WGC3Denum type, const void* pixels)
@@ -165,7 +165,7 @@ public:
ASSERT_EQ(internalformat, format);
ASSERT_FALSE(border);
ASSERT_EQ(type, GL_UNSIGNED_BYTE);
- allocateTexture(IntSize(width, height), format);
+ allocateTexture(gfx::Size(width, height), format);
if (pixels)
setPixels(0, 0, width, height, pixels);
}
@@ -205,7 +205,7 @@ public:
m_textures.set(m_currentTexture, m_sharedData->consumeTexture(mailbox, m_lastWaitedSyncPoint));
}
- void getPixels(const IntSize& size, WGC3Denum format, uint8_t* pixels)
+ void getPixels(const gfx::Size& size, WGC3Denum format, uint8_t* pixels)
{
ASSERT_TRUE(m_currentTexture);
Texture* texture = m_textures.get(m_currentTexture);
@@ -229,7 +229,7 @@ protected:
{ }
private:
- void allocateTexture(const IntSize& size, WGC3Denum format)
+ void allocateTexture(const gfx::Size& size, WGC3Denum format)
{
ASSERT_TRUE(m_currentTexture);
m_textures.set(m_currentTexture, make_scoped_ptr(new Texture(size, format)));
@@ -243,9 +243,9 @@ private:
ASSERT_TRUE(xoffset >= 0 && xoffset+width <= texture->size.width());
ASSERT_TRUE(yoffset >= 0 && yoffset+height <= texture->size.height());
ASSERT_TRUE(pixels);
- size_t inPitch = textureSize(IntSize(width, 1), texture->format);
- size_t outPitch = textureSize(IntSize(texture->size.width(), 1), texture->format);
- uint8_t* dest = texture->data.get() + yoffset * outPitch + textureSize(IntSize(xoffset, 1), texture->format);
+ size_t inPitch = textureSize(gfx::Size(width, 1), texture->format);
+ size_t outPitch = textureSize(gfx::Size(texture->size.width(), 1), texture->format);
+ uint8_t* dest = texture->data.get() + yoffset * outPitch + textureSize(gfx::Size(xoffset, 1), texture->format);
const uint8_t* src = static_cast<const uint8_t*>(pixels);
for (int i = 0; i < height; ++i) {
memcpy(dest, src, inPitch);
@@ -279,7 +279,7 @@ public:
ResourceProviderContext* context() { return static_cast<ResourceProviderContext*>(m_context->context3D()); }
- void getResourcePixels(ResourceProvider::ResourceId id, const IntSize& size, WGC3Denum format, uint8_t* pixels)
+ void getResourcePixels(ResourceProvider::ResourceId id, const gfx::Size& size, WGC3Denum format, uint8_t* pixels)
{
if (GetParam() == ResourceProvider::GLTexture) {
ResourceProvider::ScopedReadLockGL lockGL(m_resourceProvider.get(), id);
@@ -308,7 +308,7 @@ protected:
TEST_P(ResourceProviderTest, Basic)
{
- IntSize size(1, 1);
+ gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
int pool = 1;
size_t pixelSize = textureSize(size, format);
@@ -318,8 +318,8 @@ TEST_P(ResourceProviderTest, Basic)
expectNumResources(1);
uint8_t data[4] = {1, 2, 3, 4};
- IntRect rect(IntPoint(), size);
- m_resourceProvider->upload(id, data, rect, rect, IntSize());
+ gfx::Rect rect(gfx::Point(), size);
+ m_resourceProvider->upload(id, data, rect, rect, gfx::Vector2d());
uint8_t result[4] = {0};
getResourcePixels(id, size, format, result);
@@ -331,7 +331,7 @@ TEST_P(ResourceProviderTest, Basic)
TEST_P(ResourceProviderTest, DeleteOwnedResources)
{
- IntSize size(1, 1);
+ gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
int pool = 1;
@@ -349,7 +349,7 @@ TEST_P(ResourceProviderTest, DeleteOwnedResources)
TEST_P(ResourceProviderTest, Upload)
{
- IntSize size(2, 2);
+ gfx::Size size(2, 2);
WGC3Denum format = GL_RGBA;
int pool = 1;
size_t pixelSize = textureSize(size, format);
@@ -358,16 +358,16 @@ TEST_P(ResourceProviderTest, Upload)
ResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, size, format, ResourceProvider::TextureUsageAny);
uint8_t image[16] = {0};
- IntRect imageRect(IntPoint(), size);
- m_resourceProvider->upload(id, image, imageRect, imageRect, IntSize());
+ gfx::Rect imageRect(gfx::Point(), size);
+ m_resourceProvider->upload(id, image, imageRect, imageRect, gfx::Vector2d());
for (uint8_t i = 0 ; i < pixelSize; ++i)
image[i] = i;
uint8_t result[16] = {0};
{
- IntRect sourceRect(0, 0, 1, 1);
- IntSize destOffset(0, 0);
+ gfx::Rect sourceRect(0, 0, 1, 1);
+ gfx::Vector2d destOffset(0, 0);
m_resourceProvider->upload(id, image, imageRect, sourceRect, destOffset);
uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0,
@@ -376,8 +376,8 @@ TEST_P(ResourceProviderTest, Upload)
EXPECT_EQ(0, memcmp(expected, result, pixelSize));
}
{
- IntRect sourceRect(0, 0, 1, 1);
- IntSize destOffset(1, 1);
+ gfx::Rect sourceRect(0, 0, 1, 1);
+ gfx::Vector2d destOffset(1, 1);
m_resourceProvider->upload(id, image, imageRect, sourceRect, destOffset);
uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0,
@@ -386,8 +386,8 @@ TEST_P(ResourceProviderTest, Upload)
EXPECT_EQ(0, memcmp(expected, result, pixelSize));
}
{
- IntRect sourceRect(1, 0, 1, 1);
- IntSize destOffset(0, 1);
+ gfx::Rect sourceRect(1, 0, 1, 1);
+ gfx::Vector2d destOffset(0, 1);
m_resourceProvider->upload(id, image, imageRect, sourceRect, destOffset);
uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0,
@@ -396,9 +396,9 @@ TEST_P(ResourceProviderTest, Upload)
EXPECT_EQ(0, memcmp(expected, result, pixelSize));
}
{
- IntRect offsetImageRect(IntPoint(100, 100), size);
- IntRect sourceRect(100, 100, 1, 1);
- IntSize destOffset(1, 0);
+ gfx::Rect offsetImageRect(gfx::Point(100, 100), size);
+ gfx::Rect sourceRect(100, 100, 1, 1);
+ gfx::Vector2d destOffset(1, 0);
m_resourceProvider->upload(id, image, offsetImageRect, sourceRect, destOffset);
uint8_t expected[16] = {0, 1, 2, 3, 0, 1, 2, 3,
@@ -420,7 +420,7 @@ TEST_P(ResourceProviderTest, TransferResources)
scoped_ptr<GraphicsContext> childContext(FakeWebCompositorOutputSurface::create(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>()));
scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create(childContext.get()));
- IntSize size(1, 1);
+ gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
int pool = 1;
size_t pixelSize = textureSize(size, format);
@@ -428,12 +428,12 @@ TEST_P(ResourceProviderTest, TransferResources)
ResourceProvider::ResourceId id1 = childResourceProvider->createResource(pool, size, format, ResourceProvider::TextureUsageAny);
uint8_t data1[4] = {1, 2, 3, 4};
- IntRect rect(IntPoint(), size);
- childResourceProvider->upload(id1, data1, rect, rect, IntSize());
+ gfx::Rect rect(gfx::Point(), size);
+ childResourceProvider->upload(id1, data1, rect, rect, gfx::Vector2d());
ResourceProvider::ResourceId id2 = childResourceProvider->createResource(pool, size, format, ResourceProvider::TextureUsageAny);
uint8_t data2[4] = {5, 5, 5, 5};
- childResourceProvider->upload(id2, data2, rect, rect, IntSize());
+ childResourceProvider->upload(id2, data2, rect, rect, gfx::Vector2d());
int childPool = 2;
int childId = m_resourceProvider->createChild(childPool);
@@ -537,7 +537,7 @@ TEST_P(ResourceProviderTest, DeleteTransferredResources)
scoped_ptr<GraphicsContext> childContext(FakeWebCompositorOutputSurface::create(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>()));
scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create(childContext.get()));
- IntSize size(1, 1);
+ gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
int pool = 1;
size_t pixelSize = textureSize(size, format);
@@ -545,8 +545,8 @@ TEST_P(ResourceProviderTest, DeleteTransferredResources)
ResourceProvider::ResourceId id = childResourceProvider->createResource(pool, size, format, ResourceProvider::TextureUsageAny);
uint8_t data[4] = {1, 2, 3, 4};
- IntRect rect(IntPoint(), size);
- childResourceProvider->upload(id, data, rect, rect, IntSize());
+ gfx::Rect rect(gfx::Point(), size);
+ childResourceProvider->upload(id, data, rect, rect, gfx::Vector2d());
int childPool = 2;
int childId = m_resourceProvider->createChild(childPool);
« no previous file with comments | « cc/resource_provider.cc ('k') | cc/resource_update.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698