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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/prioritized_resource.h" | 7 #include "cc/prioritized_resource.h" |
8 | 8 |
9 #include "cc/prioritized_resource_manager.h" | 9 #include "cc/prioritized_resource_manager.h" |
| 10 #include "cc/resource.h" |
10 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread | 11 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread |
11 #include "cc/test/fake_graphics_context.h" | 12 #include "cc/test/fake_graphics_context.h" |
12 #include "cc/test/fake_proxy.h" | 13 #include "cc/test/fake_proxy.h" |
13 #include "cc/test/tiled_layer_test_common.h" | 14 #include "cc/test/tiled_layer_test_common.h" |
14 #include "cc/texture.h" | |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 using namespace cc; | 17 using namespace cc; |
18 using namespace WebKitTests; | 18 using namespace WebKitTests; |
19 | 19 |
20 namespace cc { | 20 namespace cc { |
21 | 21 |
22 class PrioritizedResourceTest : public testing::Test { | 22 class PrioritizedResourceTest : public testing::Test { |
23 public: | 23 public: |
24 PrioritizedResourceTest() | 24 PrioritizedResourceTest() |
25 : m_proxy(scoped_ptr<Thread>(NULL)) | 25 : m_proxy(scoped_ptr<Thread>(NULL)) |
26 , m_textureSize(256, 256) | 26 , m_textureSize(256, 256) |
27 , m_textureFormat(GL_RGBA) | 27 , m_textureFormat(GL_RGBA) |
28 , m_context(WebKit::createFakeGraphicsContext()) | 28 , m_context(WebKit::createFakeGraphicsContext()) |
29 { | 29 { |
30 DebugScopedSetImplThread implThread(&m_proxy); | 30 DebugScopedSetImplThread implThread(&m_proxy); |
31 m_resourceProvider = ResourceProvider::create(m_context.get()); | 31 m_resourceProvider = ResourceProvider::create(m_context.get()); |
32 } | 32 } |
33 | 33 |
34 virtual ~PrioritizedResourceTest() | 34 virtual ~PrioritizedResourceTest() |
35 { | 35 { |
36 DebugScopedSetImplThread implThread(&m_proxy); | 36 DebugScopedSetImplThread implThread(&m_proxy); |
37 m_resourceProvider.reset(); | 37 m_resourceProvider.reset(); |
38 } | 38 } |
39 | 39 |
40 size_t texturesMemorySize(size_t textureCount) | 40 size_t texturesMemorySize(size_t textureCount) |
41 { | 41 { |
42 return Texture::memorySizeBytes(m_textureSize, m_textureFormat) * textur
eCount; | 42 return Resource::memorySizeBytes(m_textureSize, m_textureFormat) * textu
reCount; |
43 } | 43 } |
44 | 44 |
45 scoped_ptr<PrioritizedResourceManager> createManager(size_t maxTextures) | 45 scoped_ptr<PrioritizedResourceManager> createManager(size_t maxTextures) |
46 { | 46 { |
47 return PrioritizedResourceManager::create(texturesMemorySize(maxTextures
), 1024, 0, &m_proxy); | 47 return PrioritizedResourceManager::create(texturesMemorySize(maxTextures
), 1024, 0, &m_proxy); |
48 } | 48 } |
49 | 49 |
50 bool validateTexture(scoped_ptr<PrioritizedResource>& texture, bool requestL
ate) | 50 bool validateTexture(scoped_ptr<PrioritizedResource>& texture, bool requestL
ate) |
51 { | 51 { |
52 resourceManagerAssertInvariants(texture->resourceManager()); | 52 resourceManagerAssertInvariants(texture->resourceManager()); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes()); | 699 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes()); |
700 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearby
Bytes()); | 700 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearby
Bytes()); |
701 } | 701 } |
702 | 702 |
703 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(
&m_proxy); | 703 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(
&m_proxy); |
704 resourceManager->clearAllMemory(resourceProvider()); | 704 resourceManager->clearAllMemory(resourceProvider()); |
705 } | 705 } |
706 | 706 |
707 | 707 |
708 } // anonymous namespace | 708 } // anonymous namespace |
OLD | NEW |