| OLD | NEW |
| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "cc/base/scoped_ptr_deque.h" | 15 #include "cc/base/scoped_ptr_deque.h" |
| 16 #include "cc/output/output_surface.h" | 16 #include "cc/output/output_surface.h" |
| 17 #include "cc/resources/returned_resource.h" | 17 #include "cc/resources/returned_resource.h" |
| 18 #include "cc/resources/shared_bitmap_manager.h" | 18 #include "cc/resources/shared_bitmap_manager.h" |
| 19 #include "cc/resources/single_release_callback.h" | 19 #include "cc/resources/single_release_callback.h" |
| 20 #include "cc/test/fake_output_surface.h" | 20 #include "cc/test/fake_output_surface.h" |
| 21 #include "cc/test/fake_output_surface_client.h" | 21 #include "cc/test/fake_output_surface_client.h" |
| 22 #include "cc/test/test_shared_bitmap_manager.h" |
| 22 #include "cc/test/test_texture.h" | 23 #include "cc/test/test_texture.h" |
| 23 #include "cc/test/test_web_graphics_context_3d.h" | 24 #include "cc/test/test_web_graphics_context_3d.h" |
| 24 #include "gpu/GLES2/gl2extchromium.h" | 25 #include "gpu/GLES2/gl2extchromium.h" |
| 25 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "third_party/khronos/GLES2/gl2.h" | 28 #include "third_party/khronos/GLES2/gl2.h" |
| 28 #include "third_party/khronos/GLES2/gl2ext.h" | 29 #include "third_party/khronos/GLES2/gl2ext.h" |
| 29 #include "ui/gfx/rect.h" | 30 #include "ui/gfx/rect.h" |
| 30 | 31 |
| 31 using testing::Mock; | 32 using testing::Mock; |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 struct PendingProduceTexture { | 326 struct PendingProduceTexture { |
| 326 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; | 327 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; |
| 327 scoped_refptr<TestTexture> texture; | 328 scoped_refptr<TestTexture> texture; |
| 328 }; | 329 }; |
| 329 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; | 330 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; |
| 330 ContextSharedData* shared_data_; | 331 ContextSharedData* shared_data_; |
| 331 GLuint last_waited_sync_point_; | 332 GLuint last_waited_sync_point_; |
| 332 PendingProduceTextureList pending_produce_textures_; | 333 PendingProduceTextureList pending_produce_textures_; |
| 333 }; | 334 }; |
| 334 | 335 |
| 335 void FreeSharedBitmap(SharedBitmap* shared_bitmap) { | |
| 336 delete shared_bitmap->memory(); | |
| 337 } | |
| 338 | |
| 339 void IgnoreSharedBitmap(SharedBitmap* shared_bitmap) {} | |
| 340 | |
| 341 class TestSharedBitmapManager : public SharedBitmapManager { | |
| 342 public: | |
| 343 TestSharedBitmapManager() : count_(0) {} | |
| 344 virtual ~TestSharedBitmapManager() {} | |
| 345 | |
| 346 virtual scoped_ptr<SharedBitmap> AllocateSharedBitmap(const gfx::Size& size) | |
| 347 OVERRIDE { | |
| 348 scoped_ptr<base::SharedMemory> memory(new base::SharedMemory); | |
| 349 memory->CreateAndMapAnonymous(size.GetArea() * 4); | |
| 350 int8 name[GL_MAILBOX_SIZE_CHROMIUM] = {0}; | |
| 351 name[0] = count_++; | |
| 352 SharedBitmapId id; | |
| 353 id.SetName(name); | |
| 354 bitmap_map_[id] = memory.get(); | |
| 355 return scoped_ptr<SharedBitmap>( | |
| 356 new SharedBitmap(memory.release(), id, base::Bind(&FreeSharedBitmap))); | |
| 357 } | |
| 358 | |
| 359 virtual scoped_ptr<SharedBitmap> GetSharedBitmapFromId( | |
| 360 const gfx::Size&, | |
| 361 const SharedBitmapId& id) OVERRIDE { | |
| 362 if (bitmap_map_.find(id) == bitmap_map_.end()) | |
| 363 return scoped_ptr<SharedBitmap>(); | |
| 364 return scoped_ptr<SharedBitmap>( | |
| 365 new SharedBitmap(bitmap_map_[id], id, base::Bind(&IgnoreSharedBitmap))); | |
| 366 } | |
| 367 | |
| 368 virtual scoped_ptr<SharedBitmap> GetBitmapForSharedMemory( | |
| 369 base::SharedMemory* memory) OVERRIDE { | |
| 370 int8 name[GL_MAILBOX_SIZE_CHROMIUM] = {0}; | |
| 371 name[0] = count_++; | |
| 372 SharedBitmapId id; | |
| 373 id.SetName(name); | |
| 374 bitmap_map_[id] = memory; | |
| 375 return scoped_ptr<SharedBitmap>( | |
| 376 new SharedBitmap(memory, id, base::Bind(&IgnoreSharedBitmap))); | |
| 377 } | |
| 378 | |
| 379 private: | |
| 380 int count_; | |
| 381 std::map<SharedBitmapId, base::SharedMemory*> bitmap_map_; | |
| 382 }; | |
| 383 | |
| 384 void GetResourcePixels(ResourceProvider* resource_provider, | 336 void GetResourcePixels(ResourceProvider* resource_provider, |
| 385 ResourceProviderContext* context, | 337 ResourceProviderContext* context, |
| 386 ResourceProvider::ResourceId id, | 338 ResourceProvider::ResourceId id, |
| 387 const gfx::Size& size, | 339 const gfx::Size& size, |
| 388 ResourceFormat format, | 340 ResourceFormat format, |
| 389 uint8_t* pixels) { | 341 uint8_t* pixels) { |
| 390 switch (resource_provider->default_resource_type()) { | 342 switch (resource_provider->default_resource_type()) { |
| 391 case ResourceProvider::GLTexture: { | 343 case ResourceProvider::GLTexture: { |
| 392 ResourceProvider::ScopedReadLockGL lock_gl(resource_provider, id); | 344 ResourceProvider::ScopedReadLockGL lock_gl(resource_provider, id); |
| 393 ASSERT_NE(0U, lock_gl.texture_id()); | 345 ASSERT_NE(0U, lock_gl.texture_id()); |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 return; | 1114 return; |
| 1163 | 1115 |
| 1164 scoped_ptr<ResourceProviderContext> child_context_owned( | 1116 scoped_ptr<ResourceProviderContext> child_context_owned( |
| 1165 ResourceProviderContext::Create(shared_data_.get())); | 1117 ResourceProviderContext::Create(shared_data_.get())); |
| 1166 | 1118 |
| 1167 FakeOutputSurfaceClient child_output_surface_client; | 1119 FakeOutputSurfaceClient child_output_surface_client; |
| 1168 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d( | 1120 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d( |
| 1169 child_context_owned.PassAs<TestWebGraphicsContext3D>())); | 1121 child_context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1170 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); | 1122 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); |
| 1171 | 1123 |
| 1172 scoped_ptr<ResourceProvider> child_resource_provider( | 1124 scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create( |
| 1173 ResourceProvider::Create(child_output_surface.get(), | 1125 child_output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 1174 NULL, | |
| 1175 0, | |
| 1176 false, | |
| 1177 1)); | |
| 1178 | 1126 |
| 1179 gfx::Size size(1, 1); | 1127 gfx::Size size(1, 1); |
| 1180 ResourceFormat format = RGBA_8888; | 1128 ResourceFormat format = RGBA_8888; |
| 1181 size_t pixel_size = TextureSizeBytes(size, format); | 1129 size_t pixel_size = TextureSizeBytes(size, format); |
| 1182 ASSERT_EQ(4U, pixel_size); | 1130 ASSERT_EQ(4U, pixel_size); |
| 1183 | 1131 |
| 1184 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource( | 1132 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource( |
| 1185 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 1133 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 1186 uint8_t data1[4] = { 1, 2, 3, 4 }; | 1134 uint8_t data1[4] = { 1, 2, 3, 4 }; |
| 1187 gfx::Rect rect(size); | 1135 gfx::Rect rect(size); |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 public: | 1587 public: |
| 1640 static void RunTest(GLenum child_filter, GLenum parent_filter) { | 1588 static void RunTest(GLenum child_filter, GLenum parent_filter) { |
| 1641 scoped_ptr<TextureStateTrackingContext> child_context_owned( | 1589 scoped_ptr<TextureStateTrackingContext> child_context_owned( |
| 1642 new TextureStateTrackingContext); | 1590 new TextureStateTrackingContext); |
| 1643 TextureStateTrackingContext* child_context = child_context_owned.get(); | 1591 TextureStateTrackingContext* child_context = child_context_owned.get(); |
| 1644 | 1592 |
| 1645 FakeOutputSurfaceClient child_output_surface_client; | 1593 FakeOutputSurfaceClient child_output_surface_client; |
| 1646 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d( | 1594 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d( |
| 1647 child_context_owned.PassAs<TestWebGraphicsContext3D>())); | 1595 child_context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1648 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); | 1596 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); |
| 1597 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 1598 new TestSharedBitmapManager()); |
| 1649 | 1599 |
| 1650 scoped_ptr<ResourceProvider> child_resource_provider( | 1600 scoped_ptr<ResourceProvider> child_resource_provider( |
| 1651 ResourceProvider::Create(child_output_surface.get(), | 1601 ResourceProvider::Create(child_output_surface.get(), |
| 1652 NULL, | 1602 shared_bitmap_manager.get(), |
| 1653 0, | 1603 0, |
| 1654 false, | 1604 false, |
| 1655 1)); | 1605 1)); |
| 1656 | 1606 |
| 1657 scoped_ptr<TextureStateTrackingContext> parent_context_owned( | 1607 scoped_ptr<TextureStateTrackingContext> parent_context_owned( |
| 1658 new TextureStateTrackingContext); | 1608 new TextureStateTrackingContext); |
| 1659 TextureStateTrackingContext* parent_context = parent_context_owned.get(); | 1609 TextureStateTrackingContext* parent_context = parent_context_owned.get(); |
| 1660 | 1610 |
| 1661 FakeOutputSurfaceClient parent_output_surface_client; | 1611 FakeOutputSurfaceClient parent_output_surface_client; |
| 1662 scoped_ptr<OutputSurface> parent_output_surface(FakeOutputSurface::Create3d( | 1612 scoped_ptr<OutputSurface> parent_output_surface(FakeOutputSurface::Create3d( |
| 1663 parent_context_owned.PassAs<TestWebGraphicsContext3D>())); | 1613 parent_context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1664 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); | 1614 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); |
| 1665 | 1615 |
| 1666 scoped_ptr<ResourceProvider> parent_resource_provider( | 1616 scoped_ptr<ResourceProvider> parent_resource_provider( |
| 1667 ResourceProvider::Create(parent_output_surface.get(), | 1617 ResourceProvider::Create(parent_output_surface.get(), |
| 1668 NULL, | 1618 shared_bitmap_manager.get(), |
| 1669 0, | 1619 0, |
| 1670 false, | 1620 false, |
| 1671 1)); | 1621 1)); |
| 1672 | 1622 |
| 1673 gfx::Size size(1, 1); | 1623 gfx::Size size(1, 1); |
| 1674 ResourceFormat format = RGBA_8888; | 1624 ResourceFormat format = RGBA_8888; |
| 1675 int child_texture_id = 1; | 1625 int child_texture_id = 1; |
| 1676 int parent_texture_id = 2; | 1626 int parent_texture_id = 2; |
| 1677 | 1627 |
| 1678 size_t pixel_size = TextureSizeBytes(size, format); | 1628 size_t pixel_size = TextureSizeBytes(size, format); |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2268 | 2218 |
| 2269 scoped_ptr<TextureStateTrackingContext> context_owned( | 2219 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 2270 new TextureStateTrackingContext); | 2220 new TextureStateTrackingContext); |
| 2271 TextureStateTrackingContext* context = context_owned.get(); | 2221 TextureStateTrackingContext* context = context_owned.get(); |
| 2272 | 2222 |
| 2273 FakeOutputSurfaceClient output_surface_client; | 2223 FakeOutputSurfaceClient output_surface_client; |
| 2274 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2224 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2275 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2225 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2276 CHECK(output_surface->BindToClient(&output_surface_client)); | 2226 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2277 | 2227 |
| 2278 scoped_ptr<ResourceProvider> resource_provider( | 2228 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2279 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2229 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2280 | 2230 |
| 2281 gfx::Size size(1, 1); | 2231 gfx::Size size(1, 1); |
| 2282 ResourceFormat format = RGBA_8888; | 2232 ResourceFormat format = RGBA_8888; |
| 2283 int texture_id = 1; | 2233 int texture_id = 1; |
| 2284 | 2234 |
| 2285 ResourceProvider::ResourceId id = resource_provider->CreateResource( | 2235 ResourceProvider::ResourceId id = resource_provider->CreateResource( |
| 2286 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2236 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 2287 | 2237 |
| 2288 // Check that the texture gets created with the right sampler settings. | 2238 // Check that the texture gets created with the right sampler settings. |
| 2289 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) | 2239 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2349 | 2299 |
| 2350 scoped_ptr<TextureStateTrackingContext> context_owned( | 2300 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 2351 new TextureStateTrackingContext); | 2301 new TextureStateTrackingContext); |
| 2352 TextureStateTrackingContext* context = context_owned.get(); | 2302 TextureStateTrackingContext* context = context_owned.get(); |
| 2353 | 2303 |
| 2354 FakeOutputSurfaceClient output_surface_client; | 2304 FakeOutputSurfaceClient output_surface_client; |
| 2355 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2305 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2356 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2306 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2357 CHECK(output_surface->BindToClient(&output_surface_client)); | 2307 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2358 | 2308 |
| 2359 scoped_ptr<ResourceProvider> resource_provider( | 2309 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2360 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2310 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2361 | 2311 |
| 2362 gfx::Size size(1, 1); | 2312 gfx::Size size(1, 1); |
| 2363 ResourceFormat format = RGBA_8888; | 2313 ResourceFormat format = RGBA_8888; |
| 2364 int texture_id = 1; | 2314 int texture_id = 1; |
| 2365 | 2315 |
| 2366 // Check that the texture gets created with the right sampler settings. | 2316 // Check that the texture gets created with the right sampler settings. |
| 2367 ResourceProvider::ResourceId id = resource_provider->CreateManagedResource( | 2317 ResourceProvider::ResourceId id = resource_provider->CreateManagedResource( |
| 2368 size, | 2318 size, |
| 2369 GL_TEXTURE_2D, | 2319 GL_TEXTURE_2D, |
| 2370 GL_CLAMP_TO_EDGE, | 2320 GL_CLAMP_TO_EDGE, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2398 | 2348 |
| 2399 scoped_ptr<TextureStateTrackingContext> context_owned( | 2349 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 2400 new TextureStateTrackingContext); | 2350 new TextureStateTrackingContext); |
| 2401 TextureStateTrackingContext* context = context_owned.get(); | 2351 TextureStateTrackingContext* context = context_owned.get(); |
| 2402 | 2352 |
| 2403 FakeOutputSurfaceClient output_surface_client; | 2353 FakeOutputSurfaceClient output_surface_client; |
| 2404 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2354 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2405 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2355 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2406 CHECK(output_surface->BindToClient(&output_surface_client)); | 2356 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2407 | 2357 |
| 2408 scoped_ptr<ResourceProvider> resource_provider( | 2358 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2409 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2359 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2410 | 2360 |
| 2411 gfx::Size size(1, 1); | 2361 gfx::Size size(1, 1); |
| 2412 ResourceFormat format = RGBA_8888; | 2362 ResourceFormat format = RGBA_8888; |
| 2413 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; | 2363 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; |
| 2414 | 2364 |
| 2415 for (int texture_id = 1; texture_id <= 2; ++texture_id) { | 2365 for (int texture_id = 1; texture_id <= 2; ++texture_id) { |
| 2416 GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT; | 2366 GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT; |
| 2417 // Check that the texture gets created with the right sampler settings. | 2367 // Check that the texture gets created with the right sampler settings. |
| 2418 ResourceProvider::ResourceId id = | 2368 ResourceProvider::ResourceId id = |
| 2419 resource_provider->CreateGLTexture(size, | 2369 resource_provider->CreateGLTexture(size, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2452 const uint32_t kBadBeef = 0xbadbeef; | 2402 const uint32_t kBadBeef = 0xbadbeef; |
| 2453 scoped_ptr<base::SharedMemory> shared_memory( | 2403 scoped_ptr<base::SharedMemory> shared_memory( |
| 2454 CreateAndFillSharedMemory(size, kBadBeef)); | 2404 CreateAndFillSharedMemory(size, kBadBeef)); |
| 2455 | 2405 |
| 2456 FakeOutputSurfaceClient output_surface_client; | 2406 FakeOutputSurfaceClient output_surface_client; |
| 2457 scoped_ptr<OutputSurface> output_surface( | 2407 scoped_ptr<OutputSurface> output_surface( |
| 2458 FakeOutputSurface::CreateSoftware(make_scoped_ptr( | 2408 FakeOutputSurface::CreateSoftware(make_scoped_ptr( |
| 2459 new SoftwareOutputDevice))); | 2409 new SoftwareOutputDevice))); |
| 2460 CHECK(output_surface->BindToClient(&output_surface_client)); | 2410 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2461 | 2411 |
| 2462 scoped_ptr<ResourceProvider> resource_provider( | 2412 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2463 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2413 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2464 | 2414 |
| 2465 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 2415 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
| 2466 base::Bind(&EmptyReleaseCallback)); | 2416 base::Bind(&EmptyReleaseCallback)); |
| 2467 TextureMailbox mailbox(shared_memory.get(), size); | 2417 TextureMailbox mailbox(shared_memory.get(), size); |
| 2468 | 2418 |
| 2469 ResourceProvider::ResourceId id = | 2419 ResourceProvider::ResourceId id = |
| 2470 resource_provider->CreateResourceFromTextureMailbox( | 2420 resource_provider->CreateResourceFromTextureMailbox( |
| 2471 mailbox, callback.Pass()); | 2421 mailbox, callback.Pass()); |
| 2472 EXPECT_NE(0u, id); | 2422 EXPECT_NE(0u, id); |
| 2473 | 2423 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2487 | 2437 |
| 2488 scoped_ptr<TextureStateTrackingContext> context_owned( | 2438 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 2489 new TextureStateTrackingContext); | 2439 new TextureStateTrackingContext); |
| 2490 TextureStateTrackingContext* context = context_owned.get(); | 2440 TextureStateTrackingContext* context = context_owned.get(); |
| 2491 | 2441 |
| 2492 FakeOutputSurfaceClient output_surface_client; | 2442 FakeOutputSurfaceClient output_surface_client; |
| 2493 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2443 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2494 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2444 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2495 CHECK(output_surface->BindToClient(&output_surface_client)); | 2445 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2496 | 2446 |
| 2497 scoped_ptr<ResourceProvider> resource_provider( | 2447 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2498 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2448 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2499 | 2449 |
| 2500 unsigned texture_id = 1; | 2450 unsigned texture_id = 1; |
| 2501 uint32 sync_point = 30; | 2451 uint32 sync_point = 30; |
| 2502 unsigned target = GL_TEXTURE_2D; | 2452 unsigned target = GL_TEXTURE_2D; |
| 2503 | 2453 |
| 2504 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2454 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
| 2505 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2455 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
| 2506 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2456 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
| 2507 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2457 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
| 2508 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); | 2458 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2551 | 2501 |
| 2552 scoped_ptr<TextureStateTrackingContext> context_owned( | 2502 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 2553 new TextureStateTrackingContext); | 2503 new TextureStateTrackingContext); |
| 2554 TextureStateTrackingContext* context = context_owned.get(); | 2504 TextureStateTrackingContext* context = context_owned.get(); |
| 2555 | 2505 |
| 2556 FakeOutputSurfaceClient output_surface_client; | 2506 FakeOutputSurfaceClient output_surface_client; |
| 2557 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2507 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2558 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2508 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2559 CHECK(output_surface->BindToClient(&output_surface_client)); | 2509 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2560 | 2510 |
| 2561 scoped_ptr<ResourceProvider> resource_provider( | 2511 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2562 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2512 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2563 | 2513 |
| 2564 unsigned texture_id = 1; | 2514 unsigned texture_id = 1; |
| 2565 uint32 sync_point = 30; | 2515 uint32 sync_point = 30; |
| 2566 unsigned target = GL_TEXTURE_EXTERNAL_OES; | 2516 unsigned target = GL_TEXTURE_EXTERNAL_OES; |
| 2567 | 2517 |
| 2568 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2518 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
| 2569 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2519 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
| 2570 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2520 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
| 2571 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2521 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
| 2572 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); | 2522 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2689 return; | 2639 return; |
| 2690 scoped_ptr<AllocationTrackingContext3D> context_owned( | 2640 scoped_ptr<AllocationTrackingContext3D> context_owned( |
| 2691 new StrictMock<AllocationTrackingContext3D>); | 2641 new StrictMock<AllocationTrackingContext3D>); |
| 2692 AllocationTrackingContext3D* context = context_owned.get(); | 2642 AllocationTrackingContext3D* context = context_owned.get(); |
| 2693 | 2643 |
| 2694 FakeOutputSurfaceClient output_surface_client; | 2644 FakeOutputSurfaceClient output_surface_client; |
| 2695 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2645 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2696 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2646 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2697 CHECK(output_surface->BindToClient(&output_surface_client)); | 2647 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2698 | 2648 |
| 2699 scoped_ptr<ResourceProvider> resource_provider( | 2649 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2700 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2650 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2701 | 2651 |
| 2702 gfx::Size size(2, 2); | 2652 gfx::Size size(2, 2); |
| 2703 gfx::Vector2d offset(0, 0); | 2653 gfx::Vector2d offset(0, 0); |
| 2704 gfx::Rect rect(0, 0, 2, 2); | 2654 gfx::Rect rect(0, 0, 2, 2); |
| 2705 ResourceFormat format = RGBA_8888; | 2655 ResourceFormat format = RGBA_8888; |
| 2706 ResourceProvider::ResourceId id = 0; | 2656 ResourceProvider::ResourceId id = 0; |
| 2707 uint8_t pixels[16] = { 0 }; | 2657 uint8_t pixels[16] = { 0 }; |
| 2708 int texture_id = 123; | 2658 int texture_id = 123; |
| 2709 | 2659 |
| 2710 // Lazy allocation. Don't allocate when creating the resource. | 2660 // Lazy allocation. Don't allocate when creating the resource. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2762 scoped_ptr<AllocationTrackingContext3D> context_owned( | 2712 scoped_ptr<AllocationTrackingContext3D> context_owned( |
| 2763 new StrictMock<AllocationTrackingContext3D>); | 2713 new StrictMock<AllocationTrackingContext3D>); |
| 2764 AllocationTrackingContext3D* context = context_owned.get(); | 2714 AllocationTrackingContext3D* context = context_owned.get(); |
| 2765 context->set_support_texture_storage(true); | 2715 context->set_support_texture_storage(true); |
| 2766 | 2716 |
| 2767 FakeOutputSurfaceClient output_surface_client; | 2717 FakeOutputSurfaceClient output_surface_client; |
| 2768 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2718 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2769 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2719 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2770 CHECK(output_surface->BindToClient(&output_surface_client)); | 2720 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2771 | 2721 |
| 2772 scoped_ptr<ResourceProvider> resource_provider( | 2722 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2773 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2723 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2774 | 2724 |
| 2775 gfx::Size size(2, 2); | 2725 gfx::Size size(2, 2); |
| 2776 ResourceFormat format = RGBA_8888; | 2726 ResourceFormat format = RGBA_8888; |
| 2777 ResourceProvider::ResourceId id = 0; | 2727 ResourceProvider::ResourceId id = 0; |
| 2778 int texture_id = 123; | 2728 int texture_id = 123; |
| 2779 | 2729 |
| 2780 // Lazy allocation. Don't allocate when creating the resource. | 2730 // Lazy allocation. Don't allocate when creating the resource. |
| 2781 id = resource_provider->CreateResource( | 2731 id = resource_provider->CreateResource( |
| 2782 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2732 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 2783 | 2733 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2799 scoped_ptr<AllocationTrackingContext3D> context_owned( | 2749 scoped_ptr<AllocationTrackingContext3D> context_owned( |
| 2800 new StrictMock<AllocationTrackingContext3D>); | 2750 new StrictMock<AllocationTrackingContext3D>); |
| 2801 AllocationTrackingContext3D* context = context_owned.get(); | 2751 AllocationTrackingContext3D* context = context_owned.get(); |
| 2802 context->set_support_texture_storage(true); | 2752 context->set_support_texture_storage(true); |
| 2803 | 2753 |
| 2804 FakeOutputSurfaceClient output_surface_client; | 2754 FakeOutputSurfaceClient output_surface_client; |
| 2805 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2755 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2806 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2756 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2807 CHECK(output_surface->BindToClient(&output_surface_client)); | 2757 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2808 | 2758 |
| 2809 scoped_ptr<ResourceProvider> resource_provider( | 2759 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2810 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2760 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2811 | 2761 |
| 2812 gfx::Size size(2, 2); | 2762 gfx::Size size(2, 2); |
| 2813 ResourceFormat format = RGBA_8888; | 2763 ResourceFormat format = RGBA_8888; |
| 2814 ResourceProvider::ResourceId id = 0; | 2764 ResourceProvider::ResourceId id = 0; |
| 2815 int texture_id = 123; | 2765 int texture_id = 123; |
| 2816 | 2766 |
| 2817 // Lazy allocation. Don't allocate when creating the resource. | 2767 // Lazy allocation. Don't allocate when creating the resource. |
| 2818 id = resource_provider->CreateResource( | 2768 id = resource_provider->CreateResource( |
| 2819 size, | 2769 size, |
| 2820 GL_CLAMP_TO_EDGE, | 2770 GL_CLAMP_TO_EDGE, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2842 FakeOutputSurfaceClient output_surface_client; | 2792 FakeOutputSurfaceClient output_surface_client; |
| 2843 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2793 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2844 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2794 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2845 CHECK(output_surface->BindToClient(&output_surface_client)); | 2795 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2846 | 2796 |
| 2847 gfx::Size size(2, 2); | 2797 gfx::Size size(2, 2); |
| 2848 ResourceFormat format = RGBA_8888; | 2798 ResourceFormat format = RGBA_8888; |
| 2849 ResourceProvider::ResourceId id = 0; | 2799 ResourceProvider::ResourceId id = 0; |
| 2850 int texture_id = 123; | 2800 int texture_id = 123; |
| 2851 | 2801 |
| 2852 scoped_ptr<ResourceProvider> resource_provider( | 2802 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2853 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2803 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2854 | 2804 |
| 2855 id = resource_provider->CreateResource( | 2805 id = resource_provider->CreateResource( |
| 2856 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2806 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 2857 resource_provider->AcquirePixelRasterBuffer(id); | 2807 resource_provider->AcquirePixelRasterBuffer(id); |
| 2858 | 2808 |
| 2859 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 2809 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
| 2860 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 2810 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
| 2861 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) | 2811 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) |
| 2862 .Times(1); | 2812 .Times(1); |
| 2863 resource_provider->BeginSetPixels(id); | 2813 resource_provider->BeginSetPixels(id); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2879 scoped_ptr<OutputSurface> output_surface( | 2829 scoped_ptr<OutputSurface> output_surface( |
| 2880 FakeOutputSurface::CreateSoftware(make_scoped_ptr( | 2830 FakeOutputSurface::CreateSoftware(make_scoped_ptr( |
| 2881 new SoftwareOutputDevice))); | 2831 new SoftwareOutputDevice))); |
| 2882 CHECK(output_surface->BindToClient(&output_surface_client)); | 2832 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2883 | 2833 |
| 2884 gfx::Size size(1, 1); | 2834 gfx::Size size(1, 1); |
| 2885 ResourceFormat format = RGBA_8888; | 2835 ResourceFormat format = RGBA_8888; |
| 2886 ResourceProvider::ResourceId id = 0; | 2836 ResourceProvider::ResourceId id = 0; |
| 2887 const uint32_t kBadBeef = 0xbadbeef; | 2837 const uint32_t kBadBeef = 0xbadbeef; |
| 2888 | 2838 |
| 2889 scoped_ptr<ResourceProvider> resource_provider( | 2839 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2890 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2840 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2891 | 2841 |
| 2892 id = resource_provider->CreateResource( | 2842 id = resource_provider->CreateResource( |
| 2893 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2843 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 2894 resource_provider->AcquirePixelRasterBuffer(id); | 2844 resource_provider->AcquirePixelRasterBuffer(id); |
| 2895 | 2845 |
| 2896 SkBitmap bitmap; | 2846 SkBitmap bitmap; |
| 2897 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); | 2847 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); |
| 2898 bitmap.allocPixels(); | 2848 bitmap.allocPixels(); |
| 2899 *(bitmap.getAddr32(0, 0)) = kBadBeef; | 2849 *(bitmap.getAddr32(0, 0)) = kBadBeef; |
| 2900 SkCanvas* canvas = resource_provider->MapPixelRasterBuffer(id); | 2850 SkCanvas* canvas = resource_provider->MapPixelRasterBuffer(id); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2928 FakeOutputSurfaceClient output_surface_client; | 2878 FakeOutputSurfaceClient output_surface_client; |
| 2929 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2879 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2930 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2880 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2931 CHECK(output_surface->BindToClient(&output_surface_client)); | 2881 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2932 | 2882 |
| 2933 gfx::Size size(2, 2); | 2883 gfx::Size size(2, 2); |
| 2934 ResourceFormat format = RGBA_8888; | 2884 ResourceFormat format = RGBA_8888; |
| 2935 ResourceProvider::ResourceId id = 0; | 2885 ResourceProvider::ResourceId id = 0; |
| 2936 int texture_id = 123; | 2886 int texture_id = 123; |
| 2937 | 2887 |
| 2938 scoped_ptr<ResourceProvider> resource_provider( | 2888 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2939 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2889 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2940 | 2890 |
| 2941 id = resource_provider->CreateResource( | 2891 id = resource_provider->CreateResource( |
| 2942 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2892 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 2943 resource_provider->AcquirePixelRasterBuffer(id); | 2893 resource_provider->AcquirePixelRasterBuffer(id); |
| 2944 | 2894 |
| 2945 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 2895 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
| 2946 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 2896 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
| 2947 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) | 2897 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) |
| 2948 .Times(1); | 2898 .Times(1); |
| 2949 resource_provider->BeginSetPixels(id); | 2899 resource_provider->BeginSetPixels(id); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2969 FakeOutputSurfaceClient output_surface_client; | 2919 FakeOutputSurfaceClient output_surface_client; |
| 2970 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2920 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2971 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2921 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2972 CHECK(output_surface->BindToClient(&output_surface_client)); | 2922 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2973 | 2923 |
| 2974 gfx::Size size(2, 2); | 2924 gfx::Size size(2, 2); |
| 2975 ResourceFormat format = RGBA_8888; | 2925 ResourceFormat format = RGBA_8888; |
| 2976 ResourceProvider::ResourceId id = 0; | 2926 ResourceProvider::ResourceId id = 0; |
| 2977 int texture_id = 123; | 2927 int texture_id = 123; |
| 2978 | 2928 |
| 2979 scoped_ptr<ResourceProvider> resource_provider( | 2929 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2980 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2930 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 2981 | 2931 |
| 2982 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); | 2932 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); |
| 2983 | 2933 |
| 2984 id = resource_provider->CreateResource( | 2934 id = resource_provider->CreateResource( |
| 2985 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2935 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 2986 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 2936 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 2987 GL_INNOCENT_CONTEXT_RESET_ARB); | 2937 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 2988 | 2938 |
| 2989 resource_provider->AcquirePixelRasterBuffer(id); | 2939 resource_provider->AcquirePixelRasterBuffer(id); |
| 2990 SkCanvas* raster_canvas = resource_provider->MapPixelRasterBuffer(id); | 2940 SkCanvas* raster_canvas = resource_provider->MapPixelRasterBuffer(id); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3008 CHECK(output_surface->BindToClient(&output_surface_client)); | 2958 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 3009 | 2959 |
| 3010 const int kWidth = 2; | 2960 const int kWidth = 2; |
| 3011 const int kHeight = 2; | 2961 const int kHeight = 2; |
| 3012 gfx::Size size(kWidth, kHeight); | 2962 gfx::Size size(kWidth, kHeight); |
| 3013 ResourceFormat format = RGBA_8888; | 2963 ResourceFormat format = RGBA_8888; |
| 3014 ResourceProvider::ResourceId id = 0; | 2964 ResourceProvider::ResourceId id = 0; |
| 3015 const unsigned kTextureId = 123u; | 2965 const unsigned kTextureId = 123u; |
| 3016 const unsigned kImageId = 234u; | 2966 const unsigned kImageId = 234u; |
| 3017 | 2967 |
| 3018 scoped_ptr<ResourceProvider> resource_provider( | 2968 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 3019 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2969 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 3020 | 2970 |
| 3021 id = resource_provider->CreateResource( | 2971 id = resource_provider->CreateResource( |
| 3022 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2972 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 3023 | 2973 |
| 3024 const int kStride = 4; | 2974 const int kStride = 4; |
| 3025 void* dummy_mapped_buffer_address = NULL; | 2975 void* dummy_mapped_buffer_address = NULL; |
| 3026 EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES)) | 2976 EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES)) |
| 3027 .WillOnce(Return(kImageId)) | 2977 .WillOnce(Return(kImageId)) |
| 3028 .RetiresOnSaturation(); | 2978 .RetiresOnSaturation(); |
| 3029 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId, | 2979 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3100 scoped_ptr<OutputSurface> output_surface( | 3050 scoped_ptr<OutputSurface> output_surface( |
| 3101 FakeOutputSurface::CreateSoftware(make_scoped_ptr( | 3051 FakeOutputSurface::CreateSoftware(make_scoped_ptr( |
| 3102 new SoftwareOutputDevice))); | 3052 new SoftwareOutputDevice))); |
| 3103 CHECK(output_surface->BindToClient(&output_surface_client)); | 3053 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 3104 | 3054 |
| 3105 gfx::Size size(1, 1); | 3055 gfx::Size size(1, 1); |
| 3106 ResourceFormat format = RGBA_8888; | 3056 ResourceFormat format = RGBA_8888; |
| 3107 ResourceProvider::ResourceId id = 0; | 3057 ResourceProvider::ResourceId id = 0; |
| 3108 const uint32_t kBadBeef = 0xbadbeef; | 3058 const uint32_t kBadBeef = 0xbadbeef; |
| 3109 | 3059 |
| 3110 scoped_ptr<ResourceProvider> resource_provider( | 3060 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 3111 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 3061 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
| 3112 | 3062 |
| 3113 id = resource_provider->CreateResource( | 3063 id = resource_provider->CreateResource( |
| 3114 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3064 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 3115 | 3065 |
| 3116 SkBitmap bitmap; | 3066 SkBitmap bitmap; |
| 3117 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); | 3067 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); |
| 3118 bitmap.allocPixels(); | 3068 bitmap.allocPixels(); |
| 3119 *(bitmap.getAddr32(0, 0)) = kBadBeef; | 3069 *(bitmap.getAddr32(0, 0)) = kBadBeef; |
| 3120 SkCanvas* canvas = resource_provider->MapImageRasterBuffer(id); | 3070 SkCanvas* canvas = resource_provider->MapImageRasterBuffer(id); |
| 3121 ASSERT_TRUE(!!canvas); | 3071 ASSERT_TRUE(!!canvas); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3149 CheckCreateResource(ResourceProvider::GLTexture, resource_provider, context); | 3099 CheckCreateResource(ResourceProvider::GLTexture, resource_provider, context); |
| 3150 } | 3100 } |
| 3151 | 3101 |
| 3152 TEST(ResourceProviderTest, BasicInitializeGLSoftware) { | 3102 TEST(ResourceProviderTest, BasicInitializeGLSoftware) { |
| 3153 scoped_ptr<ContextSharedData> shared_data = ContextSharedData::Create(); | 3103 scoped_ptr<ContextSharedData> shared_data = ContextSharedData::Create(); |
| 3154 FakeOutputSurfaceClient client; | 3104 FakeOutputSurfaceClient client; |
| 3155 scoped_ptr<FakeOutputSurface> output_surface( | 3105 scoped_ptr<FakeOutputSurface> output_surface( |
| 3156 FakeOutputSurface::CreateDeferredGL( | 3106 FakeOutputSurface::CreateDeferredGL( |
| 3157 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice))); | 3107 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice))); |
| 3158 EXPECT_TRUE(output_surface->BindToClient(&client)); | 3108 EXPECT_TRUE(output_surface->BindToClient(&client)); |
| 3159 scoped_ptr<ResourceProvider> resource_provider( | 3109 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 3160 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 3110 new TestSharedBitmapManager()); |
| 3111 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 3112 output_surface.get(), shared_bitmap_manager.get(), 0, false, 1)); |
| 3161 | 3113 |
| 3162 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); | 3114 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); |
| 3163 | 3115 |
| 3164 InitializeGLAndCheck(shared_data.get(), | 3116 InitializeGLAndCheck(shared_data.get(), |
| 3165 resource_provider.get(), | 3117 resource_provider.get(), |
| 3166 output_surface.get()); | 3118 output_surface.get()); |
| 3167 | 3119 |
| 3168 resource_provider->InitializeSoftware(); | 3120 resource_provider->InitializeSoftware(); |
| 3169 output_surface->ReleaseGL(); | 3121 output_surface->ReleaseGL(); |
| 3170 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); | 3122 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3267 | 3219 |
| 3268 TEST(ResourceProviderTest, TextureAllocationChunkSize) { | 3220 TEST(ResourceProviderTest, TextureAllocationChunkSize) { |
| 3269 scoped_ptr<TextureIdAllocationTrackingContext> context_owned( | 3221 scoped_ptr<TextureIdAllocationTrackingContext> context_owned( |
| 3270 new TextureIdAllocationTrackingContext); | 3222 new TextureIdAllocationTrackingContext); |
| 3271 TextureIdAllocationTrackingContext* context = context_owned.get(); | 3223 TextureIdAllocationTrackingContext* context = context_owned.get(); |
| 3272 | 3224 |
| 3273 FakeOutputSurfaceClient output_surface_client; | 3225 FakeOutputSurfaceClient output_surface_client; |
| 3274 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 3226 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 3275 context_owned.PassAs<TestWebGraphicsContext3D>())); | 3227 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 3276 CHECK(output_surface->BindToClient(&output_surface_client)); | 3228 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 3229 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 3230 new TestSharedBitmapManager()); |
| 3277 | 3231 |
| 3278 gfx::Size size(1, 1); | 3232 gfx::Size size(1, 1); |
| 3279 ResourceFormat format = RGBA_8888; | 3233 ResourceFormat format = RGBA_8888; |
| 3280 | 3234 |
| 3281 { | 3235 { |
| 3282 size_t kTextureAllocationChunkSize = 1; | 3236 size_t kTextureAllocationChunkSize = 1; |
| 3283 scoped_ptr<ResourceProvider> resource_provider( | 3237 scoped_ptr<ResourceProvider> resource_provider( |
| 3284 ResourceProvider::Create(output_surface.get(), | 3238 ResourceProvider::Create(output_surface.get(), |
| 3285 NULL, | 3239 shared_bitmap_manager.get(), |
| 3286 0, | 3240 0, |
| 3287 false, | 3241 false, |
| 3288 kTextureAllocationChunkSize)); | 3242 kTextureAllocationChunkSize)); |
| 3289 | 3243 |
| 3290 ResourceProvider::ResourceId id = resource_provider->CreateResource( | 3244 ResourceProvider::ResourceId id = resource_provider->CreateResource( |
| 3291 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3245 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 3292 resource_provider->AllocateForTesting(id); | 3246 resource_provider->AllocateForTesting(id); |
| 3293 Mock::VerifyAndClearExpectations(context); | 3247 Mock::VerifyAndClearExpectations(context); |
| 3294 | 3248 |
| 3295 DCHECK_EQ(2u, context->PeekTextureId()); | 3249 DCHECK_EQ(2u, context->PeekTextureId()); |
| 3296 resource_provider->DeleteResource(id); | 3250 resource_provider->DeleteResource(id); |
| 3297 } | 3251 } |
| 3298 | 3252 |
| 3299 { | 3253 { |
| 3300 size_t kTextureAllocationChunkSize = 8; | 3254 size_t kTextureAllocationChunkSize = 8; |
| 3301 scoped_ptr<ResourceProvider> resource_provider( | 3255 scoped_ptr<ResourceProvider> resource_provider( |
| 3302 ResourceProvider::Create(output_surface.get(), | 3256 ResourceProvider::Create(output_surface.get(), |
| 3303 NULL, | 3257 shared_bitmap_manager.get(), |
| 3304 0, | 3258 0, |
| 3305 false, | 3259 false, |
| 3306 kTextureAllocationChunkSize)); | 3260 kTextureAllocationChunkSize)); |
| 3307 | 3261 |
| 3308 ResourceProvider::ResourceId id = resource_provider->CreateResource( | 3262 ResourceProvider::ResourceId id = resource_provider->CreateResource( |
| 3309 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3263 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 3310 resource_provider->AllocateForTesting(id); | 3264 resource_provider->AllocateForTesting(id); |
| 3311 Mock::VerifyAndClearExpectations(context); | 3265 Mock::VerifyAndClearExpectations(context); |
| 3312 | 3266 |
| 3313 DCHECK_EQ(10u, context->PeekTextureId()); | 3267 DCHECK_EQ(10u, context->PeekTextureId()); |
| 3314 resource_provider->DeleteResource(id); | 3268 resource_provider->DeleteResource(id); |
| 3315 } | 3269 } |
| 3316 } | 3270 } |
| 3317 | 3271 |
| 3318 } // namespace | 3272 } // namespace |
| 3319 } // namespace cc | 3273 } // namespace cc |
| OLD | NEW |