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

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: bettertestsyay 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 20 matching lines...) Expand all
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(),
40 client_(client), 40 client_(client),
41 can_use_lcd_text_last_frame_(can_use_lcd_text()) { 41 can_use_lcd_text_for_update_(false),
42 ignore_lcd_text_change_(false) {
42 } 43 }
43 44
44 ContentLayer::~ContentLayer() {} 45 ContentLayer::~ContentLayer() {}
45 46
46 void ContentLayer::ClearClient() { 47 void ContentLayer::ClearClient() {
47 client_ = nullptr; 48 client_ = nullptr;
48 UpdateDrawsContent(HasDrawableContent()); 49 UpdateDrawsContent(HasDrawableContent());
49 } 50 }
50 51
51 bool ContentLayer::HasDrawableContent() const { 52 bool ContentLayer::HasDrawableContent() const {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 layer_tree_host()->GetRendererCapabilities().best_texture_format); 113 layer_tree_host()->GetRendererCapabilities().best_texture_format);
113 } 114 }
114 115
115 void ContentLayer::SetContentsOpaque(bool opaque) { 116 void ContentLayer::SetContentsOpaque(bool opaque) {
116 Layer::SetContentsOpaque(opaque); 117 Layer::SetContentsOpaque(opaque);
117 if (updater_.get()) 118 if (updater_.get())
118 updater_->SetOpaque(opaque); 119 updater_->SetOpaque(opaque);
119 } 120 }
120 121
121 void ContentLayer::UpdateCanUseLCDText() { 122 void ContentLayer::UpdateCanUseLCDText() {
122 if (can_use_lcd_text_last_frame_ == can_use_lcd_text()) 123 if (can_use_lcd_text_for_update_ == can_use_lcd_text())
124 return;
125 // Once LCD text decision has been made, only allow it to be disabled.
126 if (can_use_lcd_text() && ignore_lcd_text_change_)
123 return; 127 return;
124 128
125 can_use_lcd_text_last_frame_ = can_use_lcd_text(); 129 can_use_lcd_text_for_update_ = can_use_lcd_text();
126 if (client_) 130 ignore_lcd_text_change_ = true;
127 client_->DidChangeLayerCanUseLCDText(); 131 SetNeedsDisplay();
128 } 132 }
129 133
130 bool ContentLayer::SupportsLCDText() const { 134 bool ContentLayer::SupportsLCDText() const {
131 return true; 135 return true;
132 } 136 }
133 137
134 skia::RefPtr<SkPicture> ContentLayer::GetPicture() const { 138 skia::RefPtr<SkPicture> ContentLayer::GetPicture() const {
135 if (!DrawsContent()) 139 if (!DrawsContent())
136 return skia::RefPtr<SkPicture>(); 140 return skia::RefPtr<SkPicture>();
137 141
138 int width = bounds().width(); 142 int width = bounds().width();
139 int height = bounds().height(); 143 int height = bounds().height();
140 144
141 SkPictureRecorder recorder; 145 SkPictureRecorder recorder;
142 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); 146 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0);
143 client_->PaintContents(canvas, 147 client_->PaintContents(canvas,
144 gfx::Rect(width, height), 148 gfx::Rect(width, height),
145 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); 149 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED);
146 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); 150 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording());
147 return picture; 151 return picture;
148 } 152 }
149 153
150 void ContentLayer::OnOutputSurfaceCreated() { 154 void ContentLayer::OnOutputSurfaceCreated() {
151 SetTextureFormat( 155 SetTextureFormat(
152 layer_tree_host()->GetRendererCapabilities().best_texture_format); 156 layer_tree_host()->GetRendererCapabilities().best_texture_format);
153 TiledLayer::OnOutputSurfaceCreated(); 157 TiledLayer::OnOutputSurfaceCreated();
154 } 158 }
155 159
156 } // namespace cc 160 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698