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

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

Issue 22870016: Update the nine patch layer to use UI resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: UIResourceBitmap holds SkPixelRef* instead of uint8_t* Created 7 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
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 6327 matching lines...) Expand 10 before | Expand all | Expand 10 after
6338 6338
6339 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { 6339 TEST_F(LayerTreeHostImplTest, UIResourceManagement) {
6340 scoped_ptr<TestWebGraphicsContext3D> context = 6340 scoped_ptr<TestWebGraphicsContext3D> context =
6341 TestWebGraphicsContext3D::Create(); 6341 TestWebGraphicsContext3D::Create();
6342 TestWebGraphicsContext3D* context3d = context.get(); 6342 TestWebGraphicsContext3D* context3d = context.get();
6343 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); 6343 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface();
6344 host_impl_->InitializeRenderer(output_surface.Pass()); 6344 host_impl_->InitializeRenderer(output_surface.Pass());
6345 6345
6346 EXPECT_EQ(0u, context3d->NumTextures()); 6346 EXPECT_EQ(0u, context3d->NumTextures());
6347 6347
6348 SkBitmap skbitmap;
6349 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
6350 skbitmap.allocPixels();
6351 skbitmap.setImmutable();
6352
6348 UIResourceId ui_resource_id = 1; 6353 UIResourceId ui_resource_id = 1;
6349 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create( 6354 UIResourceBitmap bitmap(skbitmap);
6350 new uint8_t[1], UIResourceBitmap::RGBA8, gfx::Size(1, 1));
6351 host_impl_->CreateUIResource(ui_resource_id, bitmap); 6355 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6352 EXPECT_EQ(1u, context3d->NumTextures()); 6356 EXPECT_EQ(1u, context3d->NumTextures());
6353 ResourceProvider::ResourceId id1 = 6357 ResourceProvider::ResourceId id1 =
6354 host_impl_->ResourceIdForUIResource(ui_resource_id); 6358 host_impl_->ResourceIdForUIResource(ui_resource_id);
6355 EXPECT_NE(0u, id1); 6359 EXPECT_NE(0u, id1);
6356 6360
6357 // Multiple requests with the same id is allowed. The previous texture is 6361 // Multiple requests with the same id is allowed. The previous texture is
6358 // deleted. 6362 // deleted.
6359 host_impl_->CreateUIResource(ui_resource_id, bitmap); 6363 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6360 EXPECT_EQ(1u, context3d->NumTextures()); 6364 EXPECT_EQ(1u, context3d->NumTextures());
(...skipping 15 matching lines...) Expand all
6376 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); 6380 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id));
6377 EXPECT_EQ(0u, context3d->NumTextures()); 6381 EXPECT_EQ(0u, context3d->NumTextures());
6378 6382
6379 // Should not change state for multiple deletion on one UIResourceId 6383 // Should not change state for multiple deletion on one UIResourceId
6380 host_impl_->DeleteUIResource(ui_resource_id); 6384 host_impl_->DeleteUIResource(ui_resource_id);
6381 EXPECT_EQ(0u, context3d->NumTextures()); 6385 EXPECT_EQ(0u, context3d->NumTextures());
6382 } 6386 }
6383 6387
6384 } // namespace 6388 } // namespace
6385 } // namespace cc 6389 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698