Commit 36df0635 authored by alokp@chromium.org's avatar alokp@chromium.org

Record SkPicture with correct LCD text setting.

We used to always recorded with LCD ON and if needed disabled it with an
SkFilter during rasterization. This is wasteful on platforms where LCD
text is always disabled. This patch records SkPicture with correct
setting. One downside to this approach is that we would need to
invalidate and record anytime the LCD text setting changes. But since
this can only happen once for a layer (all future changes are ignored),
this is not going to be a big performance issue.

On the positive side, this patch will simplify a lot of things on the
rasterization front - no SkDrawFilter, or LCD text tile versions, or
a special rasterization mode for disable LCD.

BUG=368513

Review URL: https://codereview.chromium.org/315393002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276785 0039d316-1c4b-4281-b951-d872f2087c98
parent b725243e
......@@ -21,7 +21,9 @@ PictureLayer::PictureLayer(ContentLayerClient* client)
pile_(make_scoped_refptr(new PicturePile())),
instrumentation_object_tracker_(id()),
is_mask_(false),
update_source_frame_number_(-1) {}
update_source_frame_number_(-1),
can_use_lcd_text_last_frame_(can_use_lcd_text()) {
}
PictureLayer::~PictureLayer() {
}
......@@ -88,6 +90,8 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue,
update_source_frame_number_ = layer_tree_host()->source_frame_number();
bool updated = Layer::Update(queue, occlusion);
UpdateCanUseLCDText();
gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect(
visible_content_rect(), 1.f / contents_scale_x());
......@@ -157,6 +161,15 @@ bool PictureLayer::SupportsLCDText() const {
return true;
}
void PictureLayer::UpdateCanUseLCDText() {
if (can_use_lcd_text_last_frame_ == can_use_lcd_text())
return;
can_use_lcd_text_last_frame_ = can_use_lcd_text();
if (client_)
client_->DidChangeLayerCanUseLCDText();
}
skia::RefPtr<SkPicture> PictureLayer::GetPicture() const {
// We could either flatten the PicturePile into a single SkPicture,
// or paint a fresh one depending on what we intend to do with the
......
......@@ -49,6 +49,8 @@ class CC_EXPORT PictureLayer : public Layer {
explicit PictureLayer(ContentLayerClient* client);
virtual ~PictureLayer();
void UpdateCanUseLCDText();
private:
ContentLayerClient* client_;
scoped_refptr<PicturePile> pile_;
......@@ -62,6 +64,7 @@ class CC_EXPORT PictureLayer : public Layer {
bool is_mask_;
int update_source_frame_number_;
bool can_use_lcd_text_last_frame_;
DISALLOW_COPY_AND_ASSIGN(PictureLayer);
};
......
......@@ -2210,7 +2210,11 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
};
virtual void SetupTree() OVERRIDE {
scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_);
scoped_refptr<Layer> root_layer;
if (layer_tree_host()->settings().impl_side_painting)
root_layer = PictureLayer::Create(&client_);
else
root_layer = ContentLayer::Create(&client_);
root_layer->SetIsDrawable(true);
root_layer->SetBounds(gfx::Size(1, 1));
......@@ -2231,7 +2235,7 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
virtual void DidCommit() OVERRIDE {
switch (layer_tree_host()->source_frame_number()) {
case 1:
// The first update consists one LCD notification and one paint.
// The first update consists of one LCD notification and one paint.
EXPECT_EQ(1, client_.lcd_notification_count());
EXPECT_EQ(1, client_.paint_count());
// LCD text must have been enabled on the layer.
......@@ -2250,7 +2254,7 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
// No need to request a commit - setting opacity will do it.
break;
default:
// Verify that there is not extra commit due to layer invalidation.
// Verify that there is no extra commit due to layer invalidation.
EXPECT_EQ(3, layer_tree_host()->source_frame_number());
// LCD notification count should have incremented due to
// change in layer opacity.
......@@ -2268,7 +2272,7 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
NotificationClient client_;
};
SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification);
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDNotification);
// Verify that the BeginFrame notification is used to initiate rendering.
class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest {
......
......@@ -55,13 +55,10 @@ void WebContentLayerImpl::PaintContents(
return;
blink::WebFloatRect web_opaque;
// For picture layers, always record with LCD text. PictureLayerImpl
// will turn this off later during rasterization.
bool use_lcd_text = WebLayerImpl::UsingPictureLayer() || can_use_lcd_text_;
client_->paintContents(
canvas,
clip,
use_lcd_text,
can_use_lcd_text_,
web_opaque,
graphics_context_status == ContentLayerClient::GRAPHICS_CONTEXT_ENABLED
? blink::WebContentLayerClient::GraphicsContextEnabled
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment