| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/content_layer.h" | 5 #include "cc/layers/content_layer.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "cc/layers/content_layer_client.h" | 10 #include "cc/layers/content_layer_client.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 client_->PaintContents(canvas, | 29 client_->PaintContents(canvas, |
| 30 content_rect, | 30 content_rect, |
| 31 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); | 31 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); |
| 32 } | 32 } |
| 33 | 33 |
| 34 scoped_refptr<ContentLayer> ContentLayer::Create(ContentLayerClient* client) { | 34 scoped_refptr<ContentLayer> ContentLayer::Create(ContentLayerClient* client) { |
| 35 return make_scoped_refptr(new ContentLayer(client)); | 35 return make_scoped_refptr(new ContentLayer(client)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 ContentLayer::ContentLayer(ContentLayerClient* client) | 38 ContentLayer::ContentLayer(ContentLayerClient* client) |
| 39 : TiledLayer(), client_(client) { | 39 : TiledLayer(), |
| 40 client_(client), |
| 41 can_use_lcd_text_last_frame_(can_use_lcd_text()) { |
| 40 } | 42 } |
| 41 | 43 |
| 42 ContentLayer::~ContentLayer() {} | 44 ContentLayer::~ContentLayer() {} |
| 43 | 45 |
| 44 void ContentLayer::ClearClient() { | 46 void ContentLayer::ClearClient() { |
| 45 client_ = nullptr; | 47 client_ = nullptr; |
| 46 UpdateDrawsContent(HasDrawableContent()); | 48 UpdateDrawsContent(HasDrawableContent()); |
| 47 } | 49 } |
| 48 | 50 |
| 49 bool ContentLayer::HasDrawableContent() const { | 51 bool ContentLayer::HasDrawableContent() const { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 65 TiledLayer::SetTexturePriorities(priority_calc); | 67 TiledLayer::SetTexturePriorities(priority_calc); |
| 66 } | 68 } |
| 67 | 69 |
| 68 bool ContentLayer::Update(ResourceUpdateQueue* queue, | 70 bool ContentLayer::Update(ResourceUpdateQueue* queue, |
| 69 const OcclusionTracker<Layer>* occlusion) { | 71 const OcclusionTracker<Layer>* occlusion) { |
| 70 { | 72 { |
| 71 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, | 73 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, |
| 72 true); | 74 true); |
| 73 | 75 |
| 74 CreateUpdaterIfNeeded(); | 76 CreateUpdaterIfNeeded(); |
| 77 UpdateCanUseLCDText(); |
| 75 } | 78 } |
| 76 | 79 |
| 77 bool updated = TiledLayer::Update(queue, occlusion); | 80 bool updated = TiledLayer::Update(queue, occlusion); |
| 78 return updated; | 81 return updated; |
| 79 } | 82 } |
| 80 | 83 |
| 81 bool ContentLayer::NeedMoreUpdates() { | 84 bool ContentLayer::NeedMoreUpdates() { |
| 82 return NeedsIdlePaint(); | 85 return NeedsIdlePaint(); |
| 83 } | 86 } |
| 84 | 87 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 108 SetTextureFormat( | 111 SetTextureFormat( |
| 109 layer_tree_host()->GetRendererCapabilities().best_texture_format); | 112 layer_tree_host()->GetRendererCapabilities().best_texture_format); |
| 110 } | 113 } |
| 111 | 114 |
| 112 void ContentLayer::SetContentsOpaque(bool opaque) { | 115 void ContentLayer::SetContentsOpaque(bool opaque) { |
| 113 Layer::SetContentsOpaque(opaque); | 116 Layer::SetContentsOpaque(opaque); |
| 114 if (updater_.get()) | 117 if (updater_.get()) |
| 115 updater_->SetOpaque(opaque); | 118 updater_->SetOpaque(opaque); |
| 116 } | 119 } |
| 117 | 120 |
| 121 void ContentLayer::UpdateCanUseLCDText() { |
| 122 if (can_use_lcd_text_last_frame_ == can_use_lcd_text()) |
| 123 return; |
| 124 |
| 125 can_use_lcd_text_last_frame_ = can_use_lcd_text(); |
| 126 if (client_) |
| 127 client_->DidChangeLayerCanUseLCDText(); |
| 128 } |
| 129 |
| 118 bool ContentLayer::SupportsLCDText() const { | 130 bool ContentLayer::SupportsLCDText() const { |
| 119 return true; | 131 return true; |
| 120 } | 132 } |
| 121 | 133 |
| 122 skia::RefPtr<SkPicture> ContentLayer::GetPicture() const { | 134 skia::RefPtr<SkPicture> ContentLayer::GetPicture() const { |
| 123 if (!DrawsContent()) | 135 if (!DrawsContent()) |
| 124 return skia::RefPtr<SkPicture>(); | 136 return skia::RefPtr<SkPicture>(); |
| 125 | 137 |
| 126 int width = bounds().width(); | 138 int width = bounds().width(); |
| 127 int height = bounds().height(); | 139 int height = bounds().height(); |
| 128 | 140 |
| 129 SkPictureRecorder recorder; | 141 SkPictureRecorder recorder; |
| 130 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); | 142 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); |
| 131 client_->PaintContents(canvas, | 143 client_->PaintContents(canvas, |
| 132 gfx::Rect(width, height), | 144 gfx::Rect(width, height), |
| 133 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); | 145 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); |
| 134 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); | 146 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); |
| 135 return picture; | 147 return picture; |
| 136 } | 148 } |
| 137 | 149 |
| 138 void ContentLayer::OnOutputSurfaceCreated() { | 150 void ContentLayer::OnOutputSurfaceCreated() { |
| 139 SetTextureFormat( | 151 SetTextureFormat( |
| 140 layer_tree_host()->GetRendererCapabilities().best_texture_format); | 152 layer_tree_host()->GetRendererCapabilities().best_texture_format); |
| 141 TiledLayer::OnOutputSurfaceCreated(); | 153 TiledLayer::OnOutputSurfaceCreated(); |
| 142 } | 154 } |
| 143 | 155 |
| 144 } // namespace cc | 156 } // namespace cc |
| OLD | NEW |