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

Unified Diff: cc/picture_layer_impl.cc

Issue 11777008: cc: Use maximum tiling contents scales for picture layer scale (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ok, 1.f Created 7 years, 11 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/picture_layer_impl.h ('k') | cc/picture_layer_tiling_set.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/picture_layer_impl.cc
diff --git a/cc/picture_layer_impl.cc b/cc/picture_layer_impl.cc
index d5a44c7af7311b5dec5b7037861ae15cb1b8b624..161fd83cc54471c0a627b2479b5912ace15cac79 100644
--- a/cc/picture_layer_impl.cc
+++ b/cc/picture_layer_impl.cc
@@ -15,6 +15,7 @@
#include "cc/solid_color_draw_quad.h"
#include "cc/tile_draw_quad.h"
#include "ui/gfx/quad_f.h"
+#include "ui/gfx/size_conversions.h"
namespace cc {
@@ -129,18 +130,6 @@ void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const {
}
void PictureLayerImpl::didUpdateTransforms() {
- if (drawsContent()) {
- // TODO(enne): Add tilings during pinch zoom
- // TODO(enne): Consider culling old tilings after pinch finishes.
- if (!tilings_.num_tilings()) {
- AddTiling(contentsScaleX(), TileSize());
- // TODO(enne): Add a low-res tiling as well.
- }
- } else {
- // TODO(enne): This should be unnecessary once there are two trees.
- tilings_.Reset();
- }
-
gfx::Transform current_screen_space_transform =
screenSpaceTransform();
double current_time =
@@ -170,6 +159,36 @@ void PictureLayerImpl::didUpdateTransforms() {
last_content_scale_y_ = contentsScaleY();
}
+void PictureLayerImpl::calculateContentsScale(
+ float ideal_contents_scale,
+ float* contents_scale_x,
+ float* contents_scale_y,
+ gfx::Size* content_bounds) {
+ if (!drawsContent()) {
+ DCHECK(!tilings_.num_tilings());
+ return;
+ }
+
+ ManageTilings(ideal_contents_scale);
+
+ // The content scale and bounds for a PictureLayerImpl is somewhat fictitious.
+ // There are (usually) several tilings at different scales. However, the
+ // content bounds is the (integer!) space in which quads are generated.
+ // In order to guarantee that we can fill this integer space with any set of
+ // tilings (and then map back to floating point texture coordinates), the
+ // contents scale must be at least as large as the largest of the tilings.
+ float max_contents_scale = 1.f;
+ for (size_t i = 0; i < tilings_.num_tilings(); ++i) {
+ const PictureLayerTiling* tiling = tilings_.tiling_at(i);
+ max_contents_scale = std::max(max_contents_scale, tiling->contents_scale());
+ }
+
+ *contents_scale_x = max_contents_scale;
+ *contents_scale_y = max_contents_scale;
+ *content_bounds = gfx::ToCeiledSize(
+ gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale));
+}
+
scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
gfx::Rect rect) {
TileManager* tile_manager = layerTreeImpl()->tile_manager();
@@ -260,4 +279,18 @@ gfx::Size PictureLayerImpl::TileSize() const {
return layerTreeImpl()->settings().defaultTileSize;
}
+void PictureLayerImpl::ManageTilings(float ideal_contents_scale) {
+ if (drawsContent()) {
+ // TODO(enne): Add tilings during pinch zoom
+ // TODO(enne): Consider culling old tilings after pinch finishes.
+ if (!tilings_.num_tilings()) {
+ AddTiling(ideal_contents_scale, TileSize());
+ // TODO(enne): Add a low-res tiling as well.
+ }
+ } else {
+ // TODO(enne): This should be unnecessary once there are two trees.
+ tilings_.Reset();
+ }
+}
+
} // namespace cc
« no previous file with comments | « cc/picture_layer_impl.h ('k') | cc/picture_layer_tiling_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698