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

Unified Diff: cc/image_layer.cc

Issue 11503005: cc: Refactor content scale/bounds into draw properties (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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/image_layer.cc
diff --git a/cc/image_layer.cc b/cc/image_layer.cc
index f3819faf3dd236f478f694bd9f64f3a8211d4cd6..26dee60f8a4c7703d983186c05fe437120d4af9b 100644
--- a/cc/image_layer.cc
+++ b/cc/image_layer.cc
@@ -36,6 +36,7 @@ void ImageLayer::setBitmap(const SkBitmap& bitmap)
return;
m_bitmap = bitmap;
+ didUpdateBounds();
setNeedsDisplay();
}
@@ -74,9 +75,12 @@ LayerUpdater* ImageLayer::updater() const
return m_updater.get();
}
-gfx::Size ImageLayer::contentBounds() const
+void ImageLayer::setIdealContentsScale(float ideal_contents_scale)
{
- return gfx::Size(m_bitmap.width(), m_bitmap.height());
+ m_drawProperties.ideal_contents_scale = ideal_contents_scale;
+ m_drawProperties.contents_scale_x = contentsScaleX();
+ m_drawProperties.contents_scale_y = contentsScaleY();
+ m_drawProperties.content_bounds = gfx::Size(m_bitmap.width(), m_bitmap.height());
}
bool ImageLayer::drawsContent() const
@@ -86,14 +90,14 @@ bool ImageLayer::drawsContent() const
float ImageLayer::contentsScaleX() const
{
- if (bounds().IsEmpty() || contentBounds().IsEmpty())
+ if (bounds().IsEmpty() || m_bitmap.width() == 0)
return 1;
return static_cast<float>(m_bitmap.width()) / bounds().width();
}
float ImageLayer::contentsScaleY() const
{
- if (bounds().IsEmpty() || contentBounds().IsEmpty())
+ if (bounds().IsEmpty() || m_bitmap.height() == 0)
return 1;
return static_cast<float>(m_bitmap.height()) / bounds().height();
}

Powered by Google App Engine
This is Rietveld 408576698