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

Side by Side Diff: cc/CCScopedTextureTest.cpp

Issue 10961008: cc: Remove TextureUploaderOption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Settle for removing TextureUploaderOption in this CL. I'll figure out what to do with the uploader … Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « cc/CCResourceProviderTest.cpp ('k') | cc/CCSingleThreadProxy.cpp » ('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 "config.h" 5 #include "config.h"
6 6
7 #include "CCScopedTexture.h" 7 #include "CCScopedTexture.h"
8 8
9 #include "CCRenderer.h" 9 #include "CCRenderer.h"
10 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread 10 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread
11 #include "CCTiledLayerTestCommon.h" 11 #include "CCTiledLayerTestCommon.h"
12 #include "FakeCCGraphicsContext.h" 12 #include "FakeCCGraphicsContext.h"
13 #include "GraphicsContext3D.h" 13 #include "GraphicsContext3D.h"
14 #include <gtest/gtest.h> 14 #include <gtest/gtest.h>
15 15
16 using namespace cc; 16 using namespace cc;
17 using namespace WebKit; 17 using namespace WebKit;
18 using namespace WebKitTests; 18 using namespace WebKitTests;
19 19
20 namespace { 20 namespace {
21 21
22 TEST(CCScopedTextureTest, NewScopedTexture) 22 TEST(CCScopedTextureTest, NewScopedTexture)
23 { 23 {
24 OwnPtr<CCGraphicsContext> context(createFakeCCGraphicsContext()); 24 OwnPtr<CCGraphicsContext> context(createFakeCCGraphicsContext());
25 DebugScopedSetImplThread implThread; 25 DebugScopedSetImplThread implThread;
26 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get(), UnthrottledUploader)); 26 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get()));
27 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.g et()); 27 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.g et());
28 28
29 // New scoped textures do not hold a texture yet. 29 // New scoped textures do not hold a texture yet.
30 EXPECT_EQ(0u, texture->id()); 30 EXPECT_EQ(0u, texture->id());
31 31
32 // New scoped textures do not have a size yet. 32 // New scoped textures do not have a size yet.
33 EXPECT_EQ(IntSize(), texture->size()); 33 EXPECT_EQ(IntSize(), texture->size());
34 EXPECT_EQ(0u, texture->bytes()); 34 EXPECT_EQ(0u, texture->bytes());
35 } 35 }
36 36
37 TEST(CCScopedTextureTest, CreateScopedTexture) 37 TEST(CCScopedTextureTest, CreateScopedTexture)
38 { 38 {
39 OwnPtr<CCGraphicsContext> context(createFakeCCGraphicsContext()); 39 OwnPtr<CCGraphicsContext> context(createFakeCCGraphicsContext());
40 DebugScopedSetImplThread implThread; 40 DebugScopedSetImplThread implThread;
41 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get(), UnthrottledUploader)); 41 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get()));
42 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.g et()); 42 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.g et());
43 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext3D:: RGBA, CCResourceProvider::TextureUsageAny); 43 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext3D:: RGBA, CCResourceProvider::TextureUsageAny);
44 44
45 // The texture has an allocated byte-size now. 45 // The texture has an allocated byte-size now.
46 size_t expectedBytes = 30 * 30 * 4; 46 size_t expectedBytes = 30 * 30 * 4;
47 EXPECT_EQ(expectedBytes, texture->bytes()); 47 EXPECT_EQ(expectedBytes, texture->bytes());
48 48
49 EXPECT_LT(0u, texture->id()); 49 EXPECT_LT(0u, texture->id());
50 EXPECT_EQ(GraphicsContext3D::RGBA, texture->format()); 50 EXPECT_EQ(GraphicsContext3D::RGBA, texture->format());
51 EXPECT_EQ(IntSize(30, 30), texture->size()); 51 EXPECT_EQ(IntSize(30, 30), texture->size());
52 } 52 }
53 53
54 TEST(CCScopedTextureTest, ScopedTextureIsDeleted) 54 TEST(CCScopedTextureTest, ScopedTextureIsDeleted)
55 { 55 {
56 OwnPtr<CCGraphicsContext> context(createFakeCCGraphicsContext()); 56 OwnPtr<CCGraphicsContext> context(createFakeCCGraphicsContext());
57 DebugScopedSetImplThread implThread; 57 DebugScopedSetImplThread implThread;
58 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get(), UnthrottledUploader)); 58 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get()));
59 59
60 { 60 {
61 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvid er.get()); 61 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvid er.get());
62 62
63 EXPECT_EQ(0u, resourceProvider->numResources()); 63 EXPECT_EQ(0u, resourceProvider->numResources());
64 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext 3D::RGBA, CCResourceProvider::TextureUsageAny); 64 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext 3D::RGBA, CCResourceProvider::TextureUsageAny);
65 EXPECT_LT(0u, texture->id()); 65 EXPECT_LT(0u, texture->id());
66 EXPECT_EQ(1u, resourceProvider->numResources()); 66 EXPECT_EQ(1u, resourceProvider->numResources());
67 } 67 }
68 68
69 EXPECT_EQ(0u, resourceProvider->numResources()); 69 EXPECT_EQ(0u, resourceProvider->numResources());
70 70
71 { 71 {
72 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvid er.get()); 72 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvid er.get());
73 EXPECT_EQ(0u, resourceProvider->numResources()); 73 EXPECT_EQ(0u, resourceProvider->numResources());
74 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext 3D::RGBA, CCResourceProvider::TextureUsageAny); 74 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext 3D::RGBA, CCResourceProvider::TextureUsageAny);
75 EXPECT_LT(0u, texture->id()); 75 EXPECT_LT(0u, texture->id());
76 EXPECT_EQ(1u, resourceProvider->numResources()); 76 EXPECT_EQ(1u, resourceProvider->numResources());
77 texture->free(); 77 texture->free();
78 EXPECT_EQ(0u, resourceProvider->numResources()); 78 EXPECT_EQ(0u, resourceProvider->numResources());
79 } 79 }
80 } 80 }
81 81
82 TEST(CCScopedTextureTest, LeakScopedTexture) 82 TEST(CCScopedTextureTest, LeakScopedTexture)
83 { 83 {
84 OwnPtr<CCGraphicsContext> context(createFakeCCGraphicsContext()); 84 OwnPtr<CCGraphicsContext> context(createFakeCCGraphicsContext());
85 DebugScopedSetImplThread implThread; 85 DebugScopedSetImplThread implThread;
86 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get(), UnthrottledUploader)); 86 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get()));
87 87
88 { 88 {
89 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvid er.get()); 89 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvid er.get());
90 90
91 EXPECT_EQ(0u, resourceProvider->numResources()); 91 EXPECT_EQ(0u, resourceProvider->numResources());
92 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext 3D::RGBA, CCResourceProvider::TextureUsageAny); 92 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext 3D::RGBA, CCResourceProvider::TextureUsageAny);
93 EXPECT_LT(0u, texture->id()); 93 EXPECT_LT(0u, texture->id());
94 EXPECT_EQ(1u, resourceProvider->numResources()); 94 EXPECT_EQ(1u, resourceProvider->numResources());
95 95
96 texture->leak(); 96 texture->leak();
97 EXPECT_EQ(0u, texture->id()); 97 EXPECT_EQ(0u, texture->id());
98 EXPECT_EQ(1u, resourceProvider->numResources()); 98 EXPECT_EQ(1u, resourceProvider->numResources());
99 99
100 texture->free(); 100 texture->free();
101 EXPECT_EQ(0u, texture->id()); 101 EXPECT_EQ(0u, texture->id());
102 EXPECT_EQ(1u, resourceProvider->numResources()); 102 EXPECT_EQ(1u, resourceProvider->numResources());
103 } 103 }
104 104
105 EXPECT_EQ(1u, resourceProvider->numResources()); 105 EXPECT_EQ(1u, resourceProvider->numResources());
106 } 106 }
107 107
108 } 108 }
OLDNEW
« no previous file with comments | « cc/CCResourceProviderTest.cpp ('k') | cc/CCSingleThreadProxy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698