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 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "cc/base/scoped_ptr_deque.h" | 14 #include "cc/base/scoped_ptr_deque.h" |
15 #include "cc/output/output_surface.h" | 15 #include "cc/output/output_surface.h" |
16 #include "cc/resources/returned_resource.h" | 16 #include "cc/resources/returned_resource.h" |
17 #include "cc/resources/shared_bitmap_manager.h" | 17 #include "cc/resources/shared_bitmap_manager.h" |
18 #include "cc/resources/single_release_callback.h" | 18 #include "cc/resources/single_release_callback.h" |
19 #include "cc/test/fake_output_surface.h" | 19 #include "cc/test/fake_output_surface.h" |
20 #include "cc/test/fake_output_surface_client.h" | 20 #include "cc/test/fake_output_surface_client.h" |
| 21 #include "cc/test/test_shared_bitmap_manager.h" |
21 #include "cc/test/test_texture.h" | 22 #include "cc/test/test_texture.h" |
22 #include "cc/test/test_web_graphics_context_3d.h" | 23 #include "cc/test/test_web_graphics_context_3d.h" |
23 #include "gpu/GLES2/gl2extchromium.h" | 24 #include "gpu/GLES2/gl2extchromium.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
26 #include "third_party/khronos/GLES2/gl2.h" | 27 #include "third_party/khronos/GLES2/gl2.h" |
27 #include "third_party/khronos/GLES2/gl2ext.h" | 28 #include "third_party/khronos/GLES2/gl2ext.h" |
28 #include "ui/gfx/rect.h" | 29 #include "ui/gfx/rect.h" |
29 | 30 |
30 using testing::Mock; | 31 using testing::Mock; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 struct PendingProduceTexture { | 325 struct PendingProduceTexture { |
325 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; | 326 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; |
326 scoped_refptr<TestTexture> texture; | 327 scoped_refptr<TestTexture> texture; |
327 }; | 328 }; |
328 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; | 329 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; |
329 ContextSharedData* shared_data_; | 330 ContextSharedData* shared_data_; |
330 GLuint last_waited_sync_point_; | 331 GLuint last_waited_sync_point_; |
331 PendingProduceTextureList pending_produce_textures_; | 332 PendingProduceTextureList pending_produce_textures_; |
332 }; | 333 }; |
333 | 334 |
334 void FreeSharedBitmap(SharedBitmap* shared_bitmap) { | |
335 delete shared_bitmap->memory(); | |
336 } | |
337 | |
338 void IgnoreSharedBitmap(SharedBitmap* shared_bitmap) {} | |
339 | |
340 class TestSharedBitmapManager : public SharedBitmapManager { | |
341 public: | |
342 TestSharedBitmapManager() : count_(0) {} | |
343 virtual ~TestSharedBitmapManager() {} | |
344 | |
345 virtual scoped_ptr<SharedBitmap> AllocateSharedBitmap(const gfx::Size& size) | |
346 OVERRIDE { | |
347 scoped_ptr<base::SharedMemory> memory(new base::SharedMemory); | |
348 memory->CreateAndMapAnonymous(size.GetArea() * 4); | |
349 int8 name[GL_MAILBOX_SIZE_CHROMIUM] = {0}; | |
350 name[0] = count_++; | |
351 SharedBitmapId id; | |
352 id.SetName(name); | |
353 bitmap_map_[id] = memory.get(); | |
354 return scoped_ptr<SharedBitmap>( | |
355 new SharedBitmap(memory.release(), id, base::Bind(&FreeSharedBitmap))); | |
356 } | |
357 | |
358 virtual scoped_ptr<SharedBitmap> GetSharedBitmapFromId( | |
359 const gfx::Size&, | |
360 const SharedBitmapId& id) OVERRIDE { | |
361 if (bitmap_map_.find(id) == bitmap_map_.end()) | |
362 return scoped_ptr<SharedBitmap>(); | |
363 return scoped_ptr<SharedBitmap>( | |
364 new SharedBitmap(bitmap_map_[id], id, base::Bind(&IgnoreSharedBitmap))); | |
365 } | |
366 | |
367 virtual scoped_ptr<SharedBitmap> GetBitmapForSharedMemory( | |
368 base::SharedMemory* memory) OVERRIDE { | |
369 int8 name[GL_MAILBOX_SIZE_CHROMIUM] = {0}; | |
370 name[0] = count_++; | |
371 SharedBitmapId id; | |
372 id.SetName(name); | |
373 bitmap_map_[id] = memory; | |
374 return scoped_ptr<SharedBitmap>( | |
375 new SharedBitmap(memory, id, base::Bind(&IgnoreSharedBitmap))); | |
376 } | |
377 | |
378 private: | |
379 int count_; | |
380 std::map<SharedBitmapId, base::SharedMemory*> bitmap_map_; | |
381 }; | |
382 | |
383 void GetResourcePixels(ResourceProvider* resource_provider, | 335 void GetResourcePixels(ResourceProvider* resource_provider, |
384 ResourceProviderContext* context, | 336 ResourceProviderContext* context, |
385 ResourceProvider::ResourceId id, | 337 ResourceProvider::ResourceId id, |
386 const gfx::Size& size, | 338 const gfx::Size& size, |
387 ResourceFormat format, | 339 ResourceFormat format, |
388 uint8_t* pixels) { | 340 uint8_t* pixels) { |
389 switch (resource_provider->default_resource_type()) { | 341 switch (resource_provider->default_resource_type()) { |
390 case ResourceProvider::GLTexture: { | 342 case ResourceProvider::GLTexture: { |
391 ResourceProvider::ScopedReadLockGL lock_gl(resource_provider, id); | 343 ResourceProvider::ScopedReadLockGL lock_gl(resource_provider, id); |
392 ASSERT_NE(0U, lock_gl.texture_id()); | 344 ASSERT_NE(0U, lock_gl.texture_id()); |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 return; | 1103 return; |
1152 | 1104 |
1153 scoped_ptr<ResourceProviderContext> child_context_owned( | 1105 scoped_ptr<ResourceProviderContext> child_context_owned( |
1154 ResourceProviderContext::Create(shared_data_.get())); | 1106 ResourceProviderContext::Create(shared_data_.get())); |
1155 | 1107 |
1156 FakeOutputSurfaceClient child_output_surface_client; | 1108 FakeOutputSurfaceClient child_output_surface_client; |
1157 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d( | 1109 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d( |
1158 child_context_owned.PassAs<TestWebGraphicsContext3D>())); | 1110 child_context_owned.PassAs<TestWebGraphicsContext3D>())); |
1159 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); | 1111 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); |
1160 | 1112 |
1161 scoped_ptr<ResourceProvider> child_resource_provider( | 1113 scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create( |
1162 ResourceProvider::Create(child_output_surface.get(), | 1114 child_output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
1163 NULL, | |
1164 0, | |
1165 false, | |
1166 1)); | |
1167 | 1115 |
1168 gfx::Size size(1, 1); | 1116 gfx::Size size(1, 1); |
1169 ResourceFormat format = RGBA_8888; | 1117 ResourceFormat format = RGBA_8888; |
1170 size_t pixel_size = TextureSizeBytes(size, format); | 1118 size_t pixel_size = TextureSizeBytes(size, format); |
1171 ASSERT_EQ(4U, pixel_size); | 1119 ASSERT_EQ(4U, pixel_size); |
1172 | 1120 |
1173 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource( | 1121 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource( |
1174 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 1122 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
1175 uint8_t data1[4] = { 1, 2, 3, 4 }; | 1123 uint8_t data1[4] = { 1, 2, 3, 4 }; |
1176 gfx::Rect rect(size); | 1124 gfx::Rect rect(size); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 public: | 1576 public: |
1629 static void RunTest(GLenum child_filter, GLenum parent_filter) { | 1577 static void RunTest(GLenum child_filter, GLenum parent_filter) { |
1630 scoped_ptr<TextureStateTrackingContext> child_context_owned( | 1578 scoped_ptr<TextureStateTrackingContext> child_context_owned( |
1631 new TextureStateTrackingContext); | 1579 new TextureStateTrackingContext); |
1632 TextureStateTrackingContext* child_context = child_context_owned.get(); | 1580 TextureStateTrackingContext* child_context = child_context_owned.get(); |
1633 | 1581 |
1634 FakeOutputSurfaceClient child_output_surface_client; | 1582 FakeOutputSurfaceClient child_output_surface_client; |
1635 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d( | 1583 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d( |
1636 child_context_owned.PassAs<TestWebGraphicsContext3D>())); | 1584 child_context_owned.PassAs<TestWebGraphicsContext3D>())); |
1637 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); | 1585 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); |
| 1586 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 1587 new TestSharedBitmapManager()); |
1638 | 1588 |
1639 scoped_ptr<ResourceProvider> child_resource_provider( | 1589 scoped_ptr<ResourceProvider> child_resource_provider( |
1640 ResourceProvider::Create(child_output_surface.get(), | 1590 ResourceProvider::Create(child_output_surface.get(), |
1641 NULL, | 1591 shared_bitmap_manager.get(), |
1642 0, | 1592 0, |
1643 false, | 1593 false, |
1644 1)); | 1594 1)); |
1645 | 1595 |
1646 scoped_ptr<TextureStateTrackingContext> parent_context_owned( | 1596 scoped_ptr<TextureStateTrackingContext> parent_context_owned( |
1647 new TextureStateTrackingContext); | 1597 new TextureStateTrackingContext); |
1648 TextureStateTrackingContext* parent_context = parent_context_owned.get(); | 1598 TextureStateTrackingContext* parent_context = parent_context_owned.get(); |
1649 | 1599 |
1650 FakeOutputSurfaceClient parent_output_surface_client; | 1600 FakeOutputSurfaceClient parent_output_surface_client; |
1651 scoped_ptr<OutputSurface> parent_output_surface(FakeOutputSurface::Create3d( | 1601 scoped_ptr<OutputSurface> parent_output_surface(FakeOutputSurface::Create3d( |
1652 parent_context_owned.PassAs<TestWebGraphicsContext3D>())); | 1602 parent_context_owned.PassAs<TestWebGraphicsContext3D>())); |
1653 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); | 1603 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); |
1654 | 1604 |
1655 scoped_ptr<ResourceProvider> parent_resource_provider( | 1605 scoped_ptr<ResourceProvider> parent_resource_provider( |
1656 ResourceProvider::Create(parent_output_surface.get(), | 1606 ResourceProvider::Create(parent_output_surface.get(), |
1657 NULL, | 1607 shared_bitmap_manager.get(), |
1658 0, | 1608 0, |
1659 false, | 1609 false, |
1660 1)); | 1610 1)); |
1661 | 1611 |
1662 gfx::Size size(1, 1); | 1612 gfx::Size size(1, 1); |
1663 ResourceFormat format = RGBA_8888; | 1613 ResourceFormat format = RGBA_8888; |
1664 int child_texture_id = 1; | 1614 int child_texture_id = 1; |
1665 int parent_texture_id = 2; | 1615 int parent_texture_id = 2; |
1666 | 1616 |
1667 size_t pixel_size = TextureSizeBytes(size, format); | 1617 size_t pixel_size = TextureSizeBytes(size, format); |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2257 | 2207 |
2258 scoped_ptr<TextureStateTrackingContext> context_owned( | 2208 scoped_ptr<TextureStateTrackingContext> context_owned( |
2259 new TextureStateTrackingContext); | 2209 new TextureStateTrackingContext); |
2260 TextureStateTrackingContext* context = context_owned.get(); | 2210 TextureStateTrackingContext* context = context_owned.get(); |
2261 | 2211 |
2262 FakeOutputSurfaceClient output_surface_client; | 2212 FakeOutputSurfaceClient output_surface_client; |
2263 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2213 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2264 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2214 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2265 CHECK(output_surface->BindToClient(&output_surface_client)); | 2215 CHECK(output_surface->BindToClient(&output_surface_client)); |
2266 | 2216 |
2267 scoped_ptr<ResourceProvider> resource_provider( | 2217 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2268 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2218 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2269 | 2219 |
2270 gfx::Size size(1, 1); | 2220 gfx::Size size(1, 1); |
2271 ResourceFormat format = RGBA_8888; | 2221 ResourceFormat format = RGBA_8888; |
2272 int texture_id = 1; | 2222 int texture_id = 1; |
2273 | 2223 |
2274 ResourceProvider::ResourceId id = resource_provider->CreateResource( | 2224 ResourceProvider::ResourceId id = resource_provider->CreateResource( |
2275 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2225 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
2276 | 2226 |
2277 // Check that the texture gets created with the right sampler settings. | 2227 // Check that the texture gets created with the right sampler settings. |
2278 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) | 2228 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2338 | 2288 |
2339 scoped_ptr<TextureStateTrackingContext> context_owned( | 2289 scoped_ptr<TextureStateTrackingContext> context_owned( |
2340 new TextureStateTrackingContext); | 2290 new TextureStateTrackingContext); |
2341 TextureStateTrackingContext* context = context_owned.get(); | 2291 TextureStateTrackingContext* context = context_owned.get(); |
2342 | 2292 |
2343 FakeOutputSurfaceClient output_surface_client; | 2293 FakeOutputSurfaceClient output_surface_client; |
2344 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2294 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2345 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2295 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2346 CHECK(output_surface->BindToClient(&output_surface_client)); | 2296 CHECK(output_surface->BindToClient(&output_surface_client)); |
2347 | 2297 |
2348 scoped_ptr<ResourceProvider> resource_provider( | 2298 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2349 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2299 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2350 | 2300 |
2351 gfx::Size size(1, 1); | 2301 gfx::Size size(1, 1); |
2352 ResourceFormat format = RGBA_8888; | 2302 ResourceFormat format = RGBA_8888; |
2353 int texture_id = 1; | 2303 int texture_id = 1; |
2354 | 2304 |
2355 // Check that the texture gets created with the right sampler settings. | 2305 // Check that the texture gets created with the right sampler settings. |
2356 ResourceProvider::ResourceId id = resource_provider->CreateManagedResource( | 2306 ResourceProvider::ResourceId id = resource_provider->CreateManagedResource( |
2357 size, | 2307 size, |
2358 GL_TEXTURE_2D, | 2308 GL_TEXTURE_2D, |
2359 GL_CLAMP_TO_EDGE, | 2309 GL_CLAMP_TO_EDGE, |
(...skipping 27 matching lines...) Expand all Loading... |
2387 | 2337 |
2388 scoped_ptr<TextureStateTrackingContext> context_owned( | 2338 scoped_ptr<TextureStateTrackingContext> context_owned( |
2389 new TextureStateTrackingContext); | 2339 new TextureStateTrackingContext); |
2390 TextureStateTrackingContext* context = context_owned.get(); | 2340 TextureStateTrackingContext* context = context_owned.get(); |
2391 | 2341 |
2392 FakeOutputSurfaceClient output_surface_client; | 2342 FakeOutputSurfaceClient output_surface_client; |
2393 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2343 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2394 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2344 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2395 CHECK(output_surface->BindToClient(&output_surface_client)); | 2345 CHECK(output_surface->BindToClient(&output_surface_client)); |
2396 | 2346 |
2397 scoped_ptr<ResourceProvider> resource_provider( | 2347 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2398 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2348 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2399 | 2349 |
2400 gfx::Size size(1, 1); | 2350 gfx::Size size(1, 1); |
2401 ResourceFormat format = RGBA_8888; | 2351 ResourceFormat format = RGBA_8888; |
2402 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; | 2352 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; |
2403 | 2353 |
2404 for (int texture_id = 1; texture_id <= 2; ++texture_id) { | 2354 for (int texture_id = 1; texture_id <= 2; ++texture_id) { |
2405 GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT; | 2355 GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT; |
2406 // Check that the texture gets created with the right sampler settings. | 2356 // Check that the texture gets created with the right sampler settings. |
2407 ResourceProvider::ResourceId id = | 2357 ResourceProvider::ResourceId id = |
2408 resource_provider->CreateGLTexture(size, | 2358 resource_provider->CreateGLTexture(size, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2441 const uint32_t kBadBeef = 0xbadbeef; | 2391 const uint32_t kBadBeef = 0xbadbeef; |
2442 scoped_ptr<base::SharedMemory> shared_memory( | 2392 scoped_ptr<base::SharedMemory> shared_memory( |
2443 CreateAndFillSharedMemory(size, kBadBeef)); | 2393 CreateAndFillSharedMemory(size, kBadBeef)); |
2444 | 2394 |
2445 FakeOutputSurfaceClient output_surface_client; | 2395 FakeOutputSurfaceClient output_surface_client; |
2446 scoped_ptr<OutputSurface> output_surface( | 2396 scoped_ptr<OutputSurface> output_surface( |
2447 FakeOutputSurface::CreateSoftware(make_scoped_ptr( | 2397 FakeOutputSurface::CreateSoftware(make_scoped_ptr( |
2448 new SoftwareOutputDevice))); | 2398 new SoftwareOutputDevice))); |
2449 CHECK(output_surface->BindToClient(&output_surface_client)); | 2399 CHECK(output_surface->BindToClient(&output_surface_client)); |
2450 | 2400 |
2451 scoped_ptr<ResourceProvider> resource_provider( | 2401 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2452 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2402 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2453 | 2403 |
2454 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 2404 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
2455 base::Bind(&EmptyReleaseCallback)); | 2405 base::Bind(&EmptyReleaseCallback)); |
2456 TextureMailbox mailbox(shared_memory.get(), size); | 2406 TextureMailbox mailbox(shared_memory.get(), size); |
2457 | 2407 |
2458 ResourceProvider::ResourceId id = | 2408 ResourceProvider::ResourceId id = |
2459 resource_provider->CreateResourceFromTextureMailbox( | 2409 resource_provider->CreateResourceFromTextureMailbox( |
2460 mailbox, callback.Pass()); | 2410 mailbox, callback.Pass()); |
2461 EXPECT_NE(0u, id); | 2411 EXPECT_NE(0u, id); |
2462 | 2412 |
(...skipping 13 matching lines...) Expand all Loading... |
2476 | 2426 |
2477 scoped_ptr<TextureStateTrackingContext> context_owned( | 2427 scoped_ptr<TextureStateTrackingContext> context_owned( |
2478 new TextureStateTrackingContext); | 2428 new TextureStateTrackingContext); |
2479 TextureStateTrackingContext* context = context_owned.get(); | 2429 TextureStateTrackingContext* context = context_owned.get(); |
2480 | 2430 |
2481 FakeOutputSurfaceClient output_surface_client; | 2431 FakeOutputSurfaceClient output_surface_client; |
2482 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2432 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2483 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2433 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2484 CHECK(output_surface->BindToClient(&output_surface_client)); | 2434 CHECK(output_surface->BindToClient(&output_surface_client)); |
2485 | 2435 |
2486 scoped_ptr<ResourceProvider> resource_provider( | 2436 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2487 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2437 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2488 | 2438 |
2489 unsigned texture_id = 1; | 2439 unsigned texture_id = 1; |
2490 uint32 sync_point = 30; | 2440 uint32 sync_point = 30; |
2491 unsigned target = GL_TEXTURE_2D; | 2441 unsigned target = GL_TEXTURE_2D; |
2492 | 2442 |
2493 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2443 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
2494 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2444 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
2495 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2445 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
2496 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2446 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
2497 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); | 2447 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2540 | 2490 |
2541 scoped_ptr<TextureStateTrackingContext> context_owned( | 2491 scoped_ptr<TextureStateTrackingContext> context_owned( |
2542 new TextureStateTrackingContext); | 2492 new TextureStateTrackingContext); |
2543 TextureStateTrackingContext* context = context_owned.get(); | 2493 TextureStateTrackingContext* context = context_owned.get(); |
2544 | 2494 |
2545 FakeOutputSurfaceClient output_surface_client; | 2495 FakeOutputSurfaceClient output_surface_client; |
2546 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2496 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2547 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2497 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2548 CHECK(output_surface->BindToClient(&output_surface_client)); | 2498 CHECK(output_surface->BindToClient(&output_surface_client)); |
2549 | 2499 |
2550 scoped_ptr<ResourceProvider> resource_provider( | 2500 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2551 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2501 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2552 | 2502 |
2553 unsigned texture_id = 1; | 2503 unsigned texture_id = 1; |
2554 uint32 sync_point = 30; | 2504 uint32 sync_point = 30; |
2555 unsigned target = GL_TEXTURE_EXTERNAL_OES; | 2505 unsigned target = GL_TEXTURE_EXTERNAL_OES; |
2556 | 2506 |
2557 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2507 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
2558 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2508 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
2559 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2509 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
2560 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2510 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
2561 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); | 2511 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2678 return; | 2628 return; |
2679 scoped_ptr<AllocationTrackingContext3D> context_owned( | 2629 scoped_ptr<AllocationTrackingContext3D> context_owned( |
2680 new StrictMock<AllocationTrackingContext3D>); | 2630 new StrictMock<AllocationTrackingContext3D>); |
2681 AllocationTrackingContext3D* context = context_owned.get(); | 2631 AllocationTrackingContext3D* context = context_owned.get(); |
2682 | 2632 |
2683 FakeOutputSurfaceClient output_surface_client; | 2633 FakeOutputSurfaceClient output_surface_client; |
2684 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2634 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2685 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2635 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2686 CHECK(output_surface->BindToClient(&output_surface_client)); | 2636 CHECK(output_surface->BindToClient(&output_surface_client)); |
2687 | 2637 |
2688 scoped_ptr<ResourceProvider> resource_provider( | 2638 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2689 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2639 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2690 | 2640 |
2691 gfx::Size size(2, 2); | 2641 gfx::Size size(2, 2); |
2692 gfx::Vector2d offset(0, 0); | 2642 gfx::Vector2d offset(0, 0); |
2693 gfx::Rect rect(0, 0, 2, 2); | 2643 gfx::Rect rect(0, 0, 2, 2); |
2694 ResourceFormat format = RGBA_8888; | 2644 ResourceFormat format = RGBA_8888; |
2695 ResourceProvider::ResourceId id = 0; | 2645 ResourceProvider::ResourceId id = 0; |
2696 uint8_t pixels[16] = { 0 }; | 2646 uint8_t pixels[16] = { 0 }; |
2697 int texture_id = 123; | 2647 int texture_id = 123; |
2698 | 2648 |
2699 // Lazy allocation. Don't allocate when creating the resource. | 2649 // Lazy allocation. Don't allocate when creating the resource. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2751 scoped_ptr<AllocationTrackingContext3D> context_owned( | 2701 scoped_ptr<AllocationTrackingContext3D> context_owned( |
2752 new StrictMock<AllocationTrackingContext3D>); | 2702 new StrictMock<AllocationTrackingContext3D>); |
2753 AllocationTrackingContext3D* context = context_owned.get(); | 2703 AllocationTrackingContext3D* context = context_owned.get(); |
2754 context->set_support_texture_storage(true); | 2704 context->set_support_texture_storage(true); |
2755 | 2705 |
2756 FakeOutputSurfaceClient output_surface_client; | 2706 FakeOutputSurfaceClient output_surface_client; |
2757 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2707 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2758 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2708 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2759 CHECK(output_surface->BindToClient(&output_surface_client)); | 2709 CHECK(output_surface->BindToClient(&output_surface_client)); |
2760 | 2710 |
2761 scoped_ptr<ResourceProvider> resource_provider( | 2711 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2762 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2712 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2763 | 2713 |
2764 gfx::Size size(2, 2); | 2714 gfx::Size size(2, 2); |
2765 ResourceFormat format = RGBA_8888; | 2715 ResourceFormat format = RGBA_8888; |
2766 ResourceProvider::ResourceId id = 0; | 2716 ResourceProvider::ResourceId id = 0; |
2767 int texture_id = 123; | 2717 int texture_id = 123; |
2768 | 2718 |
2769 // Lazy allocation. Don't allocate when creating the resource. | 2719 // Lazy allocation. Don't allocate when creating the resource. |
2770 id = resource_provider->CreateResource( | 2720 id = resource_provider->CreateResource( |
2771 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2721 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
2772 | 2722 |
(...skipping 15 matching lines...) Expand all Loading... |
2788 scoped_ptr<AllocationTrackingContext3D> context_owned( | 2738 scoped_ptr<AllocationTrackingContext3D> context_owned( |
2789 new StrictMock<AllocationTrackingContext3D>); | 2739 new StrictMock<AllocationTrackingContext3D>); |
2790 AllocationTrackingContext3D* context = context_owned.get(); | 2740 AllocationTrackingContext3D* context = context_owned.get(); |
2791 context->set_support_texture_storage(true); | 2741 context->set_support_texture_storage(true); |
2792 | 2742 |
2793 FakeOutputSurfaceClient output_surface_client; | 2743 FakeOutputSurfaceClient output_surface_client; |
2794 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2744 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2795 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2745 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2796 CHECK(output_surface->BindToClient(&output_surface_client)); | 2746 CHECK(output_surface->BindToClient(&output_surface_client)); |
2797 | 2747 |
2798 scoped_ptr<ResourceProvider> resource_provider( | 2748 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2799 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2749 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2800 | 2750 |
2801 gfx::Size size(2, 2); | 2751 gfx::Size size(2, 2); |
2802 ResourceFormat format = RGBA_8888; | 2752 ResourceFormat format = RGBA_8888; |
2803 ResourceProvider::ResourceId id = 0; | 2753 ResourceProvider::ResourceId id = 0; |
2804 int texture_id = 123; | 2754 int texture_id = 123; |
2805 | 2755 |
2806 // Lazy allocation. Don't allocate when creating the resource. | 2756 // Lazy allocation. Don't allocate when creating the resource. |
2807 id = resource_provider->CreateResource( | 2757 id = resource_provider->CreateResource( |
2808 size, | 2758 size, |
2809 GL_CLAMP_TO_EDGE, | 2759 GL_CLAMP_TO_EDGE, |
(...skipping 21 matching lines...) Expand all Loading... |
2831 FakeOutputSurfaceClient output_surface_client; | 2781 FakeOutputSurfaceClient output_surface_client; |
2832 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2782 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2833 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2783 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2834 CHECK(output_surface->BindToClient(&output_surface_client)); | 2784 CHECK(output_surface->BindToClient(&output_surface_client)); |
2835 | 2785 |
2836 gfx::Size size(2, 2); | 2786 gfx::Size size(2, 2); |
2837 ResourceFormat format = RGBA_8888; | 2787 ResourceFormat format = RGBA_8888; |
2838 ResourceProvider::ResourceId id = 0; | 2788 ResourceProvider::ResourceId id = 0; |
2839 int texture_id = 123; | 2789 int texture_id = 123; |
2840 | 2790 |
2841 scoped_ptr<ResourceProvider> resource_provider( | 2791 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2842 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2792 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2843 | 2793 |
2844 id = resource_provider->CreateResource( | 2794 id = resource_provider->CreateResource( |
2845 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2795 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
2846 resource_provider->AcquirePixelRasterBuffer(id); | 2796 resource_provider->AcquirePixelRasterBuffer(id); |
2847 | 2797 |
2848 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 2798 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
2849 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 2799 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
2850 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) | 2800 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) |
2851 .Times(1); | 2801 .Times(1); |
2852 resource_provider->BeginSetPixels(id); | 2802 resource_provider->BeginSetPixels(id); |
(...skipping 15 matching lines...) Expand all Loading... |
2868 scoped_ptr<OutputSurface> output_surface( | 2818 scoped_ptr<OutputSurface> output_surface( |
2869 FakeOutputSurface::CreateSoftware(make_scoped_ptr( | 2819 FakeOutputSurface::CreateSoftware(make_scoped_ptr( |
2870 new SoftwareOutputDevice))); | 2820 new SoftwareOutputDevice))); |
2871 CHECK(output_surface->BindToClient(&output_surface_client)); | 2821 CHECK(output_surface->BindToClient(&output_surface_client)); |
2872 | 2822 |
2873 gfx::Size size(1, 1); | 2823 gfx::Size size(1, 1); |
2874 ResourceFormat format = RGBA_8888; | 2824 ResourceFormat format = RGBA_8888; |
2875 ResourceProvider::ResourceId id = 0; | 2825 ResourceProvider::ResourceId id = 0; |
2876 const uint32_t kBadBeef = 0xbadbeef; | 2826 const uint32_t kBadBeef = 0xbadbeef; |
2877 | 2827 |
2878 scoped_ptr<ResourceProvider> resource_provider( | 2828 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2879 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2829 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2880 | 2830 |
2881 id = resource_provider->CreateResource( | 2831 id = resource_provider->CreateResource( |
2882 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2832 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
2883 resource_provider->AcquirePixelRasterBuffer(id); | 2833 resource_provider->AcquirePixelRasterBuffer(id); |
2884 | 2834 |
2885 SkBitmap bitmap; | 2835 SkBitmap bitmap; |
2886 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); | 2836 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); |
2887 bitmap.allocPixels(); | 2837 bitmap.allocPixels(); |
2888 *(bitmap.getAddr32(0, 0)) = kBadBeef; | 2838 *(bitmap.getAddr32(0, 0)) = kBadBeef; |
2889 SkCanvas* canvas = resource_provider->MapPixelRasterBuffer(id); | 2839 SkCanvas* canvas = resource_provider->MapPixelRasterBuffer(id); |
(...skipping 27 matching lines...) Expand all Loading... |
2917 FakeOutputSurfaceClient output_surface_client; | 2867 FakeOutputSurfaceClient output_surface_client; |
2918 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2868 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2919 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2869 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2920 CHECK(output_surface->BindToClient(&output_surface_client)); | 2870 CHECK(output_surface->BindToClient(&output_surface_client)); |
2921 | 2871 |
2922 gfx::Size size(2, 2); | 2872 gfx::Size size(2, 2); |
2923 ResourceFormat format = RGBA_8888; | 2873 ResourceFormat format = RGBA_8888; |
2924 ResourceProvider::ResourceId id = 0; | 2874 ResourceProvider::ResourceId id = 0; |
2925 int texture_id = 123; | 2875 int texture_id = 123; |
2926 | 2876 |
2927 scoped_ptr<ResourceProvider> resource_provider( | 2877 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2928 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2878 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2929 | 2879 |
2930 id = resource_provider->CreateResource( | 2880 id = resource_provider->CreateResource( |
2931 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2881 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
2932 resource_provider->AcquirePixelRasterBuffer(id); | 2882 resource_provider->AcquirePixelRasterBuffer(id); |
2933 | 2883 |
2934 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 2884 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
2935 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 2885 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
2936 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) | 2886 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) |
2937 .Times(1); | 2887 .Times(1); |
2938 resource_provider->BeginSetPixels(id); | 2888 resource_provider->BeginSetPixels(id); |
(...skipping 19 matching lines...) Expand all Loading... |
2958 FakeOutputSurfaceClient output_surface_client; | 2908 FakeOutputSurfaceClient output_surface_client; |
2959 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2909 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2960 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2910 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2961 CHECK(output_surface->BindToClient(&output_surface_client)); | 2911 CHECK(output_surface->BindToClient(&output_surface_client)); |
2962 | 2912 |
2963 gfx::Size size(2, 2); | 2913 gfx::Size size(2, 2); |
2964 ResourceFormat format = RGBA_8888; | 2914 ResourceFormat format = RGBA_8888; |
2965 ResourceProvider::ResourceId id = 0; | 2915 ResourceProvider::ResourceId id = 0; |
2966 int texture_id = 123; | 2916 int texture_id = 123; |
2967 | 2917 |
2968 scoped_ptr<ResourceProvider> resource_provider( | 2918 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2969 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2919 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
2970 | 2920 |
2971 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); | 2921 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); |
2972 | 2922 |
2973 id = resource_provider->CreateResource( | 2923 id = resource_provider->CreateResource( |
2974 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2924 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
2975 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 2925 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
2976 GL_INNOCENT_CONTEXT_RESET_ARB); | 2926 GL_INNOCENT_CONTEXT_RESET_ARB); |
2977 | 2927 |
2978 resource_provider->AcquirePixelRasterBuffer(id); | 2928 resource_provider->AcquirePixelRasterBuffer(id); |
2979 SkCanvas* raster_canvas = resource_provider->MapPixelRasterBuffer(id); | 2929 SkCanvas* raster_canvas = resource_provider->MapPixelRasterBuffer(id); |
(...skipping 17 matching lines...) Expand all Loading... |
2997 CHECK(output_surface->BindToClient(&output_surface_client)); | 2947 CHECK(output_surface->BindToClient(&output_surface_client)); |
2998 | 2948 |
2999 const int kWidth = 2; | 2949 const int kWidth = 2; |
3000 const int kHeight = 2; | 2950 const int kHeight = 2; |
3001 gfx::Size size(kWidth, kHeight); | 2951 gfx::Size size(kWidth, kHeight); |
3002 ResourceFormat format = RGBA_8888; | 2952 ResourceFormat format = RGBA_8888; |
3003 ResourceProvider::ResourceId id = 0; | 2953 ResourceProvider::ResourceId id = 0; |
3004 const unsigned kTextureId = 123u; | 2954 const unsigned kTextureId = 123u; |
3005 const unsigned kImageId = 234u; | 2955 const unsigned kImageId = 234u; |
3006 | 2956 |
3007 scoped_ptr<ResourceProvider> resource_provider( | 2957 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
3008 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2958 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
3009 | 2959 |
3010 id = resource_provider->CreateResource( | 2960 id = resource_provider->CreateResource( |
3011 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2961 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
3012 | 2962 |
3013 const int kStride = 4; | 2963 const int kStride = 4; |
3014 void* dummy_mapped_buffer_address = NULL; | 2964 void* dummy_mapped_buffer_address = NULL; |
3015 EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES)) | 2965 EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES)) |
3016 .WillOnce(Return(kImageId)) | 2966 .WillOnce(Return(kImageId)) |
3017 .RetiresOnSaturation(); | 2967 .RetiresOnSaturation(); |
3018 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId, | 2968 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3089 scoped_ptr<OutputSurface> output_surface( | 3039 scoped_ptr<OutputSurface> output_surface( |
3090 FakeOutputSurface::CreateSoftware(make_scoped_ptr( | 3040 FakeOutputSurface::CreateSoftware(make_scoped_ptr( |
3091 new SoftwareOutputDevice))); | 3041 new SoftwareOutputDevice))); |
3092 CHECK(output_surface->BindToClient(&output_surface_client)); | 3042 CHECK(output_surface->BindToClient(&output_surface_client)); |
3093 | 3043 |
3094 gfx::Size size(1, 1); | 3044 gfx::Size size(1, 1); |
3095 ResourceFormat format = RGBA_8888; | 3045 ResourceFormat format = RGBA_8888; |
3096 ResourceProvider::ResourceId id = 0; | 3046 ResourceProvider::ResourceId id = 0; |
3097 const uint32_t kBadBeef = 0xbadbeef; | 3047 const uint32_t kBadBeef = 0xbadbeef; |
3098 | 3048 |
3099 scoped_ptr<ResourceProvider> resource_provider( | 3049 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
3100 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 3050 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
3101 | 3051 |
3102 id = resource_provider->CreateResource( | 3052 id = resource_provider->CreateResource( |
3103 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3053 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
3104 | 3054 |
3105 SkBitmap bitmap; | 3055 SkBitmap bitmap; |
3106 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); | 3056 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); |
3107 bitmap.allocPixels(); | 3057 bitmap.allocPixels(); |
3108 *(bitmap.getAddr32(0, 0)) = kBadBeef; | 3058 *(bitmap.getAddr32(0, 0)) = kBadBeef; |
3109 SkCanvas* canvas = resource_provider->MapImageRasterBuffer(id); | 3059 SkCanvas* canvas = resource_provider->MapImageRasterBuffer(id); |
3110 ASSERT_TRUE(!!canvas); | 3060 ASSERT_TRUE(!!canvas); |
(...skipping 27 matching lines...) Expand all Loading... |
3138 CheckCreateResource(ResourceProvider::GLTexture, resource_provider, context); | 3088 CheckCreateResource(ResourceProvider::GLTexture, resource_provider, context); |
3139 } | 3089 } |
3140 | 3090 |
3141 TEST(ResourceProviderTest, BasicInitializeGLSoftware) { | 3091 TEST(ResourceProviderTest, BasicInitializeGLSoftware) { |
3142 scoped_ptr<ContextSharedData> shared_data = ContextSharedData::Create(); | 3092 scoped_ptr<ContextSharedData> shared_data = ContextSharedData::Create(); |
3143 FakeOutputSurfaceClient client; | 3093 FakeOutputSurfaceClient client; |
3144 scoped_ptr<FakeOutputSurface> output_surface( | 3094 scoped_ptr<FakeOutputSurface> output_surface( |
3145 FakeOutputSurface::CreateDeferredGL( | 3095 FakeOutputSurface::CreateDeferredGL( |
3146 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice))); | 3096 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice))); |
3147 EXPECT_TRUE(output_surface->BindToClient(&client)); | 3097 EXPECT_TRUE(output_surface->BindToClient(&client)); |
3148 scoped_ptr<ResourceProvider> resource_provider( | 3098 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
3149 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 3099 new TestSharedBitmapManager()); |
| 3100 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 3101 output_surface.get(), shared_bitmap_manager.get(), 0, false, 1)); |
3150 | 3102 |
3151 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); | 3103 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); |
3152 | 3104 |
3153 InitializeGLAndCheck(shared_data.get(), | 3105 InitializeGLAndCheck(shared_data.get(), |
3154 resource_provider.get(), | 3106 resource_provider.get(), |
3155 output_surface.get()); | 3107 output_surface.get()); |
3156 | 3108 |
3157 resource_provider->InitializeSoftware(); | 3109 resource_provider->InitializeSoftware(); |
3158 output_surface->ReleaseGL(); | 3110 output_surface->ReleaseGL(); |
3159 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); | 3111 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3256 | 3208 |
3257 TEST(ResourceProviderTest, TextureAllocationChunkSize) { | 3209 TEST(ResourceProviderTest, TextureAllocationChunkSize) { |
3258 scoped_ptr<TextureIdAllocationTrackingContext> context_owned( | 3210 scoped_ptr<TextureIdAllocationTrackingContext> context_owned( |
3259 new TextureIdAllocationTrackingContext); | 3211 new TextureIdAllocationTrackingContext); |
3260 TextureIdAllocationTrackingContext* context = context_owned.get(); | 3212 TextureIdAllocationTrackingContext* context = context_owned.get(); |
3261 | 3213 |
3262 FakeOutputSurfaceClient output_surface_client; | 3214 FakeOutputSurfaceClient output_surface_client; |
3263 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 3215 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
3264 context_owned.PassAs<TestWebGraphicsContext3D>())); | 3216 context_owned.PassAs<TestWebGraphicsContext3D>())); |
3265 CHECK(output_surface->BindToClient(&output_surface_client)); | 3217 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 3218 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 3219 new TestSharedBitmapManager()); |
3266 | 3220 |
3267 gfx::Size size(1, 1); | 3221 gfx::Size size(1, 1); |
3268 ResourceFormat format = RGBA_8888; | 3222 ResourceFormat format = RGBA_8888; |
3269 | 3223 |
3270 { | 3224 { |
3271 size_t kTextureAllocationChunkSize = 1; | 3225 size_t kTextureAllocationChunkSize = 1; |
3272 scoped_ptr<ResourceProvider> resource_provider( | 3226 scoped_ptr<ResourceProvider> resource_provider( |
3273 ResourceProvider::Create(output_surface.get(), | 3227 ResourceProvider::Create(output_surface.get(), |
3274 NULL, | 3228 shared_bitmap_manager.get(), |
3275 0, | 3229 0, |
3276 false, | 3230 false, |
3277 kTextureAllocationChunkSize)); | 3231 kTextureAllocationChunkSize)); |
3278 | 3232 |
3279 ResourceProvider::ResourceId id = resource_provider->CreateResource( | 3233 ResourceProvider::ResourceId id = resource_provider->CreateResource( |
3280 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3234 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
3281 resource_provider->AllocateForTesting(id); | 3235 resource_provider->AllocateForTesting(id); |
3282 Mock::VerifyAndClearExpectations(context); | 3236 Mock::VerifyAndClearExpectations(context); |
3283 | 3237 |
3284 DCHECK_EQ(2u, context->PeekTextureId()); | 3238 DCHECK_EQ(2u, context->PeekTextureId()); |
3285 resource_provider->DeleteResource(id); | 3239 resource_provider->DeleteResource(id); |
3286 } | 3240 } |
3287 | 3241 |
3288 { | 3242 { |
3289 size_t kTextureAllocationChunkSize = 8; | 3243 size_t kTextureAllocationChunkSize = 8; |
3290 scoped_ptr<ResourceProvider> resource_provider( | 3244 scoped_ptr<ResourceProvider> resource_provider( |
3291 ResourceProvider::Create(output_surface.get(), | 3245 ResourceProvider::Create(output_surface.get(), |
3292 NULL, | 3246 shared_bitmap_manager.get(), |
3293 0, | 3247 0, |
3294 false, | 3248 false, |
3295 kTextureAllocationChunkSize)); | 3249 kTextureAllocationChunkSize)); |
3296 | 3250 |
3297 ResourceProvider::ResourceId id = resource_provider->CreateResource( | 3251 ResourceProvider::ResourceId id = resource_provider->CreateResource( |
3298 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3252 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
3299 resource_provider->AllocateForTesting(id); | 3253 resource_provider->AllocateForTesting(id); |
3300 Mock::VerifyAndClearExpectations(context); | 3254 Mock::VerifyAndClearExpectations(context); |
3301 | 3255 |
3302 DCHECK_EQ(10u, context->PeekTextureId()); | 3256 DCHECK_EQ(10u, context->PeekTextureId()); |
3303 resource_provider->DeleteResource(id); | 3257 resource_provider->DeleteResource(id); |
3304 } | 3258 } |
3305 } | 3259 } |
3306 | 3260 |
3307 } // namespace | 3261 } // namespace |
3308 } // namespace cc | 3262 } // namespace cc |
OLD | NEW |