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

Unified Diff: cc/picture_image_layer.cc

Issue 12326022: Efficiently handle image layer scaling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handle sublayerTransform and anchor point Created 7 years, 10 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/picture_image_layer.cc
diff --git a/cc/picture_image_layer.cc b/cc/picture_image_layer.cc
index 14864464ae12dc50ddc9d5e202e23c15dd08c3ba..0fb908f956f33cd47281f9d68493842c97edcbbc 100644
--- a/cc/picture_image_layer.cc
+++ b/cc/picture_image_layer.cc
@@ -4,6 +4,7 @@
#include "cc/picture_image_layer.h"
+#include "cc/picture_image_layer_impl.h"
#include "third_party/skia/include/core/SkCanvas.h"
namespace cc {
@@ -23,6 +24,15 @@ PictureImageLayer::~PictureImageLayer()
clearClient();
}
+scoped_ptr<LayerImpl> PictureImageLayer::createLayerImpl(
+ LayerTreeImpl* treeImpl) {
+ return PictureImageLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>();
+}
+
+bool PictureImageLayer::drawsContent() const {
+ return !bitmap_.isNull() && PictureLayer::drawsContent();
+}
+
void PictureImageLayer::setBitmap(const SkBitmap& bitmap)
{
// setBitmap() currently gets called whenever there is any
@@ -36,21 +46,6 @@ void PictureImageLayer::setBitmap(const SkBitmap& bitmap)
setNeedsDisplay();
}
-void PictureImageLayer::update(
- ResourceUpdateQueue& queue,
- const OcclusionTracker* tracker,
- RenderingStats* stats) {
- if (bounds() != bounds_) {
- // Pictures are recorded in layer space, so if the layer size changes,
- // then the picture needs to be re-scaled, as a directly composited image
- // always fills its entire layer bounds. This could be improved by
- // recording pictures of images at their actual resolution somehow.
- bounds_ = bounds();
- setNeedsDisplay();
- }
- PictureLayer::update(queue, tracker, stats);
-}
-
void PictureImageLayer::paintContents(
SkCanvas* canvas,
const gfx::Rect& clip,
@@ -58,11 +53,10 @@ void PictureImageLayer::paintContents(
if (!bitmap_.width() || !bitmap_.height())
return;
- SkScalar content_to_layer_scale_x = SkFloatToScalar(
- static_cast<float>(bounds().width()) / bitmap_.width());
- SkScalar content_to_layer_scale_y = SkFloatToScalar(
- static_cast<float>(bounds().height()) / bitmap_.height());
- canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y);
+ // WebImageLayerImpl should always set bounds equaling to the size of the
+ // bitmap.
+ DCHECK(bounds().width() == bitmap_.width() &&
+ bounds().height() == bitmap_.height());
canvas->drawBitmap(bitmap_, 0, 0);
}

Powered by Google App Engine
This is Rietveld 408576698