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

Unified Diff: cc/layers/content_layer.cc

Issue 315393002: Record SkPicture with correct LCD text setting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better unittest Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: cc/layers/content_layer.cc
diff --git a/cc/layers/content_layer.cc b/cc/layers/content_layer.cc
index d720501b56ddbe852f43ad86f4f9ebde149e0409..1a8909f2e03fce40c9b50d008c09c9ac96e413d9 100644
--- a/cc/layers/content_layer.cc
+++ b/cc/layers/content_layer.cc
@@ -10,37 +10,18 @@
#include "cc/layers/content_layer_client.h"
#include "cc/resources/bitmap_content_layer_updater.h"
#include "cc/resources/bitmap_skpicture_content_layer_updater.h"
-#include "cc/resources/layer_painter.h"
+#include "cc/resources/content_layer_painter.h"
#include "cc/trees/layer_tree_host.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
namespace cc {
-ContentLayerPainter::ContentLayerPainter(ContentLayerClient* client)
- : client_(client) {}
-
-scoped_ptr<ContentLayerPainter> ContentLayerPainter::Create(
- ContentLayerClient* client) {
- return make_scoped_ptr(new ContentLayerPainter(client));
-}
-
-void ContentLayerPainter::Paint(SkCanvas* canvas,
- const gfx::Rect& content_rect,
- gfx::RectF* opaque) {
- client_->PaintContents(canvas,
- content_rect,
- opaque,
- ContentLayerClient::GRAPHICS_CONTEXT_ENABLED);
-}
-
scoped_refptr<ContentLayer> ContentLayer::Create(ContentLayerClient* client) {
return make_scoped_refptr(new ContentLayer(client));
}
ContentLayer::ContentLayer(ContentLayerClient* client)
- : TiledLayer(),
- client_(client),
- can_use_lcd_text_last_frame_(can_use_lcd_text()) {
+ : client_(client), use_lcd_text_(true) {
}
ContentLayer::~ContentLayer() {}
@@ -78,7 +59,7 @@ bool ContentLayer::Update(ResourceUpdateQueue* queue,
true);
CreateUpdaterIfNeeded();
- UpdateCanUseLCDText();
+ UpdateUseLCDText();
}
bool updated = TiledLayer::Update(queue, occlusion);
@@ -96,8 +77,8 @@ LayerUpdater* ContentLayer::Updater() const {
void ContentLayer::CreateUpdaterIfNeeded() {
if (updater_.get())
return;
- scoped_ptr<LayerPainter> painter =
- ContentLayerPainter::Create(client_).PassAs<LayerPainter>();
+ scoped_ptr<ContentLayerPainter> painter =
+ ContentLayerPainter::Create(client_);
if (layer_tree_host()->settings().per_tile_painting_enabled) {
updater_ = BitmapSkPictureContentLayerUpdater::Create(
painter.Pass(),
@@ -112,6 +93,7 @@ void ContentLayer::CreateUpdaterIfNeeded() {
updater_->SetOpaque(contents_opaque());
if (client_)
updater_->SetFillsBoundsCompletely(client_->FillsBoundsCompletely());
+ updater_->set_can_use_lcd_text(use_lcd_text_);
SetTextureFormat(
layer_tree_host()->GetRendererCapabilities().best_texture_format);
@@ -123,13 +105,18 @@ void ContentLayer::SetContentsOpaque(bool opaque) {
updater_->SetOpaque(opaque);
}
-void ContentLayer::UpdateCanUseLCDText() {
- if (can_use_lcd_text_last_frame_ == can_use_lcd_text())
+void ContentLayer::UpdateUseLCDText() {
+ if (use_lcd_text_ == can_use_lcd_text())
return;
- can_use_lcd_text_last_frame_ = can_use_lcd_text();
- if (client_)
- client_->DidChangeLayerCanUseLCDText();
+ // LCD text starts out enabled and can only be disabled.
+ if (!use_lcd_text_)
+ return;
+
+ use_lcd_text_ = can_use_lcd_text();
+ updater_->set_can_use_lcd_text(use_lcd_text_);
+ if (client_->PaintsLCDText())
+ SetNeedsDisplay();
}
bool ContentLayer::SupportsLCDText() const {
@@ -148,6 +135,7 @@ skia::RefPtr<SkPicture> ContentLayer::GetPicture() const {
SkCanvas* canvas = recorder.beginRecording(width, height, NULL, 0);
client_->PaintContents(canvas,
gfx::Rect(width, height),
+ use_lcd_text_,
&opaque,
ContentLayerClient::GRAPHICS_CONTEXT_ENABLED);
skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording());

Powered by Google App Engine
This is Rietveld 408576698