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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 18191020: UI Resource Manager (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Added DCHECK of resource queue size to PushPropertiesTo Created 7 years, 4 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/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 6224 matching lines...) Expand 10 before | Expand all | Expand 10 after
6235 0, ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING); 6235 0, ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING);
6236 host_impl_->SetMemoryPolicy(policy2, false); 6236 host_impl_->SetMemoryPolicy(policy2, false);
6237 EXPECT_EQ(actual_policy, host_impl_->ActualManagedMemoryPolicy()); 6237 EXPECT_EQ(actual_policy, host_impl_->ActualManagedMemoryPolicy());
6238 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); 6238 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_);
6239 EXPECT_EQ(visible_cutoff_value, current_priority_cutoff_value_); 6239 EXPECT_EQ(visible_cutoff_value, current_priority_cutoff_value_);
6240 host_impl_->SetVisible(false); 6240 host_impl_->SetVisible(false);
6241 EXPECT_EQ(policy1.bytes_limit_when_not_visible, current_limit_bytes_); 6241 EXPECT_EQ(policy1.bytes_limit_when_not_visible, current_limit_bytes_);
6242 EXPECT_EQ(not_visible_cutoff_value, current_priority_cutoff_value_); 6242 EXPECT_EQ(not_visible_cutoff_value, current_priority_cutoff_value_);
6243 } 6243 }
6244 6244
6245 TEST_F(LayerTreeHostImplTest, UIResourceManagement) {
6246 scoped_ptr<TestWebGraphicsContext3D> context =
6247 TestWebGraphicsContext3D::Create();
6248 TestWebGraphicsContext3D* context3d = context.get();
6249 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(
6250 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
6251 host_impl_->InitializeRenderer(output_surface.Pass());
6252
6253 EXPECT_EQ(0u, context3d->NumTextures());
6254
6255 UIResourceId ui_resource_id = 1;
6256 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create(
6257 new uint8_t[1], UIResourceBitmap::RGBA8, gfx::Size(1, 1));
6258 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6259 EXPECT_EQ(1u, context3d->NumTextures());
6260 ResourceProvider::ResourceId id1 =
6261 host_impl_->ResourceIdForUIResource(ui_resource_id);
6262 EXPECT_NE(0u, id1);
6263
6264 // Multiple requests with the same id is allowed. The previous texture is
6265 // deleted.
6266 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6267 EXPECT_EQ(1u, context3d->NumTextures());
6268 ResourceProvider::ResourceId id2 =
6269 host_impl_->ResourceIdForUIResource(ui_resource_id);
6270 EXPECT_NE(0u, id2);
6271 EXPECT_NE(id1, id2);
6272
6273 // Deleting invalid UIResourceId is allowed and does not change state.
6274 host_impl_->DeleteUIResource(-1);
6275 EXPECT_EQ(1u, context3d->NumTextures());
6276
6277 // Should return zero for invalid UIResourceId. Number of textures should
6278 // not change.
6279 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(-1));
6280 EXPECT_EQ(1u, context3d->NumTextures());
6281
6282 host_impl_->DeleteUIResource(ui_resource_id);
6283 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id));
6284 EXPECT_EQ(0u, context3d->NumTextures());
6285
6286 // Should not change state for multiple deletion on one UIResourceId
6287 host_impl_->DeleteUIResource(ui_resource_id);
6288 EXPECT_EQ(0u, context3d->NumTextures());
6289 }
6290
6245 } // namespace 6291 } // namespace
6246 } // namespace cc 6292 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698