OLD | NEW |
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/layers/nine_patch_layer.h" | 5 #include "cc/layers/nine_patch_layer.h" |
6 | 6 |
7 #include "cc/layers/nine_patch_layer_impl.h" | 7 #include "cc/layers/nine_patch_layer_impl.h" |
8 #include "cc/resources/prioritized_resource.h" | 8 #include "cc/resources/prioritized_resource.h" |
9 #include "cc/resources/resource_update.h" | 9 #include "cc/resources/resource_update.h" |
10 #include "cc/resources/resource_update_queue.h" | 10 #include "cc/resources/resource_update_queue.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 void NinePatchLayer::SetBitmap(const SkBitmap& bitmap, gfx::Rect aperture) { | 50 void NinePatchLayer::SetBitmap(const SkBitmap& bitmap, gfx::Rect aperture) { |
51 bitmap_ = bitmap; | 51 bitmap_ = bitmap; |
52 image_aperture_ = aperture; | 52 image_aperture_ = aperture; |
53 bitmap_dirty_ = true; | 53 bitmap_dirty_ = true; |
54 SetNeedsDisplay(); | 54 SetNeedsDisplay(); |
55 } | 55 } |
56 | 56 |
57 bool NinePatchLayer::Update(ResourceUpdateQueue* queue, | 57 bool NinePatchLayer::Update(ResourceUpdateQueue* queue, |
58 const OcclusionTracker* occlusion) { | 58 const OcclusionTracker* occlusion) { |
| 59 bool updated = Layer::Update(queue, occlusion); |
| 60 |
59 CreateUpdaterIfNeeded(); | 61 CreateUpdaterIfNeeded(); |
60 | 62 |
61 if (resource_ && | 63 if (resource_ && |
62 (bitmap_dirty_ || resource_->texture()->resource_id() == 0)) { | 64 (bitmap_dirty_ || resource_->texture()->resource_id() == 0)) { |
63 gfx::Rect content_rect(0, 0, bitmap_.width(), bitmap_.height()); | 65 gfx::Rect content_rect(0, 0, bitmap_.width(), bitmap_.height()); |
64 ResourceUpdate upload = ResourceUpdate::Create(resource_->texture(), | 66 ResourceUpdate upload = ResourceUpdate::Create(resource_->texture(), |
65 &bitmap_, | 67 &bitmap_, |
66 content_rect, | 68 content_rect, |
67 content_rect, | 69 content_rect, |
68 gfx::Vector2d()); | 70 gfx::Vector2d()); |
69 queue->AppendFullUpload(upload); | 71 queue->AppendFullUpload(upload); |
70 bitmap_dirty_ = false; | 72 bitmap_dirty_ = false; |
71 return true; | 73 updated = true; |
72 } | 74 } |
73 return false; | 75 return updated; |
74 } | 76 } |
75 | 77 |
76 void NinePatchLayer::CreateUpdaterIfNeeded() { | 78 void NinePatchLayer::CreateUpdaterIfNeeded() { |
77 if (updater_.get()) | 79 if (updater_.get()) |
78 return; | 80 return; |
79 | 81 |
80 updater_ = ImageLayerUpdater::Create(); | 82 updater_ = ImageLayerUpdater::Create(); |
81 } | 83 } |
82 | 84 |
83 void NinePatchLayer::CreateResource() { | 85 void NinePatchLayer::CreateResource() { |
(...skipping 21 matching lines...) Expand all Loading... |
105 | 107 |
106 if (resource_) { | 108 if (resource_) { |
107 DCHECK(!bitmap_.isNull()); | 109 DCHECK(!bitmap_.isNull()); |
108 layer_impl->SetResourceId(resource_->texture()->resource_id()); | 110 layer_impl->SetResourceId(resource_->texture()->resource_id()); |
109 layer_impl->SetLayout( | 111 layer_impl->SetLayout( |
110 gfx::Size(bitmap_.width(), bitmap_.height()), image_aperture_); | 112 gfx::Size(bitmap_.width(), bitmap_.height()), image_aperture_); |
111 } | 113 } |
112 } | 114 } |
113 | 115 |
114 } // namespace cc | 116 } // namespace cc |
OLD | NEW |