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

Side by Side Diff: cc/resource_provider_unittest.cc

Issue 11150025: Patch from https://codereview.chromium.org/11111005/ without actual file deletes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/resource_provider.cc ('k') | cc/scoped_texture.h » ('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 "CCResourceProvider.h" 7 #include "CCResourceProvider.h"
8 8
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/khronos/GLES2/gl2ext.h"
9 #include "CCGraphicsContext.h" 11 #include "CCGraphicsContext.h"
10 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread 12 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread
11 #include "CompositorFakeWebGraphicsContext3D.h" 13 #include "CompositorFakeWebGraphicsContext3D.h"
12 #include "Extensions3DChromium.h"
13 #include "FakeWebCompositorOutputSurface.h" 14 #include "FakeWebCompositorOutputSurface.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include <public/WebGraphicsContext3D.h> 15 #include <public/WebGraphicsContext3D.h>
16 #include <wtf/HashMap.h> 16 #include <wtf/HashMap.h>
17 #include <wtf/OwnArrayPtr.h> 17 #include <wtf/OwnArrayPtr.h>
18 #include <wtf/OwnPtr.h> 18 #include <wtf/OwnPtr.h>
19 19
20 using namespace cc; 20 using namespace cc;
21 using namespace WebKit; 21 using namespace WebKit;
22 22
23 namespace { 23 namespace {
24 24
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return syncPoint; 109 return syncPoint;
110 } 110 }
111 111
112 virtual void waitSyncPoint(unsigned syncPoint) 112 virtual void waitSyncPoint(unsigned syncPoint)
113 { 113 {
114 m_lastWaitedSyncPoint = std::max(syncPoint, m_lastWaitedSyncPoint); 114 m_lastWaitedSyncPoint = std::max(syncPoint, m_lastWaitedSyncPoint);
115 } 115 }
116 116
117 virtual void bindTexture(WGC3Denum target, WebGLId texture) 117 virtual void bindTexture(WGC3Denum target, WebGLId texture)
118 { 118 {
119 ASSERT(target == GraphicsContext3D::TEXTURE_2D); 119 ASSERT(target == GL_TEXTURE_2D);
120 ASSERT(!texture || m_textures.find(texture) != m_textures.end()); 120 ASSERT(!texture || m_textures.find(texture) != m_textures.end());
121 m_currentTexture = texture; 121 m_currentTexture = texture;
122 } 122 }
123 123
124 virtual WebGLId createTexture() 124 virtual WebGLId createTexture()
125 { 125 {
126 WebGLId id = CompositorFakeWebGraphicsContext3D::createTexture(); 126 WebGLId id = CompositorFakeWebGraphicsContext3D::createTexture();
127 m_textures.add(id, nullptr); 127 m_textures.add(id, nullptr);
128 return id; 128 return id;
129 } 129 }
130 130
131 virtual void deleteTexture(WebGLId id) 131 virtual void deleteTexture(WebGLId id)
132 { 132 {
133 TextureMap::iterator it = m_textures.find(id); 133 TextureMap::iterator it = m_textures.find(id);
134 ASSERT(it != m_textures.end()); 134 ASSERT(it != m_textures.end());
135 m_textures.remove(it); 135 m_textures.remove(it);
136 if (m_currentTexture == id) 136 if (m_currentTexture == id)
137 m_currentTexture = 0; 137 m_currentTexture = 0;
138 } 138 }
139 139
140 virtual void texStorage2DEXT(WGC3Denum target, WGC3Dint levels, WGC3Duint in ternalformat, 140 virtual void texStorage2DEXT(WGC3Denum target, WGC3Dint levels, WGC3Duint in ternalformat,
141 WGC3Dint width, WGC3Dint height) 141 WGC3Dint width, WGC3Dint height)
142 { 142 {
143 ASSERT(m_currentTexture); 143 ASSERT(m_currentTexture);
144 ASSERT(target == GraphicsContext3D::TEXTURE_2D); 144 ASSERT(target == GL_TEXTURE_2D);
145 ASSERT(levels == 1); 145 ASSERT(levels == 1);
146 WGC3Denum format = GraphicsContext3D::RGBA; 146 WGC3Denum format = GL_RGBA;
147 switch (internalformat) { 147 switch (internalformat) {
148 case Extensions3D::RGBA8_OES: 148 case GL_RGBA8_OES:
149 break; 149 break;
150 case Extensions3DChromium::BGRA8_EXT: 150 case GL_BGRA8_EXT:
151 format = Extensions3D::BGRA_EXT; 151 format = GL_BGRA_EXT;
152 break; 152 break;
153 default: 153 default:
154 ASSERT_NOT_REACHED(); 154 ASSERT_NOT_REACHED();
155 } 155 }
156 allocateTexture(IntSize(width, height), format); 156 allocateTexture(IntSize(width, height), format);
157 } 157 }
158 158
159 virtual void texImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internal format, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Denum format, WGC3Denum type, const void* pixels) 159 virtual void texImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internal format, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Denum format, WGC3Denum type, const void* pixels)
160 { 160 {
161 ASSERT(m_currentTexture); 161 ASSERT(m_currentTexture);
162 ASSERT(target == GraphicsContext3D::TEXTURE_2D); 162 ASSERT(target == GL_TEXTURE_2D);
163 ASSERT(!level); 163 ASSERT(!level);
164 ASSERT(internalformat == format); 164 ASSERT(internalformat == format);
165 ASSERT(!border); 165 ASSERT(!border);
166 ASSERT(type == GraphicsContext3D::UNSIGNED_BYTE); 166 ASSERT(type == GL_UNSIGNED_BYTE);
167 allocateTexture(IntSize(width, height), format); 167 allocateTexture(IntSize(width, height), format);
168 if (pixels) 168 if (pixels)
169 setPixels(0, 0, width, height, pixels); 169 setPixels(0, 0, width, height, pixels);
170 } 170 }
171 171
172 virtual void texSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffse t, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3 Denum type, const void* pixels) 172 virtual void texSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffse t, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3 Denum type, const void* pixels)
173 { 173 {
174 ASSERT(m_currentTexture); 174 ASSERT(m_currentTexture);
175 ASSERT(target == GraphicsContext3D::TEXTURE_2D); 175 ASSERT(target == GL_TEXTURE_2D);
176 ASSERT(!level); 176 ASSERT(!level);
177 ASSERT(m_textures.get(m_currentTexture)); 177 ASSERT(m_textures.get(m_currentTexture));
178 ASSERT(m_textures.get(m_currentTexture)->format == format); 178 ASSERT(m_textures.get(m_currentTexture)->format == format);
179 ASSERT(type == GraphicsContext3D::UNSIGNED_BYTE); 179 ASSERT(type == GL_UNSIGNED_BYTE);
180 ASSERT(pixels); 180 ASSERT(pixels);
181 setPixels(xoffset, yoffset, width, height, pixels); 181 setPixels(xoffset, yoffset, width, height, pixels);
182 } 182 }
183 183
184 virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox) { return m_sharedData->g enMailbox(mailbox); } 184 virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox) { return m_sharedData->g enMailbox(mailbox); }
185 virtual void produceTextureCHROMIUM(WGC3Denum target, const WGC3Dbyte* mailb ox) 185 virtual void produceTextureCHROMIUM(WGC3Denum target, const WGC3Dbyte* mailb ox)
186 { 186 {
187 ASSERT(m_currentTexture); 187 ASSERT(m_currentTexture);
188 ASSERT(target == GraphicsContext3D::TEXTURE_2D); 188 ASSERT(target == GL_TEXTURE_2D);
189 189
190 // Delay movind the texture into the mailbox until the next 190 // Delay movind the texture into the mailbox until the next
191 // insertSyncPoint, so that it is not visible to other contexts that 191 // insertSyncPoint, so that it is not visible to other contexts that
192 // haven't waited on that sync point. 192 // haven't waited on that sync point.
193 OwnPtr<PendingProduceTexture> pending(adoptPtr(new PendingProduceTexture )); 193 OwnPtr<PendingProduceTexture> pending(adoptPtr(new PendingProduceTexture ));
194 memcpy(pending->mailbox, mailbox, sizeof(pending->mailbox)); 194 memcpy(pending->mailbox, mailbox, sizeof(pending->mailbox));
195 pending->texture = m_textures.take(m_currentTexture); 195 pending->texture = m_textures.take(m_currentTexture);
196 m_textures.set(m_currentTexture, nullptr); 196 m_textures.set(m_currentTexture, nullptr);
197 m_pendingProduceTextures.append(pending.release()); 197 m_pendingProduceTextures.append(pending.release());
198 } 198 }
199 199
200 virtual void consumeTextureCHROMIUM(WGC3Denum target, const WGC3Dbyte* mailb ox) 200 virtual void consumeTextureCHROMIUM(WGC3Denum target, const WGC3Dbyte* mailb ox)
201 { 201 {
202 ASSERT(m_currentTexture); 202 ASSERT(m_currentTexture);
203 ASSERT(target == GraphicsContext3D::TEXTURE_2D); 203 ASSERT(target == GL_TEXTURE_2D);
204 m_textures.set(m_currentTexture, m_sharedData->consumeTexture(mailbox, m _lastWaitedSyncPoint)); 204 m_textures.set(m_currentTexture, m_sharedData->consumeTexture(mailbox, m _lastWaitedSyncPoint));
205 } 205 }
206 206
207 void getPixels(const IntSize& size, WGC3Denum format, uint8_t* pixels) 207 void getPixels(const IntSize& size, WGC3Denum format, uint8_t* pixels)
208 { 208 {
209 ASSERT(m_currentTexture); 209 ASSERT(m_currentTexture);
210 Texture* texture = m_textures.get(m_currentTexture); 210 Texture* texture = m_textures.get(m_currentTexture);
211 ASSERT(texture); 211 ASSERT(texture);
212 ASSERT(texture->size == size); 212 ASSERT(texture->size == size);
213 ASSERT(texture->format == format); 213 ASSERT(texture->format == format);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 m_resourceProvider->setDefaultResourceType(GetParam()); 276 m_resourceProvider->setDefaultResourceType(GetParam());
277 } 277 }
278 278
279 ResourceProviderContext* context() { return static_cast<ResourceProviderCont ext*>(m_context->context3D()); } 279 ResourceProviderContext* context() { return static_cast<ResourceProviderCont ext*>(m_context->context3D()); }
280 280
281 void getResourcePixels(CCResourceProvider::ResourceId id, const IntSize& siz e, WGC3Denum format, uint8_t* pixels) 281 void getResourcePixels(CCResourceProvider::ResourceId id, const IntSize& siz e, WGC3Denum format, uint8_t* pixels)
282 { 282 {
283 if (GetParam() == CCResourceProvider::GLTexture) { 283 if (GetParam() == CCResourceProvider::GLTexture) {
284 CCResourceProvider::ScopedReadLockGL lockGL(m_resourceProvider.get() , id); 284 CCResourceProvider::ScopedReadLockGL lockGL(m_resourceProvider.get() , id);
285 ASSERT_NE(0U, lockGL.textureId()); 285 ASSERT_NE(0U, lockGL.textureId());
286 context()->bindTexture(GraphicsContext3D::TEXTURE_2D, lockGL.texture Id()); 286 context()->bindTexture(GL_TEXTURE_2D, lockGL.textureId());
287 context()->getPixels(size, format, pixels); 287 context()->getPixels(size, format, pixels);
288 } else if (GetParam() == CCResourceProvider::Bitmap) { 288 } else if (GetParam() == CCResourceProvider::Bitmap) {
289 CCResourceProvider::ScopedReadLockSoftware lockSoftware(m_resourcePr ovider.get(), id); 289 CCResourceProvider::ScopedReadLockSoftware lockSoftware(m_resourcePr ovider.get(), id);
290 memcpy(pixels, lockSoftware.skBitmap()->getPixels(), lockSoftware.sk Bitmap()->getSize()); 290 memcpy(pixels, lockSoftware.skBitmap()->getPixels(), lockSoftware.sk Bitmap()->getSize());
291 } 291 }
292 } 292 }
293 293
294 void expectNumResources(int count) 294 void expectNumResources(int count)
295 { 295 {
296 EXPECT_EQ(count, static_cast<int>(m_resourceProvider->numResources())); 296 EXPECT_EQ(count, static_cast<int>(m_resourceProvider->numResources()));
297 if (GetParam() == CCResourceProvider::GLTexture) 297 if (GetParam() == CCResourceProvider::GLTexture)
298 EXPECT_EQ(count, context()->textureCount()); 298 EXPECT_EQ(count, context()->textureCount());
299 } 299 }
300 300
301 protected: 301 protected:
302 DebugScopedSetImplThread implThread; 302 DebugScopedSetImplThread implThread;
303 OwnPtr<ContextSharedData> m_sharedData; 303 OwnPtr<ContextSharedData> m_sharedData;
304 scoped_ptr<CCGraphicsContext> m_context; 304 scoped_ptr<CCGraphicsContext> m_context;
305 OwnPtr<CCResourceProvider> m_resourceProvider; 305 OwnPtr<CCResourceProvider> m_resourceProvider;
306 }; 306 };
307 307
308 TEST_P(CCResourceProviderTest, Basic) 308 TEST_P(CCResourceProviderTest, Basic)
309 { 309 {
310 IntSize size(1, 1); 310 IntSize size(1, 1);
311 WGC3Denum format = GraphicsContext3D::RGBA; 311 WGC3Denum format = GL_RGBA;
312 int pool = 1; 312 int pool = 1;
313 size_t pixelSize = textureSize(size, format); 313 size_t pixelSize = textureSize(size, format);
314 ASSERT_EQ(4U, pixelSize); 314 ASSERT_EQ(4U, pixelSize);
315 315
316 CCResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, size, format, CCResourceProvider::TextureUsageAny); 316 CCResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, size, format, CCResourceProvider::TextureUsageAny);
317 expectNumResources(1); 317 expectNumResources(1);
318 318
319 uint8_t data[4] = {1, 2, 3, 4}; 319 uint8_t data[4] = {1, 2, 3, 4};
320 IntRect rect(IntPoint(), size); 320 IntRect rect(IntPoint(), size);
321 m_resourceProvider->upload(id, data, rect, rect, IntSize()); 321 m_resourceProvider->upload(id, data, rect, rect, IntSize());
322 322
323 uint8_t result[4] = {0}; 323 uint8_t result[4] = {0};
324 getResourcePixels(id, size, format, result); 324 getResourcePixels(id, size, format, result);
325 EXPECT_EQ(0, memcmp(data, result, pixelSize)); 325 EXPECT_EQ(0, memcmp(data, result, pixelSize));
326 326
327 m_resourceProvider->deleteResource(id); 327 m_resourceProvider->deleteResource(id);
328 expectNumResources(0); 328 expectNumResources(0);
329 } 329 }
330 330
331 TEST_P(CCResourceProviderTest, DeleteOwnedResources) 331 TEST_P(CCResourceProviderTest, DeleteOwnedResources)
332 { 332 {
333 IntSize size(1, 1); 333 IntSize size(1, 1);
334 WGC3Denum format = GraphicsContext3D::RGBA; 334 WGC3Denum format = GL_RGBA;
335 int pool = 1; 335 int pool = 1;
336 336
337 const int count = 3; 337 const int count = 3;
338 for (int i = 0; i < count; ++i) 338 for (int i = 0; i < count; ++i)
339 m_resourceProvider->createResource(pool, size, format, CCResourceProvide r::TextureUsageAny); 339 m_resourceProvider->createResource(pool, size, format, CCResourceProvide r::TextureUsageAny);
340 expectNumResources(3); 340 expectNumResources(3);
341 341
342 m_resourceProvider->deleteOwnedResources(pool+1); 342 m_resourceProvider->deleteOwnedResources(pool+1);
343 expectNumResources(3); 343 expectNumResources(3);
344 344
345 m_resourceProvider->deleteOwnedResources(pool); 345 m_resourceProvider->deleteOwnedResources(pool);
346 expectNumResources(0); 346 expectNumResources(0);
347 } 347 }
348 348
349 TEST_P(CCResourceProviderTest, Upload) 349 TEST_P(CCResourceProviderTest, Upload)
350 { 350 {
351 IntSize size(2, 2); 351 IntSize size(2, 2);
352 WGC3Denum format = GraphicsContext3D::RGBA; 352 WGC3Denum format = GL_RGBA;
353 int pool = 1; 353 int pool = 1;
354 size_t pixelSize = textureSize(size, format); 354 size_t pixelSize = textureSize(size, format);
355 ASSERT_EQ(16U, pixelSize); 355 ASSERT_EQ(16U, pixelSize);
356 356
357 CCResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, size, format, CCResourceProvider::TextureUsageAny); 357 CCResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, size, format, CCResourceProvider::TextureUsageAny);
358 358
359 uint8_t image[16] = {0}; 359 uint8_t image[16] = {0};
360 IntRect imageRect(IntPoint(), size); 360 IntRect imageRect(IntPoint(), size);
361 m_resourceProvider->upload(id, image, imageRect, imageRect, IntSize()); 361 m_resourceProvider->upload(id, image, imageRect, imageRect, IntSize());
362 362
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 TEST_P(CCResourceProviderTest, TransferResources) 413 TEST_P(CCResourceProviderTest, TransferResources)
414 { 414 {
415 // Resource transfer is only supported with GL textures for now. 415 // Resource transfer is only supported with GL textures for now.
416 if (GetParam() != CCResourceProvider::GLTexture) 416 if (GetParam() != CCResourceProvider::GLTexture)
417 return; 417 return;
418 418
419 scoped_ptr<CCGraphicsContext> childContext(FakeWebCompositorOutputSurface::c reate(ResourceProviderContext::create(m_sharedData.get()))); 419 scoped_ptr<CCGraphicsContext> childContext(FakeWebCompositorOutputSurface::c reate(ResourceProviderContext::create(m_sharedData.get())));
420 OwnPtr<CCResourceProvider> childResourceProvider(CCResourceProvider::create( childContext.get())); 420 OwnPtr<CCResourceProvider> childResourceProvider(CCResourceProvider::create( childContext.get()));
421 421
422 IntSize size(1, 1); 422 IntSize size(1, 1);
423 WGC3Denum format = GraphicsContext3D::RGBA; 423 WGC3Denum format = GL_RGBA;
424 int pool = 1; 424 int pool = 1;
425 size_t pixelSize = textureSize(size, format); 425 size_t pixelSize = textureSize(size, format);
426 ASSERT_EQ(4U, pixelSize); 426 ASSERT_EQ(4U, pixelSize);
427 427
428 CCResourceProvider::ResourceId id1 = childResourceProvider->createResource(p ool, size, format, CCResourceProvider::TextureUsageAny); 428 CCResourceProvider::ResourceId id1 = childResourceProvider->createResource(p ool, size, format, CCResourceProvider::TextureUsageAny);
429 uint8_t data1[4] = {1, 2, 3, 4}; 429 uint8_t data1[4] = {1, 2, 3, 4};
430 IntRect rect(IntPoint(), size); 430 IntRect rect(IntPoint(), size);
431 childResourceProvider->upload(id1, data1, rect, rect, IntSize()); 431 childResourceProvider->upload(id1, data1, rect, rect, IntSize());
432 432
433 CCResourceProvider::ResourceId id2 = childResourceProvider->createResource(p ool, size, format, CCResourceProvider::TextureUsageAny); 433 CCResourceProvider::ResourceId id2 = childResourceProvider->createResource(p ool, size, format, CCResourceProvider::TextureUsageAny);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 489 }
490 EXPECT_EQ(0u, m_resourceProvider->mailboxCount()); 490 EXPECT_EQ(0u, m_resourceProvider->mailboxCount());
491 EXPECT_EQ(2u, childResourceProvider->mailboxCount()); 491 EXPECT_EQ(2u, childResourceProvider->mailboxCount());
492 EXPECT_FALSE(childResourceProvider->inUseByConsumer(id1)); 492 EXPECT_FALSE(childResourceProvider->inUseByConsumer(id1));
493 EXPECT_FALSE(childResourceProvider->inUseByConsumer(id2)); 493 EXPECT_FALSE(childResourceProvider->inUseByConsumer(id2));
494 494
495 ResourceProviderContext* childContext3D = static_cast<ResourceProviderContex t*>(childContext->context3D()); 495 ResourceProviderContext* childContext3D = static_cast<ResourceProviderContex t*>(childContext->context3D());
496 { 496 {
497 CCResourceProvider::ScopedReadLockGL lock(childResourceProvider.get(), i d1); 497 CCResourceProvider::ScopedReadLockGL lock(childResourceProvider.get(), i d1);
498 ASSERT_NE(0U, lock.textureId()); 498 ASSERT_NE(0U, lock.textureId());
499 childContext3D->bindTexture(GraphicsContext3D::TEXTURE_2D, lock.textureI d()); 499 childContext3D->bindTexture(GL_TEXTURE_2D, lock.textureId());
500 childContext3D->getPixels(size, format, result); 500 childContext3D->getPixels(size, format, result);
501 EXPECT_EQ(0, memcmp(data1, result, pixelSize)); 501 EXPECT_EQ(0, memcmp(data1, result, pixelSize));
502 } 502 }
503 { 503 {
504 CCResourceProvider::ScopedReadLockGL lock(childResourceProvider.get(), i d2); 504 CCResourceProvider::ScopedReadLockGL lock(childResourceProvider.get(), i d2);
505 ASSERT_NE(0U, lock.textureId()); 505 ASSERT_NE(0U, lock.textureId());
506 childContext3D->bindTexture(GraphicsContext3D::TEXTURE_2D, lock.textureI d()); 506 childContext3D->bindTexture(GL_TEXTURE_2D, lock.textureId());
507 childContext3D->getPixels(size, format, result); 507 childContext3D->getPixels(size, format, result);
508 EXPECT_EQ(0, memcmp(data2, result, pixelSize)); 508 EXPECT_EQ(0, memcmp(data2, result, pixelSize));
509 } 509 }
510 510
511 { 511 {
512 // Transfer resources to the parent again. 512 // Transfer resources to the parent again.
513 CCResourceProvider::ResourceIdArray resourceIdsToTransfer; 513 CCResourceProvider::ResourceIdArray resourceIdsToTransfer;
514 resourceIdsToTransfer.append(id1); 514 resourceIdsToTransfer.append(id1);
515 resourceIdsToTransfer.append(id2); 515 resourceIdsToTransfer.append(id2);
516 CCResourceProvider::TransferableResourceList list = childResourceProvide r->prepareSendToParent(resourceIdsToTransfer); 516 CCResourceProvider::TransferableResourceList list = childResourceProvide r->prepareSendToParent(resourceIdsToTransfer);
(...skipping 13 matching lines...) Expand all
530 TEST_P(CCResourceProviderTest, DeleteTransferredResources) 530 TEST_P(CCResourceProviderTest, DeleteTransferredResources)
531 { 531 {
532 // Resource transfer is only supported with GL textures for now. 532 // Resource transfer is only supported with GL textures for now.
533 if (GetParam() != CCResourceProvider::GLTexture) 533 if (GetParam() != CCResourceProvider::GLTexture)
534 return; 534 return;
535 535
536 scoped_ptr<CCGraphicsContext> childContext(FakeWebCompositorOutputSurface::c reate(ResourceProviderContext::create(m_sharedData.get()))); 536 scoped_ptr<CCGraphicsContext> childContext(FakeWebCompositorOutputSurface::c reate(ResourceProviderContext::create(m_sharedData.get())));
537 OwnPtr<CCResourceProvider> childResourceProvider(CCResourceProvider::create( childContext.get())); 537 OwnPtr<CCResourceProvider> childResourceProvider(CCResourceProvider::create( childContext.get()));
538 538
539 IntSize size(1, 1); 539 IntSize size(1, 1);
540 WGC3Denum format = GraphicsContext3D::RGBA; 540 WGC3Denum format = GL_RGBA;
541 int pool = 1; 541 int pool = 1;
542 size_t pixelSize = textureSize(size, format); 542 size_t pixelSize = textureSize(size, format);
543 ASSERT_EQ(4U, pixelSize); 543 ASSERT_EQ(4U, pixelSize);
544 544
545 CCResourceProvider::ResourceId id = childResourceProvider->createResource(po ol, size, format, CCResourceProvider::TextureUsageAny); 545 CCResourceProvider::ResourceId id = childResourceProvider->createResource(po ol, size, format, CCResourceProvider::TextureUsageAny);
546 uint8_t data[4] = {1, 2, 3, 4}; 546 uint8_t data[4] = {1, 2, 3, 4};
547 IntRect rect(IntPoint(), size); 547 IntRect rect(IntPoint(), size);
548 childResourceProvider->upload(id, data, rect, rect, IntSize()); 548 childResourceProvider->upload(id, data, rect, rect, IntSize());
549 549
550 int childPool = 2; 550 int childPool = 2;
(...skipping 28 matching lines...) Expand all
579 } 579 }
580 EXPECT_EQ(0u, childResourceProvider->numResources()); 580 EXPECT_EQ(0u, childResourceProvider->numResources());
581 } 581 }
582 582
583 INSTANTIATE_TEST_CASE_P(CCResourceProviderTests, 583 INSTANTIATE_TEST_CASE_P(CCResourceProviderTests,
584 CCResourceProviderTest, 584 CCResourceProviderTest,
585 ::testing::Values(CCResourceProvider::GLTexture, 585 ::testing::Values(CCResourceProvider::GLTexture,
586 CCResourceProvider::Bitmap)); 586 CCResourceProvider::Bitmap));
587 587
588 } // namespace 588 } // namespace
OLDNEW
« no previous file with comments | « cc/resource_provider.cc ('k') | cc/scoped_texture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698