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

Side by Side Diff: cc/layers/scrollbar_layer_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: rebased 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
« no previous file with comments | « cc/layers/painted_scrollbar_layer.cc ('k') | cc/resources/scoped_ui_resource.h » ('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 "base/containers/hash_tables.h" 5 #include "base/containers/hash_tables.h"
6 #include "cc/animation/scrollbar_animation_controller.h" 6 #include "cc/animation/scrollbar_animation_controller.h"
7 #include "cc/debug/test_web_graphics_context_3d.h" 7 #include "cc/debug/test_web_graphics_context_3d.h"
8 #include "cc/layers/append_quads_data.h" 8 #include "cc/layers/append_quads_data.h"
9 #include "cc/layers/painted_scrollbar_layer.h" 9 #include "cc/layers/painted_scrollbar_layer.h"
10 #include "cc/layers/painted_scrollbar_layer_impl.h" 10 #include "cc/layers/painted_scrollbar_layer_impl.h"
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 : LayerTreeHost(client, settings), 518 : LayerTreeHost(client, settings),
519 next_id_(1), 519 next_id_(1),
520 total_ui_resource_created_(0), 520 total_ui_resource_created_(0),
521 total_ui_resource_deleted_(0) { 521 total_ui_resource_deleted_(0) {
522 Initialize(NULL); 522 Initialize(NULL);
523 } 523 }
524 524
525 virtual UIResourceId CreateUIResource(UIResourceClient* content) OVERRIDE { 525 virtual UIResourceId CreateUIResource(UIResourceClient* content) OVERRIDE {
526 total_ui_resource_created_++; 526 total_ui_resource_created_++;
527 UIResourceId nid = next_id_++; 527 UIResourceId nid = next_id_++;
528 ui_resource_bitmap_map_[nid] = content->GetBitmap(nid, false); 528 ui_resource_bitmap_map_.insert(
529 std::make_pair(nid, content->GetBitmap(nid, false)));
529 return nid; 530 return nid;
530 } 531 }
531 532
532 // Deletes a UI resource. May safely be called more than once. 533 // Deletes a UI resource. May safely be called more than once.
533 virtual void DeleteUIResource(UIResourceId id) OVERRIDE { 534 virtual void DeleteUIResource(UIResourceId id) OVERRIDE {
534 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id); 535 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id);
535 if (iter != ui_resource_bitmap_map_.end()) { 536 if (iter != ui_resource_bitmap_map_.end()) {
536 ui_resource_bitmap_map_.erase(iter); 537 ui_resource_bitmap_map_.erase(iter);
537 total_ui_resource_deleted_++; 538 total_ui_resource_deleted_++;
538 } 539 }
539 } 540 }
540 541
541 size_t UIResourceCount() { return ui_resource_bitmap_map_.size(); } 542 size_t UIResourceCount() { return ui_resource_bitmap_map_.size(); }
542 int TotalUIResourceDeleted() { return total_ui_resource_deleted_; } 543 int TotalUIResourceDeleted() { return total_ui_resource_deleted_; }
543 int TotalUIResourceCreated() { return total_ui_resource_created_; } 544 int TotalUIResourceCreated() { return total_ui_resource_created_; }
544 545
545 gfx::Size ui_resource_size(UIResourceId id) { 546 gfx::Size ui_resource_size(UIResourceId id) {
546 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id); 547 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id);
547 if (iter != ui_resource_bitmap_map_.end() && iter->second.get()) 548 if (iter != ui_resource_bitmap_map_.end())
548 return iter->second->GetSize(); 549 return iter->second.GetSize();
549 return gfx::Size(); 550 return gfx::Size();
550 } 551 }
551 552
552 private: 553 private:
553 typedef base::hash_map<UIResourceId, scoped_refptr<UIResourceBitmap> > 554 typedef base::hash_map<UIResourceId, UIResourceBitmap>
554 UIResourceBitmapMap; 555 UIResourceBitmapMap;
555 UIResourceBitmapMap ui_resource_bitmap_map_; 556 UIResourceBitmapMap ui_resource_bitmap_map_;
556 557
557 int next_id_; 558 int next_id_;
558 int total_ui_resource_created_; 559 int total_ui_resource_created_;
559 int total_ui_resource_deleted_; 560 int total_ui_resource_deleted_;
560 }; 561 };
561 562
562 563
563 class ScrollbarLayerTestResourceCreation : public testing::Test { 564 class ScrollbarLayerTestResourceCreation : public testing::Test {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) { 730 TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) {
730 // Pick a test scale that moves the scrollbar's (non-zero) position to 731 // Pick a test scale that moves the scrollbar's (non-zero) position to
731 // a non-pixel-aligned location. 732 // a non-pixel-aligned location.
732 TestResourceUpload(.041f); 733 TestResourceUpload(.041f);
733 TestResourceUpload(1.41f); 734 TestResourceUpload(1.41f);
734 TestResourceUpload(4.1f); 735 TestResourceUpload(4.1f);
735 } 736 }
736 737
737 } // namespace 738 } // namespace
738 } // namespace cc 739 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/painted_scrollbar_layer.cc ('k') | cc/resources/scoped_ui_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698