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

Unified Diff: cc/resources/content_layer_updater.cc

Issue 590313004: Revert of Fix bad scaling in TiledLayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « cc/resources/content_layer_updater.h ('k') | cc/resources/layer_updater.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/content_layer_updater.cc
diff --git a/cc/resources/content_layer_updater.cc b/cc/resources/content_layer_updater.cc
index f6469ff052ea3063d5127bb8eb407a3a3060c3b0..8bd90e9d5a174768abab9709b7a3928540a2eac7 100644
--- a/cc/resources/content_layer_updater.cc
+++ b/cc/resources/content_layer_updater.cc
@@ -14,7 +14,6 @@
#include "third_party/skia/include/core/SkScalar.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/rect_f.h"
-#include "ui/gfx/skia_util.h"
namespace cc {
@@ -26,9 +25,7 @@
layer_id_(layer_id),
layer_is_opaque_(false),
layer_fills_bounds_completely_(false),
- painter_(painter.Pass()),
- background_color_(SK_ColorTRANSPARENT) {
-}
+ painter_(painter.Pass()) {}
ContentLayerUpdater::~ContentLayerUpdater() {}
@@ -38,62 +35,27 @@
}
void ContentLayerUpdater::PaintContents(SkCanvas* canvas,
- const gfx::Size& layer_content_size,
- const gfx::Rect& paint_rect,
+ const gfx::Rect& content_rect,
float contents_width_scale,
float contents_height_scale) {
TRACE_EVENT0("cc", "ContentLayerUpdater::PaintContents");
if (!canvas)
return;
canvas->save();
- canvas->translate(SkIntToScalar(-paint_rect.x()),
- SkIntToScalar(-paint_rect.y()));
+ canvas->translate(SkFloatToScalar(-content_rect.x()),
+ SkFloatToScalar(-content_rect.y()));
- // The |canvas| backing should be sized to hold the |paint_rect|.
- DCHECK_EQ(paint_rect.width(), canvas->getBaseLayerSize().width());
- DCHECK_EQ(paint_rect.height(), canvas->getBaseLayerSize().height());
+ // The |canvas| backing should be sized to hold the |content_rect|.
+ DCHECK_EQ(content_rect.width(), canvas->getBaseLayerSize().width());
+ DCHECK_EQ(content_rect.height(), canvas->getBaseLayerSize().height());
- const bool is_scaled =
- contents_width_scale != 1.f || contents_height_scale != 1.f;
-
- if (is_scaled && (layer_is_opaque_ || layer_fills_bounds_completely_)) {
- // Even if completely covered, for rasterizations that touch the edge of the
- // layer, we also need to raster the background color underneath the last
- // texel (since the paint won't cover it).
- //
- // The final texel of content may only be partially covered by a
- // rasterization; this rect represents the content rect that is fully
- // covered by content.
- const gfx::Rect layer_content_rect = gfx::Rect(layer_content_size);
- gfx::Rect deflated_layer_content_rect = layer_content_rect;
- deflated_layer_content_rect.Inset(0, 0, 1, 1);
-
- if (!layer_content_rect.Contains(deflated_layer_content_rect)) {
- // Drawing at most 1 x 1 x (canvas width + canvas height) texels is 2-3X
- // faster than clearing, so special case this.
- DCHECK_LE(paint_rect.right(), layer_content_rect.right());
- DCHECK_LE(paint_rect.bottom(), layer_content_rect.bottom());
- canvas->save();
- canvas->clipRect(gfx::RectToSkRect(layer_content_rect),
- SkRegion::kReplace_Op);
- canvas->clipRect(gfx::RectToSkRect(deflated_layer_content_rect),
- SkRegion::kDifference_Op);
- canvas->drawColor(background_color_, SkXfermode::kSrc_Mode);
- canvas->restore();
- }
- }
-
- gfx::Rect layer_rect;
- if (is_scaled) {
+ gfx::Rect layer_rect = content_rect;
+ if (contents_width_scale != 1.f || contents_height_scale != 1.f) {
canvas->scale(SkFloatToScalar(contents_width_scale),
SkFloatToScalar(contents_height_scale));
- // NOTE: this may go beyond the bounds of the layer, but that shouldn't
- // cause problems (anything beyond the layer is clipped out).
layer_rect = gfx::ScaleToEnclosingRect(
- paint_rect, 1.f / contents_width_scale, 1.f / contents_height_scale);
- } else {
- layer_rect = paint_rect;
+ content_rect, 1.f / contents_width_scale, 1.f / contents_height_scale);
}
SkRect layer_sk_rect = SkRect::MakeXYWH(
@@ -111,7 +73,7 @@
painter_->Paint(canvas, layer_rect);
canvas->restore();
- paint_rect_ = paint_rect;
+ content_rect_ = content_rect;
}
void ContentLayerUpdater::SetOpaque(bool opaque) {
@@ -122,8 +84,4 @@
layer_fills_bounds_completely_ = fills_bounds;
}
-void ContentLayerUpdater::SetBackgroundColor(SkColor background_color) {
- background_color_ = background_color;
-}
-
} // namespace cc
« no previous file with comments | « cc/resources/content_layer_updater.h ('k') | cc/resources/layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698