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

Side by Side Diff: cc/layers/content_layer.cc

Issue 684543006: cc: Toggle LCD text at raster time instead of record time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcdraster: header Created 6 years, 1 month 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 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
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(), 39 : TiledLayer(), client_(client) {
40 client_(client),
41 can_use_lcd_text_last_frame_(can_use_lcd_text()) {
42 } 40 }
43 41
44 ContentLayer::~ContentLayer() {} 42 ContentLayer::~ContentLayer() {}
45 43
46 void ContentLayer::ClearClient() { 44 void ContentLayer::ClearClient() {
47 client_ = nullptr; 45 client_ = nullptr;
48 UpdateDrawsContent(HasDrawableContent()); 46 UpdateDrawsContent(HasDrawableContent());
49 } 47 }
50 48
51 bool ContentLayer::HasDrawableContent() const { 49 bool ContentLayer::HasDrawableContent() const {
(...skipping 15 matching lines...) Expand all
67 TiledLayer::SetTexturePriorities(priority_calc); 65 TiledLayer::SetTexturePriorities(priority_calc);
68 } 66 }
69 67
70 bool ContentLayer::Update(ResourceUpdateQueue* queue, 68 bool ContentLayer::Update(ResourceUpdateQueue* queue,
71 const OcclusionTracker<Layer>* occlusion) { 69 const OcclusionTracker<Layer>* occlusion) {
72 { 70 {
73 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, 71 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_,
74 true); 72 true);
75 73
76 CreateUpdaterIfNeeded(); 74 CreateUpdaterIfNeeded();
77 UpdateCanUseLCDText();
78 } 75 }
79 76
80 bool updated = TiledLayer::Update(queue, occlusion); 77 bool updated = TiledLayer::Update(queue, occlusion);
81 return updated; 78 return updated;
82 } 79 }
83 80
84 bool ContentLayer::NeedMoreUpdates() { 81 bool ContentLayer::NeedMoreUpdates() {
85 return NeedsIdlePaint(); 82 return NeedsIdlePaint();
86 } 83 }
87 84
(...skipping 23 matching lines...) Expand all
111 SetTextureFormat( 108 SetTextureFormat(
112 layer_tree_host()->GetRendererCapabilities().best_texture_format); 109 layer_tree_host()->GetRendererCapabilities().best_texture_format);
113 } 110 }
114 111
115 void ContentLayer::SetContentsOpaque(bool opaque) { 112 void ContentLayer::SetContentsOpaque(bool opaque) {
116 Layer::SetContentsOpaque(opaque); 113 Layer::SetContentsOpaque(opaque);
117 if (updater_.get()) 114 if (updater_.get())
118 updater_->SetOpaque(opaque); 115 updater_->SetOpaque(opaque);
119 } 116 }
120 117
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
130 bool ContentLayer::SupportsLCDText() const { 118 bool ContentLayer::SupportsLCDText() const {
131 return true; 119 return true;
132 } 120 }
133 121
134 skia::RefPtr<SkPicture> ContentLayer::GetPicture() const { 122 skia::RefPtr<SkPicture> ContentLayer::GetPicture() const {
135 if (!DrawsContent()) 123 if (!DrawsContent())
136 return skia::RefPtr<SkPicture>(); 124 return skia::RefPtr<SkPicture>();
137 125
138 int width = bounds().width(); 126 int width = bounds().width();
139 int height = bounds().height(); 127 int height = bounds().height();
140 128
141 SkPictureRecorder recorder; 129 SkPictureRecorder recorder;
142 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); 130 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0);
143 client_->PaintContents(canvas, 131 client_->PaintContents(canvas,
144 gfx::Rect(width, height), 132 gfx::Rect(width, height),
145 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); 133 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED);
146 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); 134 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording());
147 return picture; 135 return picture;
148 } 136 }
149 137
150 void ContentLayer::OnOutputSurfaceCreated() { 138 void ContentLayer::OnOutputSurfaceCreated() {
151 SetTextureFormat( 139 SetTextureFormat(
152 layer_tree_host()->GetRendererCapabilities().best_texture_format); 140 layer_tree_host()->GetRendererCapabilities().best_texture_format);
153 TiledLayer::OnOutputSurfaceCreated(); 141 TiledLayer::OnOutputSurfaceCreated();
154 } 142 }
155 143
156 } // namespace cc 144 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698