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

Side by Side Diff: cc/scoped_resource_unittest.cc

Issue 11578019: Remove the pools from the ResourceProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-resolve against HEAD Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « cc/scoped_resource.cc ('k') | cc/software_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/scoped_resource.h" 5 #include "cc/scoped_resource.h"
6 6
7 #include "cc/renderer.h" 7 #include "cc/renderer.h"
8 #include "cc/test/fake_output_surface.h" 8 #include "cc/test/fake_output_surface.h"
9 #include "cc/test/tiled_layer_test_common.h" 9 #include "cc/test/tiled_layer_test_common.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 16 matching lines...) Expand all
27 // New scoped textures do not have a size yet. 27 // New scoped textures do not have a size yet.
28 EXPECT_EQ(gfx::Size(), texture->size()); 28 EXPECT_EQ(gfx::Size(), texture->size());
29 EXPECT_EQ(0u, texture->bytes()); 29 EXPECT_EQ(0u, texture->bytes());
30 } 30 }
31 31
32 TEST(ScopedResourceTest, CreateScopedResource) 32 TEST(ScopedResourceTest, CreateScopedResource)
33 { 33 {
34 scoped_ptr<OutputSurface> context(createFakeOutputSurface()); 34 scoped_ptr<OutputSurface> context(createFakeOutputSurface());
35 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get())); 35 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get()));
36 scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider .get()); 36 scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider .get());
37 texture->Allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourcePr ovider::TextureUsageAny); 37 texture->Allocate(gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsage Any);
38 38
39 // The texture has an allocated byte-size now. 39 // The texture has an allocated byte-size now.
40 size_t expectedBytes = 30 * 30 * 4; 40 size_t expectedBytes = 30 * 30 * 4;
41 EXPECT_EQ(expectedBytes, texture->bytes()); 41 EXPECT_EQ(expectedBytes, texture->bytes());
42 42
43 EXPECT_LT(0u, texture->id()); 43 EXPECT_LT(0u, texture->id());
44 EXPECT_EQ(GL_RGBA, texture->format()); 44 EXPECT_EQ(GL_RGBA, texture->format());
45 EXPECT_EQ(gfx::Size(30, 30), texture->size()); 45 EXPECT_EQ(gfx::Size(30, 30), texture->size());
46 } 46 }
47 47
48 TEST(ScopedResourceTest, ScopedResourceIsDeleted) 48 TEST(ScopedResourceTest, ScopedResourceIsDeleted)
49 { 49 {
50 scoped_ptr<OutputSurface> context(createFakeOutputSurface()); 50 scoped_ptr<OutputSurface> context(createFakeOutputSurface());
51 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get())); 51 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get()));
52 52
53 { 53 {
54 scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProv ider.get()); 54 scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProv ider.get());
55 55
56 EXPECT_EQ(0u, resourceProvider->numResources()); 56 EXPECT_EQ(0u, resourceProvider->numResources());
57 texture->Allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, Resour ceProvider::TextureUsageAny); 57 texture->Allocate(gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureU sageAny);
58 EXPECT_LT(0u, texture->id()); 58 EXPECT_LT(0u, texture->id());
59 EXPECT_EQ(1u, resourceProvider->numResources()); 59 EXPECT_EQ(1u, resourceProvider->numResources());
60 } 60 }
61 61
62 EXPECT_EQ(0u, resourceProvider->numResources()); 62 EXPECT_EQ(0u, resourceProvider->numResources());
63 63
64 { 64 {
65 scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProv ider.get()); 65 scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProv ider.get());
66 EXPECT_EQ(0u, resourceProvider->numResources()); 66 EXPECT_EQ(0u, resourceProvider->numResources());
67 texture->Allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, Resour ceProvider::TextureUsageAny); 67 texture->Allocate(gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureU sageAny);
68 EXPECT_LT(0u, texture->id()); 68 EXPECT_LT(0u, texture->id());
69 EXPECT_EQ(1u, resourceProvider->numResources()); 69 EXPECT_EQ(1u, resourceProvider->numResources());
70 texture->Free(); 70 texture->Free();
71 EXPECT_EQ(0u, resourceProvider->numResources()); 71 EXPECT_EQ(0u, resourceProvider->numResources());
72 } 72 }
73 } 73 }
74 74
75 TEST(ScopedResourceTest, LeakScopedResource) 75 TEST(ScopedResourceTest, LeakScopedResource)
76 { 76 {
77 scoped_ptr<OutputSurface> context(createFakeOutputSurface()); 77 scoped_ptr<OutputSurface> context(createFakeOutputSurface());
78 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get())); 78 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get()));
79 79
80 { 80 {
81 scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProv ider.get()); 81 scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProv ider.get());
82 82
83 EXPECT_EQ(0u, resourceProvider->numResources()); 83 EXPECT_EQ(0u, resourceProvider->numResources());
84 texture->Allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, Resour ceProvider::TextureUsageAny); 84 texture->Allocate(gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureU sageAny);
85 EXPECT_LT(0u, texture->id()); 85 EXPECT_LT(0u, texture->id());
86 EXPECT_EQ(1u, resourceProvider->numResources()); 86 EXPECT_EQ(1u, resourceProvider->numResources());
87 87
88 texture->Leak(); 88 texture->Leak();
89 EXPECT_EQ(0u, texture->id()); 89 EXPECT_EQ(0u, texture->id());
90 EXPECT_EQ(1u, resourceProvider->numResources()); 90 EXPECT_EQ(1u, resourceProvider->numResources());
91 91
92 texture->Free(); 92 texture->Free();
93 EXPECT_EQ(0u, texture->id()); 93 EXPECT_EQ(0u, texture->id());
94 EXPECT_EQ(1u, resourceProvider->numResources()); 94 EXPECT_EQ(1u, resourceProvider->numResources());
95 } 95 }
96 96
97 EXPECT_EQ(1u, resourceProvider->numResources()); 97 EXPECT_EQ(1u, resourceProvider->numResources());
98 } 98 }
99 99
100 } // namespace 100 } // namespace
101 } // namespace cc 101 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scoped_resource.cc ('k') | cc/software_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698