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/scoped_resource.h" | 5 #include "cc/resources/scoped_resource.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "cc/output/renderer.h" | 9 #include "cc/output/renderer.h" |
10 #include "cc/test/fake_output_surface.h" | 10 #include "cc/test/fake_output_surface.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 CHECK(output_surface->BindToClient(&output_surface_client)); | 46 CHECK(output_surface->BindToClient(&output_surface_client)); |
47 | 47 |
48 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 48 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
49 new TestSharedBitmapManager()); | 49 new TestSharedBitmapManager()); |
50 std::unique_ptr<ResourceProvider> resource_provider = | 50 std::unique_ptr<ResourceProvider> resource_provider = |
51 FakeResourceProvider::Create(output_surface.get(), | 51 FakeResourceProvider::Create(output_surface.get(), |
52 shared_bitmap_manager.get()); | 52 shared_bitmap_manager.get()); |
53 std::unique_ptr<ScopedResource> texture = | 53 std::unique_ptr<ScopedResource> texture = |
54 ScopedResource::Create(resource_provider.get()); | 54 ScopedResource::Create(resource_provider.get()); |
55 texture->Allocate(gfx::Size(30, 30), ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 55 texture->Allocate(gfx::Size(30, 30), ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
56 RGBA_8888); | 56 RGBA_8888, gfx::ColorSpace()); |
57 | 57 |
58 // The texture has an allocated byte-size now. | 58 // The texture has an allocated byte-size now. |
59 size_t expected_bytes = 30 * 30 * 4; | 59 size_t expected_bytes = 30 * 30 * 4; |
60 EXPECT_EQ(expected_bytes, ResourceUtil::UncheckedSizeInBytes<size_t>( | 60 EXPECT_EQ(expected_bytes, ResourceUtil::UncheckedSizeInBytes<size_t>( |
61 texture->size(), texture->format())); | 61 texture->size(), texture->format())); |
62 | 62 |
63 EXPECT_LT(0u, texture->id()); | 63 EXPECT_LT(0u, texture->id()); |
64 EXPECT_EQ(static_cast<unsigned>(RGBA_8888), texture->format()); | 64 EXPECT_EQ(static_cast<unsigned>(RGBA_8888), texture->format()); |
65 EXPECT_EQ(gfx::Size(30, 30), texture->size()); | 65 EXPECT_EQ(gfx::Size(30, 30), texture->size()); |
66 } | 66 } |
67 | 67 |
68 TEST(ScopedResourceTest, ScopedResourceIsDeleted) { | 68 TEST(ScopedResourceTest, ScopedResourceIsDeleted) { |
69 FakeOutputSurfaceClient output_surface_client; | 69 FakeOutputSurfaceClient output_surface_client; |
70 std::unique_ptr<OutputSurface> output_surface( | 70 std::unique_ptr<OutputSurface> output_surface( |
71 FakeOutputSurface::CreateDelegating3d()); | 71 FakeOutputSurface::CreateDelegating3d()); |
72 CHECK(output_surface->BindToClient(&output_surface_client)); | 72 CHECK(output_surface->BindToClient(&output_surface_client)); |
73 | 73 |
74 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 74 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
75 new TestSharedBitmapManager()); | 75 new TestSharedBitmapManager()); |
76 std::unique_ptr<ResourceProvider> resource_provider = | 76 std::unique_ptr<ResourceProvider> resource_provider = |
77 FakeResourceProvider::Create(output_surface.get(), | 77 FakeResourceProvider::Create(output_surface.get(), |
78 shared_bitmap_manager.get()); | 78 shared_bitmap_manager.get()); |
79 { | 79 { |
80 std::unique_ptr<ScopedResource> texture = | 80 std::unique_ptr<ScopedResource> texture = |
81 ScopedResource::Create(resource_provider.get()); | 81 ScopedResource::Create(resource_provider.get()); |
82 | 82 |
83 EXPECT_EQ(0u, resource_provider->num_resources()); | 83 EXPECT_EQ(0u, resource_provider->num_resources()); |
84 texture->Allocate(gfx::Size(30, 30), | 84 texture->Allocate(gfx::Size(30, 30), |
85 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | 85 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 86 gfx::ColorSpace()); |
86 EXPECT_LT(0u, texture->id()); | 87 EXPECT_LT(0u, texture->id()); |
87 EXPECT_EQ(1u, resource_provider->num_resources()); | 88 EXPECT_EQ(1u, resource_provider->num_resources()); |
88 } | 89 } |
89 | 90 |
90 EXPECT_EQ(0u, resource_provider->num_resources()); | 91 EXPECT_EQ(0u, resource_provider->num_resources()); |
91 { | 92 { |
92 std::unique_ptr<ScopedResource> texture = | 93 std::unique_ptr<ScopedResource> texture = |
93 ScopedResource::Create(resource_provider.get()); | 94 ScopedResource::Create(resource_provider.get()); |
94 EXPECT_EQ(0u, resource_provider->num_resources()); | 95 EXPECT_EQ(0u, resource_provider->num_resources()); |
95 texture->Allocate(gfx::Size(30, 30), | 96 texture->Allocate(gfx::Size(30, 30), |
96 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | 97 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 98 gfx::ColorSpace()); |
97 EXPECT_LT(0u, texture->id()); | 99 EXPECT_LT(0u, texture->id()); |
98 EXPECT_EQ(1u, resource_provider->num_resources()); | 100 EXPECT_EQ(1u, resource_provider->num_resources()); |
99 texture->Free(); | 101 texture->Free(); |
100 EXPECT_EQ(0u, resource_provider->num_resources()); | 102 EXPECT_EQ(0u, resource_provider->num_resources()); |
101 } | 103 } |
102 } | 104 } |
103 | 105 |
104 } // namespace | 106 } // namespace |
105 } // namespace cc | 107 } // namespace cc |
OLD | NEW |