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

Side by Side Diff: cc/resources/scoped_resource_unittest.cc

Issue 648293006: cc: turn on distance field text on animated layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved dff setting from rasterprovider to gpurasterpool Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/scoped_resource.h" 5 #include "cc/resources/scoped_resource.h"
6 6
7 #include "cc/output/renderer.h" 7 #include "cc/output/renderer.h"
8 #include "cc/test/fake_output_surface.h" 8 #include "cc/test/fake_output_surface.h"
9 #include "cc/test/fake_output_surface_client.h" 9 #include "cc/test/fake_output_surface_client.h"
10 #include "cc/test/test_shared_bitmap_manager.h" 10 #include "cc/test/test_shared_bitmap_manager.h"
(...skipping 10 matching lines...) Expand all
21 21
22 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 22 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
23 new TestSharedBitmapManager()); 23 new TestSharedBitmapManager());
24 scoped_ptr<ResourceProvider> resource_provider( 24 scoped_ptr<ResourceProvider> resource_provider(
25 ResourceProvider::Create(output_surface.get(), 25 ResourceProvider::Create(output_surface.get(),
26 shared_bitmap_manager.get(), 26 shared_bitmap_manager.get(),
27 NULL, 27 NULL,
28 NULL, 28 NULL,
29 0, 29 0,
30 false, 30 false,
31 1, 31 1));
32 false));
33 scoped_ptr<ScopedResource> texture = 32 scoped_ptr<ScopedResource> texture =
34 ScopedResource::Create(resource_provider.get()); 33 ScopedResource::Create(resource_provider.get());
35 34
36 // New scoped textures do not hold a texture yet. 35 // New scoped textures do not hold a texture yet.
37 EXPECT_EQ(0u, texture->id()); 36 EXPECT_EQ(0u, texture->id());
38 37
39 // New scoped textures do not have a size yet. 38 // New scoped textures do not have a size yet.
40 EXPECT_EQ(gfx::Size(), texture->size()); 39 EXPECT_EQ(gfx::Size(), texture->size());
41 EXPECT_EQ(0u, texture->bytes()); 40 EXPECT_EQ(0u, texture->bytes());
42 } 41 }
43 42
44 TEST(ScopedResourceTest, CreateScopedResource) { 43 TEST(ScopedResourceTest, CreateScopedResource) {
45 FakeOutputSurfaceClient output_surface_client; 44 FakeOutputSurfaceClient output_surface_client;
46 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); 45 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
47 CHECK(output_surface->BindToClient(&output_surface_client)); 46 CHECK(output_surface->BindToClient(&output_surface_client));
48 47
49 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 48 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
50 new TestSharedBitmapManager()); 49 new TestSharedBitmapManager());
51 scoped_ptr<ResourceProvider> resource_provider( 50 scoped_ptr<ResourceProvider> resource_provider(
52 ResourceProvider::Create(output_surface.get(), 51 ResourceProvider::Create(output_surface.get(),
53 shared_bitmap_manager.get(), 52 shared_bitmap_manager.get(),
54 NULL, 53 NULL,
55 NULL, 54 NULL,
56 0, 55 0,
57 false, 56 false,
58 1, 57 1));
59 false));
60 scoped_ptr<ScopedResource> texture = 58 scoped_ptr<ScopedResource> texture =
61 ScopedResource::Create(resource_provider.get()); 59 ScopedResource::Create(resource_provider.get());
62 texture->Allocate( 60 texture->Allocate(
63 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); 61 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888);
64 62
65 // The texture has an allocated byte-size now. 63 // The texture has an allocated byte-size now.
66 size_t expected_bytes = 30 * 30 * 4; 64 size_t expected_bytes = 30 * 30 * 4;
67 EXPECT_EQ(expected_bytes, texture->bytes()); 65 EXPECT_EQ(expected_bytes, texture->bytes());
68 66
69 EXPECT_LT(0u, texture->id()); 67 EXPECT_LT(0u, texture->id());
70 EXPECT_EQ(static_cast<unsigned>(RGBA_8888), texture->format()); 68 EXPECT_EQ(static_cast<unsigned>(RGBA_8888), texture->format());
71 EXPECT_EQ(gfx::Size(30, 30), texture->size()); 69 EXPECT_EQ(gfx::Size(30, 30), texture->size());
72 } 70 }
73 71
74 TEST(ScopedResourceTest, ScopedResourceIsDeleted) { 72 TEST(ScopedResourceTest, ScopedResourceIsDeleted) {
75 FakeOutputSurfaceClient output_surface_client; 73 FakeOutputSurfaceClient output_surface_client;
76 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); 74 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
77 CHECK(output_surface->BindToClient(&output_surface_client)); 75 CHECK(output_surface->BindToClient(&output_surface_client));
78 76
79 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 77 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
80 new TestSharedBitmapManager()); 78 new TestSharedBitmapManager());
81 scoped_ptr<ResourceProvider> resource_provider( 79 scoped_ptr<ResourceProvider> resource_provider(
82 ResourceProvider::Create(output_surface.get(), 80 ResourceProvider::Create(output_surface.get(),
83 shared_bitmap_manager.get(), 81 shared_bitmap_manager.get(),
84 NULL, 82 NULL,
85 NULL, 83 NULL,
86 0, 84 0,
87 false, 85 false,
88 1, 86 1));
89 false));
90 { 87 {
91 scoped_ptr<ScopedResource> texture = 88 scoped_ptr<ScopedResource> texture =
92 ScopedResource::Create(resource_provider.get()); 89 ScopedResource::Create(resource_provider.get());
93 90
94 EXPECT_EQ(0u, resource_provider->num_resources()); 91 EXPECT_EQ(0u, resource_provider->num_resources());
95 texture->Allocate( 92 texture->Allocate(
96 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); 93 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888);
97 EXPECT_LT(0u, texture->id()); 94 EXPECT_LT(0u, texture->id());
98 EXPECT_EQ(1u, resource_provider->num_resources()); 95 EXPECT_EQ(1u, resource_provider->num_resources());
99 } 96 }
(...skipping 19 matching lines...) Expand all
119 116
120 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 117 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
121 new TestSharedBitmapManager()); 118 new TestSharedBitmapManager());
122 scoped_ptr<ResourceProvider> resource_provider( 119 scoped_ptr<ResourceProvider> resource_provider(
123 ResourceProvider::Create(output_surface.get(), 120 ResourceProvider::Create(output_surface.get(),
124 shared_bitmap_manager.get(), 121 shared_bitmap_manager.get(),
125 NULL, 122 NULL,
126 NULL, 123 NULL,
127 0, 124 0,
128 false, 125 false,
129 1, 126 1));
130 false));
131 { 127 {
132 scoped_ptr<ScopedResource> texture = 128 scoped_ptr<ScopedResource> texture =
133 ScopedResource::Create(resource_provider.get()); 129 ScopedResource::Create(resource_provider.get());
134 130
135 EXPECT_EQ(0u, resource_provider->num_resources()); 131 EXPECT_EQ(0u, resource_provider->num_resources());
136 texture->Allocate( 132 texture->Allocate(
137 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); 133 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888);
138 EXPECT_LT(0u, texture->id()); 134 EXPECT_LT(0u, texture->id());
139 EXPECT_EQ(1u, resource_provider->num_resources()); 135 EXPECT_EQ(1u, resource_provider->num_resources());
140 136
141 texture->Leak(); 137 texture->Leak();
142 EXPECT_EQ(0u, texture->id()); 138 EXPECT_EQ(0u, texture->id());
143 EXPECT_EQ(1u, resource_provider->num_resources()); 139 EXPECT_EQ(1u, resource_provider->num_resources());
144 140
145 texture->Free(); 141 texture->Free();
146 EXPECT_EQ(0u, texture->id()); 142 EXPECT_EQ(0u, texture->id());
147 EXPECT_EQ(1u, resource_provider->num_resources()); 143 EXPECT_EQ(1u, resource_provider->num_resources());
148 } 144 }
149 145
150 EXPECT_EQ(1u, resource_provider->num_resources()); 146 EXPECT_EQ(1u, resource_provider->num_resources());
151 } 147 }
152 148
153 } // namespace 149 } // namespace
154 } // namespace cc 150 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698