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

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

Issue 1202843008: cc: Fix BytesPerPixel issue and refactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments. Created 5 years, 5 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/fake_resource_provider.h" 10 #include "cc/test/fake_resource_provider.h"
(...skipping 13 matching lines...) Expand all
24 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 24 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create(
25 output_surface.get(), shared_bitmap_manager.get()); 25 output_surface.get(), shared_bitmap_manager.get());
26 scoped_ptr<ScopedResource> texture = 26 scoped_ptr<ScopedResource> texture =
27 ScopedResource::Create(resource_provider.get()); 27 ScopedResource::Create(resource_provider.get());
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(gfx::Size(), texture->size()); 33 EXPECT_EQ(gfx::Size(), texture->size());
34 EXPECT_EQ(0u, Resource::UncheckedMemorySizeBytes(texture->size(), 34 EXPECT_EQ(0u, ResourceUtil::UncheckedSizeInBytes(texture->size(),
35 texture->format())); 35 texture->format()));
36 } 36 }
37 37
38 TEST(ScopedResourceTest, CreateScopedResource) { 38 TEST(ScopedResourceTest, CreateScopedResource) {
39 FakeOutputSurfaceClient output_surface_client; 39 FakeOutputSurfaceClient output_surface_client;
40 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); 40 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
41 CHECK(output_surface->BindToClient(&output_surface_client)); 41 CHECK(output_surface->BindToClient(&output_surface_client));
42 42
43 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 43 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
44 new TestSharedBitmapManager()); 44 new TestSharedBitmapManager());
45 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 45 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create(
46 output_surface.get(), shared_bitmap_manager.get()); 46 output_surface.get(), shared_bitmap_manager.get());
47 scoped_ptr<ScopedResource> texture = 47 scoped_ptr<ScopedResource> texture =
48 ScopedResource::Create(resource_provider.get()); 48 ScopedResource::Create(resource_provider.get());
49 texture->Allocate(gfx::Size(30, 30), ResourceProvider::TEXTURE_HINT_IMMUTABLE, 49 texture->Allocate(gfx::Size(30, 30), ResourceProvider::TEXTURE_HINT_IMMUTABLE,
50 RGBA_8888); 50 RGBA_8888);
51 51
52 // The texture has an allocated byte-size now. 52 // The texture has an allocated byte-size now.
53 size_t expected_bytes = 30 * 30 * 4; 53 size_t expected_bytes = 30 * 30 * 4;
54 EXPECT_EQ(expected_bytes, Resource::UncheckedMemorySizeBytes( 54 EXPECT_EQ(expected_bytes, ResourceUtil::UncheckedSizeInBytes(
55 texture->size(), texture->format())); 55 texture->size(), texture->format()));
56 56
57 EXPECT_LT(0u, texture->id()); 57 EXPECT_LT(0u, texture->id());
58 EXPECT_EQ(static_cast<unsigned>(RGBA_8888), texture->format()); 58 EXPECT_EQ(static_cast<unsigned>(RGBA_8888), texture->format());
59 EXPECT_EQ(gfx::Size(30, 30), texture->size()); 59 EXPECT_EQ(gfx::Size(30, 30), texture->size());
60 } 60 }
61 61
62 TEST(ScopedResourceTest, ScopedResourceIsDeleted) { 62 TEST(ScopedResourceTest, ScopedResourceIsDeleted) {
63 FakeOutputSurfaceClient output_surface_client; 63 FakeOutputSurfaceClient output_surface_client;
64 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); 64 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
(...skipping 23 matching lines...) Expand all
88 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); 88 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888);
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 texture->Free(); 91 texture->Free();
92 EXPECT_EQ(0u, resource_provider->num_resources()); 92 EXPECT_EQ(0u, resource_provider->num_resources());
93 } 93 }
94 } 94 }
95 95
96 } // namespace 96 } // namespace
97 } // namespace cc 97 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698