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

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: rebase 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
« no previous file with comments | « cc/image_layer.h ('k') | cc/layer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/image_layer.cc
diff --git a/cc/image_layer.cc b/cc/image_layer.cc
index f3819faf3dd236f478f694bd9f64f3a8211d4cd6..82ce952f9215a5735f1b15f3cc45b37830dc0016 100644
--- a/cc/image_layer.cc
+++ b/cc/image_layer.cc
@@ -74,9 +74,15 @@ LayerUpdater* ImageLayer::updater() const
return m_updater.get();
}
-gfx::Size ImageLayer::contentBounds() const
+void ImageLayer::calculateContentsScale(
+ float ideal_contents_scale,
+ float* contentsScaleX,
+ float* contentsScaleY,
+ gfx::Size* contentBounds)
{
- return gfx::Size(m_bitmap.width(), m_bitmap.height());
+ *contentsScaleX = imageContentsScaleX();
+ *contentsScaleY = imageContentsScaleY();
+ *contentBounds = gfx::Size(m_bitmap.width(), m_bitmap.height());
}
bool ImageLayer::drawsContent() const
@@ -84,16 +90,16 @@ bool ImageLayer::drawsContent() const
return !m_bitmap.isNull() && TiledLayer::drawsContent();
}
-float ImageLayer::contentsScaleX() const
+float ImageLayer::imageContentsScaleX() 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
+float ImageLayer::imageContentsScaleY() const
{
- if (bounds().IsEmpty() || contentBounds().IsEmpty())
+ if (bounds().IsEmpty() || m_bitmap.height() == 0)
return 1;
return static_cast<float>(m_bitmap.height()) / bounds().height();
}
« no previous file with comments | « cc/image_layer.h ('k') | cc/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698