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

Side by Side Diff: cc/picture_layer_impl.cc

Issue 11414238: implement the logic to set tile priorities based on current matrix (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing comments 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/picture_layer_impl.h" 5 #include "cc/picture_layer_impl.h"
6 6
7 #include "base/time.h"
7 #include "cc/layer_tree_host_impl.h" 8 #include "cc/layer_tree_host_impl.h"
8 #include "cc/math_util.h" 9 #include "cc/math_util.h"
9 #include "cc/quad_sink.h" 10 #include "cc/quad_sink.h"
10 #include "cc/tile_draw_quad.h" 11 #include "cc/tile_draw_quad.h"
11 12
12 namespace cc { 13 namespace cc {
13 14
14 PictureLayerImpl::PictureLayerImpl(int id) : 15 PictureLayerImpl::PictureLayerImpl(int id) :
15 LayerImpl(id), 16 LayerImpl(id),
16 tilings_(this) { 17 tilings_(this),
18 last_update_time_(0) {
17 } 19 }
18 20
19 PictureLayerImpl::~PictureLayerImpl() { 21 PictureLayerImpl::~PictureLayerImpl() {
20 } 22 }
21 23
22 const char* PictureLayerImpl::layerTypeAsString() const { 24 const char* PictureLayerImpl::layerTypeAsString() const {
23 return "PictureLayer"; 25 return "PictureLayer";
24 } 26 }
25 27
26 void PictureLayerImpl::appendQuads(QuadSink& quadSink, 28 void PictureLayerImpl::appendQuads(QuadSink& quadSink,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 83 }
82 84
83 void PictureLayerImpl::didUpdateTransforms() { 85 void PictureLayerImpl::didUpdateTransforms() {
84 tilings_.SetLayerBounds(bounds()); 86 tilings_.SetLayerBounds(bounds());
85 // TODO(enne): Add more tilings during pinch zoom. 87 // TODO(enne): Add more tilings during pinch zoom.
86 if (!tilings_.num_tilings()) { 88 if (!tilings_.num_tilings()) {
87 gfx::Size tile_size = layerTreeHostImpl()->settings().defaultTileSize; 89 gfx::Size tile_size = layerTreeHostImpl()->settings().defaultTileSize;
88 tilings_.AddTiling(contentsScaleX(), tile_size); 90 tilings_.AddTiling(contentsScaleX(), tile_size);
89 // TODO(enne): handle invalidations, create new tiles 91 // TODO(enne): handle invalidations, create new tiles
90 } 92 }
93
94 gfx::Transform current_screen_space_transform = screenSpaceTransform();
95 double current_time =
96 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
97 double time_delta =
98 (last_update_time_ == 0 ? 0 : current_time - last_update_time_);
99 tilings_.UpdateTilePriorities(layerTreeHostImpl()->deviceViewportSize(),
100 contentsScaleX(),
101 contentsScaleY(),
102 last_screen_space_transform_,
103 current_screen_space_transform,
104 time_delta);
105
106 last_screen_space_transform_ = current_screen_space_transform;
107 last_update_time_ = current_time;
91 } 108 }
92 109
93 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling*, 110 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling*,
94 gfx::Rect rect) { 111 gfx::Rect rect) {
95 TileManager* tile_manager = layerTreeHostImpl()->tileManager(); 112 TileManager* tile_manager = layerTreeHostImpl()->tileManager();
96 113
97 return make_scoped_refptr(new Tile( 114 return make_scoped_refptr(new Tile(
98 tile_manager, 115 tile_manager,
99 &pile_, 116 &pile_,
100 rect.size(), 117 rect.size(),
101 GL_RGBA, 118 GL_RGBA,
102 rect)); 119 rect));
103 } 120 }
104 121
105 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { 122 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) {
106 tilings_.CloneFrom(other->tilings_); 123 tilings_.CloneFrom(other->tilings_);
107 } 124 }
108 125
126 void PictureLayerImpl::setContentBounds(const gfx::Size& size) {
127 if (contentBounds() != size)
128 last_update_time_ = 0;
129 LayerImpl::setContentBounds(size);
130 }
131
132 void PictureLayerImpl::setContentsScale(float scaleX, float scaleY) {
133 if (contentsScaleX() != scaleX || contentsScaleY() != scaleY) {
134 last_update_time_ = 0;
135 }
136 LayerImpl::setContentsScale(scaleX, scaleY);
137 }
138
139 void PictureLayerImpl::setBounds(const gfx::Size& size) {
140 if (bounds() != size)
141 last_update_time_ = 0;
142 LayerImpl::setBounds(size);
143 }
144
109 } // namespace cc 145 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698