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

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

Issue 12665005: cc: Use highp precision for texture coords if available and needed (Closed) Base URL: http://git.chromium.org/chromium/src.git@highp2
Patch Set: rebase after all dependencies landed Created 7 years, 8 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
« no previous file with comments | « cc/resources/resource_update_controller_unittest.cc ('k') | cc/test/pixel_test.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/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/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"
11 #include "third_party/khronos/GLES2/gl2.h" 11 #include "third_party/khronos/GLES2/gl2.h"
12 12
13 namespace cc { 13 namespace cc {
14 namespace { 14 namespace {
15 15
16 TEST(ScopedResourceTest, NewScopedResource) { 16 TEST(ScopedResourceTest, NewScopedResource) {
17 scoped_ptr<OutputSurface> context(CreateFakeOutputSurface()); 17 scoped_ptr<OutputSurface> context(CreateFakeOutputSurface());
18 scoped_ptr<ResourceProvider> resource_provider( 18 scoped_ptr<ResourceProvider> resource_provider(
19 ResourceProvider::Create(context.get())); 19 ResourceProvider::Create(context.get(), 0));
20 scoped_ptr<ScopedResource> texture = 20 scoped_ptr<ScopedResource> texture =
21 ScopedResource::create(resource_provider.get()); 21 ScopedResource::create(resource_provider.get());
22 22
23 // New scoped textures do not hold a texture yet. 23 // New scoped textures do not hold a texture yet.
24 EXPECT_EQ(0u, texture->id()); 24 EXPECT_EQ(0u, texture->id());
25 25
26 // New scoped textures do not have a size yet. 26 // New scoped textures do not have a size yet.
27 EXPECT_EQ(gfx::Size(), texture->size()); 27 EXPECT_EQ(gfx::Size(), texture->size());
28 EXPECT_EQ(0u, texture->bytes()); 28 EXPECT_EQ(0u, texture->bytes());
29 } 29 }
30 30
31 TEST(ScopedResourceTest, CreateScopedResource) { 31 TEST(ScopedResourceTest, CreateScopedResource) {
32 scoped_ptr<OutputSurface> context(CreateFakeOutputSurface()); 32 scoped_ptr<OutputSurface> context(CreateFakeOutputSurface());
33 scoped_ptr<ResourceProvider> resource_provider( 33 scoped_ptr<ResourceProvider> resource_provider(
34 ResourceProvider::Create(context.get())); 34 ResourceProvider::Create(context.get(), 0));
35 scoped_ptr<ScopedResource> texture = 35 scoped_ptr<ScopedResource> texture =
36 ScopedResource::create(resource_provider.get()); 36 ScopedResource::create(resource_provider.get());
37 texture->Allocate( 37 texture->Allocate(
38 gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny); 38 gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
39 39
40 // The texture has an allocated byte-size now. 40 // The texture has an allocated byte-size now.
41 size_t expected_bytes = 30 * 30 * 4; 41 size_t expected_bytes = 30 * 30 * 4;
42 EXPECT_EQ(expected_bytes, texture->bytes()); 42 EXPECT_EQ(expected_bytes, texture->bytes());
43 43
44 EXPECT_LT(0u, texture->id()); 44 EXPECT_LT(0u, texture->id());
45 EXPECT_EQ(static_cast<unsigned>(GL_RGBA), texture->format()); 45 EXPECT_EQ(static_cast<unsigned>(GL_RGBA), texture->format());
46 EXPECT_EQ(gfx::Size(30, 30), texture->size()); 46 EXPECT_EQ(gfx::Size(30, 30), texture->size());
47 } 47 }
48 48
49 TEST(ScopedResourceTest, ScopedResourceIsDeleted) { 49 TEST(ScopedResourceTest, ScopedResourceIsDeleted) {
50 scoped_ptr<OutputSurface> context(CreateFakeOutputSurface()); 50 scoped_ptr<OutputSurface> context(CreateFakeOutputSurface());
51 scoped_ptr<ResourceProvider> resource_provider( 51 scoped_ptr<ResourceProvider> resource_provider(
52 ResourceProvider::Create(context.get())); 52 ResourceProvider::Create(context.get(), 0));
53 { 53 {
54 scoped_ptr<ScopedResource> texture = 54 scoped_ptr<ScopedResource> texture =
55 ScopedResource::create(resource_provider.get()); 55 ScopedResource::create(resource_provider.get());
56 56
57 EXPECT_EQ(0u, resource_provider->num_resources()); 57 EXPECT_EQ(0u, resource_provider->num_resources());
58 texture->Allocate( 58 texture->Allocate(
59 gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny); 59 gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
60 EXPECT_LT(0u, texture->id()); 60 EXPECT_LT(0u, texture->id());
61 EXPECT_EQ(1u, resource_provider->num_resources()); 61 EXPECT_EQ(1u, resource_provider->num_resources());
62 } 62 }
63 63
64 EXPECT_EQ(0u, resource_provider->num_resources()); 64 EXPECT_EQ(0u, resource_provider->num_resources());
65 { 65 {
66 scoped_ptr<ScopedResource> texture = 66 scoped_ptr<ScopedResource> texture =
67 ScopedResource::create(resource_provider.get()); 67 ScopedResource::create(resource_provider.get());
68 EXPECT_EQ(0u, resource_provider->num_resources()); 68 EXPECT_EQ(0u, resource_provider->num_resources());
69 texture->Allocate( 69 texture->Allocate(
70 gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny); 70 gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
71 EXPECT_LT(0u, texture->id()); 71 EXPECT_LT(0u, texture->id());
72 EXPECT_EQ(1u, resource_provider->num_resources()); 72 EXPECT_EQ(1u, resource_provider->num_resources());
73 texture->Free(); 73 texture->Free();
74 EXPECT_EQ(0u, resource_provider->num_resources()); 74 EXPECT_EQ(0u, resource_provider->num_resources());
75 } 75 }
76 } 76 }
77 77
78 TEST(ScopedResourceTest, LeakScopedResource) { 78 TEST(ScopedResourceTest, LeakScopedResource) {
79 scoped_ptr<OutputSurface> context(CreateFakeOutputSurface()); 79 scoped_ptr<OutputSurface> context(CreateFakeOutputSurface());
80 scoped_ptr<ResourceProvider> resource_provider( 80 scoped_ptr<ResourceProvider> resource_provider(
81 ResourceProvider::Create(context.get())); 81 ResourceProvider::Create(context.get(), 0));
82 { 82 {
83 scoped_ptr<ScopedResource> texture = 83 scoped_ptr<ScopedResource> texture =
84 ScopedResource::create(resource_provider.get()); 84 ScopedResource::create(resource_provider.get());
85 85
86 EXPECT_EQ(0u, resource_provider->num_resources()); 86 EXPECT_EQ(0u, resource_provider->num_resources());
87 texture->Allocate( 87 texture->Allocate(
88 gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny); 88 gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
89 EXPECT_LT(0u, texture->id()); 89 EXPECT_LT(0u, texture->id());
90 EXPECT_EQ(1u, resource_provider->num_resources()); 90 EXPECT_EQ(1u, resource_provider->num_resources());
91 91
92 texture->Leak(); 92 texture->Leak();
93 EXPECT_EQ(0u, texture->id()); 93 EXPECT_EQ(0u, texture->id());
94 EXPECT_EQ(1u, resource_provider->num_resources()); 94 EXPECT_EQ(1u, resource_provider->num_resources());
95 95
96 texture->Free(); 96 texture->Free();
97 EXPECT_EQ(0u, texture->id()); 97 EXPECT_EQ(0u, texture->id());
98 EXPECT_EQ(1u, resource_provider->num_resources()); 98 EXPECT_EQ(1u, resource_provider->num_resources());
99 } 99 }
100 100
101 EXPECT_EQ(1u, resource_provider->num_resources()); 101 EXPECT_EQ(1u, resource_provider->num_resources());
102 } 102 }
103 103
104 } // namespace 104 } // namespace
105 } // namespace cc 105 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_update_controller_unittest.cc ('k') | cc/test/pixel_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698