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

Side by Side Diff: trunk/src/cc/layers/scrollbar_layer_unittest.cc

Issue 23740010: Revert 223162 "Update the nine patch layer to use UI resources" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 | Annotate | Revision Log
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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 : LayerTreeHost(client, settings), 520 : LayerTreeHost(client, settings),
521 next_id_(1), 521 next_id_(1),
522 total_ui_resource_created_(0), 522 total_ui_resource_created_(0),
523 total_ui_resource_deleted_(0) { 523 total_ui_resource_deleted_(0) {
524 Initialize(NULL); 524 Initialize(NULL);
525 } 525 }
526 526
527 virtual UIResourceId CreateUIResource(UIResourceClient* content) OVERRIDE { 527 virtual UIResourceId CreateUIResource(UIResourceClient* content) OVERRIDE {
528 total_ui_resource_created_++; 528 total_ui_resource_created_++;
529 UIResourceId nid = next_id_++; 529 UIResourceId nid = next_id_++;
530 ui_resource_bitmap_map_.insert( 530 ui_resource_bitmap_map_[nid] = content->GetBitmap(nid, false);
531 std::make_pair(nid, content->GetBitmap(nid, false)));
532 return nid; 531 return nid;
533 } 532 }
534 533
535 // Deletes a UI resource. May safely be called more than once. 534 // Deletes a UI resource. May safely be called more than once.
536 virtual void DeleteUIResource(UIResourceId id) OVERRIDE { 535 virtual void DeleteUIResource(UIResourceId id) OVERRIDE {
537 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id); 536 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id);
538 if (iter != ui_resource_bitmap_map_.end()) { 537 if (iter != ui_resource_bitmap_map_.end()) {
539 ui_resource_bitmap_map_.erase(iter); 538 ui_resource_bitmap_map_.erase(iter);
540 total_ui_resource_deleted_++; 539 total_ui_resource_deleted_++;
541 } 540 }
542 } 541 }
543 542
544 size_t UIResourceCount() { return ui_resource_bitmap_map_.size(); } 543 size_t UIResourceCount() { return ui_resource_bitmap_map_.size(); }
545 int TotalUIResourceDeleted() { return total_ui_resource_deleted_; } 544 int TotalUIResourceDeleted() { return total_ui_resource_deleted_; }
546 int TotalUIResourceCreated() { return total_ui_resource_created_; } 545 int TotalUIResourceCreated() { return total_ui_resource_created_; }
547 546
548 gfx::Size ui_resource_size(UIResourceId id) { 547 gfx::Size ui_resource_size(UIResourceId id) {
549 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id); 548 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id);
550 if (iter != ui_resource_bitmap_map_.end()) 549 if (iter != ui_resource_bitmap_map_.end() && iter->second.get())
551 return iter->second.GetSize(); 550 return iter->second->GetSize();
552 return gfx::Size(); 551 return gfx::Size();
553 } 552 }
554 553
555 private: 554 private:
556 typedef base::hash_map<UIResourceId, UIResourceBitmap> 555 typedef base::hash_map<UIResourceId, scoped_refptr<UIResourceBitmap> >
557 UIResourceBitmapMap; 556 UIResourceBitmapMap;
558 UIResourceBitmapMap ui_resource_bitmap_map_; 557 UIResourceBitmapMap ui_resource_bitmap_map_;
559 558
560 int next_id_; 559 int next_id_;
561 int total_ui_resource_created_; 560 int total_ui_resource_created_;
562 int total_ui_resource_deleted_; 561 int total_ui_resource_deleted_;
563 }; 562 };
564 563
565 564
566 class ScrollbarLayerTestResourceCreation : public testing::Test { 565 class ScrollbarLayerTestResourceCreation : public testing::Test {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) { 731 TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) {
733 // Pick a test scale that moves the scrollbar's (non-zero) position to 732 // Pick a test scale that moves the scrollbar's (non-zero) position to
734 // a non-pixel-aligned location. 733 // a non-pixel-aligned location.
735 TestResourceUpload(.041f); 734 TestResourceUpload(.041f);
736 TestResourceUpload(1.41f); 735 TestResourceUpload(1.41f);
737 TestResourceUpload(4.1f); 736 TestResourceUpload(4.1f);
738 } 737 }
739 738
740 } // namespace 739 } // namespace
741 } // namespace cc 740 } // namespace cc
OLDNEW
« no previous file with comments | « trunk/src/cc/layers/painted_scrollbar_layer.cc ('k') | trunk/src/cc/resources/scoped_ui_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698