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

Side by Side Diff: cc/tiled_layer.cc

Issue 11276060: Pass accurate contentsScale to LayerImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 1 month 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
« no previous file with comments | « cc/tiled_layer.h ('k') | cc/tiled_layer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/tiled_layer.h" 7 #include "cc/tiled_layer.h"
8 8
9 #include "Region.h" 9 #include "Region.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 , m_updaterResource(updaterResource.Pass()) 77 , m_updaterResource(updaterResource.Pass())
78 { 78 {
79 } 79 }
80 80
81 scoped_ptr<LayerUpdater::Resource> m_updaterResource; 81 scoped_ptr<LayerUpdater::Resource> m_updaterResource;
82 82
83 DISALLOW_COPY_AND_ASSIGN(UpdatableTile); 83 DISALLOW_COPY_AND_ASSIGN(UpdatableTile);
84 }; 84 };
85 85
86 TiledLayer::TiledLayer() 86 TiledLayer::TiledLayer()
87 : Layer() 87 : ContentsScalingLayer()
88 , m_textureFormat(GL_INVALID_ENUM) 88 , m_textureFormat(GL_INVALID_ENUM)
89 , m_skipsDraw(false) 89 , m_skipsDraw(false)
90 , m_failedUpdate(false) 90 , m_failedUpdate(false)
91 , m_tilingOption(AutoTile) 91 , m_tilingOption(AutoTile)
92 { 92 {
93 m_tiler = LayerTilingData::create(IntSize(), LayerTilingData::HasBorderTexel s); 93 m_tiler = LayerTilingData::create(IntSize(), LayerTilingData::HasBorderTexel s);
94 } 94 }
95 95
96 TiledLayer::~TiledLayer() 96 TiledLayer::~TiledLayer()
97 { 97 {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 m_tiler->setTileSize(size); 159 m_tiler->setTileSize(size);
160 } 160 }
161 161
162 void TiledLayer::setBorderTexelOption(LayerTilingData::BorderTexelOption borderT exelOption) 162 void TiledLayer::setBorderTexelOption(LayerTilingData::BorderTexelOption borderT exelOption)
163 { 163 {
164 m_tiler->setBorderTexelOption(borderTexelOption); 164 m_tiler->setBorderTexelOption(borderTexelOption);
165 } 165 }
166 166
167 bool TiledLayer::drawsContent() const 167 bool TiledLayer::drawsContent() const
168 { 168 {
169 if (!Layer::drawsContent()) 169 if (!ContentsScalingLayer::drawsContent())
170 return false; 170 return false;
171 171
172 bool hasMoreThanOneTile = m_tiler->numTilesX() > 1 || m_tiler->numTilesY() > 1; 172 bool hasMoreThanOneTile = m_tiler->numTilesX() > 1 || m_tiler->numTilesY() > 1;
173 if (m_tilingOption == NeverTile && hasMoreThanOneTile) 173 if (m_tilingOption == NeverTile && hasMoreThanOneTile)
174 return false; 174 return false;
175 175
176 return true; 176 return true;
177 } 177 }
178 178
179 bool TiledLayer::needsContentsScale() const
180 {
181 return true;
182 }
183
184 IntSize TiledLayer::contentBounds() const
185 {
186 return IntSize(lroundf(bounds().width() * contentsScale()), lroundf(bounds() .height() * contentsScale()));
187 }
188
189 void TiledLayer::setTilingOption(TilingOption tilingOption) 179 void TiledLayer::setTilingOption(TilingOption tilingOption)
190 { 180 {
191 m_tilingOption = tilingOption; 181 m_tilingOption = tilingOption;
192 } 182 }
193 183
194 void TiledLayer::setIsMask(bool isMask) 184 void TiledLayer::setIsMask(bool isMask)
195 { 185 {
196 setTilingOption(isMask ? NeverTile : AutoTile); 186 setTilingOption(isMask ? NeverTile : AutoTile);
197 } 187 }
198 188
199 void TiledLayer::pushPropertiesTo(LayerImpl* layer) 189 void TiledLayer::pushPropertiesTo(LayerImpl* layer)
200 { 190 {
201 Layer::pushPropertiesTo(layer); 191 ContentsScalingLayer::pushPropertiesTo(layer);
202 192
203 TiledLayerImpl* tiledLayer = static_cast<TiledLayerImpl*>(layer); 193 TiledLayerImpl* tiledLayer = static_cast<TiledLayerImpl*>(layer);
204 194
205 tiledLayer->setSkipsDraw(m_skipsDraw); 195 tiledLayer->setSkipsDraw(m_skipsDraw);
206 tiledLayer->setTilingData(*m_tiler); 196 tiledLayer->setTilingData(*m_tiler);
207 std::vector<UpdatableTile*> invalidTiles; 197 std::vector<UpdatableTile*> invalidTiles;
208 198
209 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin( ); iter != m_tiler->tiles().end(); ++iter) { 199 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin( ); iter != m_tiler->tiles().end(); ++iter) {
210 int i = iter->first.first; 200 int i = iter->first.first;
211 int j = iter->first.second; 201 int j = iter->first.second;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 { 233 {
244 if (host && host != layerTreeHost()) { 234 if (host && host != layerTreeHost()) {
245 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().be gin(); iter != m_tiler->tiles().end(); ++iter) { 235 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().be gin(); iter != m_tiler->tiles().end(); ++iter) {
246 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); 236 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second);
247 // FIXME: This should not ever be null. 237 // FIXME: This should not ever be null.
248 if (!tile) 238 if (!tile)
249 continue; 239 continue;
250 tile->managedTexture()->setTextureManager(host->contentsTextureManag er()); 240 tile->managedTexture()->setTextureManager(host->contentsTextureManag er());
251 } 241 }
252 } 242 }
253 Layer::setLayerTreeHost(host); 243 ContentsScalingLayer::setLayerTreeHost(host);
254 } 244 }
255 245
256 UpdatableTile* TiledLayer::tileAt(int i, int j) const 246 UpdatableTile* TiledLayer::tileAt(int i, int j) const
257 { 247 {
258 return static_cast<UpdatableTile*>(m_tiler->tileAt(i, j)); 248 return static_cast<UpdatableTile*>(m_tiler->tileAt(i, j));
259 } 249 }
260 250
261 UpdatableTile* TiledLayer::createTile(int i, int j) 251 UpdatableTile* TiledLayer::createTile(int i, int j)
262 { 252 {
263 createUpdaterIfNeeded(); 253 createUpdaterIfNeeded();
(...skipping 10 matching lines...) Expand all
274 if (!addedTile) 264 if (!addedTile)
275 CRASH(); 265 CRASH();
276 if (!tileAt(i, j)) 266 if (!tileAt(i, j))
277 CRASH(); 267 CRASH();
278 268
279 return addedTile; 269 return addedTile;
280 } 270 }
281 271
282 void TiledLayer::setNeedsDisplayRect(const FloatRect& dirtyRect) 272 void TiledLayer::setNeedsDisplayRect(const FloatRect& dirtyRect)
283 { 273 {
284 float contentsWidthScale = static_cast<float>(contentBounds().width()) / bou nds().width(); 274 invalidateContentRect(layerRectToContentRect(dirtyRect));
285 float contentsHeightScale = static_cast<float>(contentBounds().height()) / b ounds().height(); 275 ContentsScalingLayer::setNeedsDisplayRect(dirtyRect);
286 FloatRect scaledDirtyRect(dirtyRect);
287 scaledDirtyRect.scale(contentsWidthScale, contentsHeightScale);
288 IntRect dirty = enclosingIntRect(scaledDirtyRect);
289 invalidateContentRect(dirty);
290 Layer::setNeedsDisplayRect(dirtyRect);
291 } 276 }
292 277
293 void TiledLayer::setUseLCDText(bool useLCDText) 278 void TiledLayer::setUseLCDText(bool useLCDText)
294 { 279 {
295 Layer::setUseLCDText(useLCDText); 280 ContentsScalingLayer::setUseLCDText(useLCDText);
296 281
297 LayerTilingData::BorderTexelOption borderTexelOption; 282 LayerTilingData::BorderTexelOption borderTexelOption;
298 #if OS(ANDROID) 283 #if OS(ANDROID)
299 // Always want border texels and GL_LINEAR due to pinch zoom. 284 // Always want border texels and GL_LINEAR due to pinch zoom.
300 borderTexelOption = LayerTilingData::HasBorderTexels; 285 borderTexelOption = LayerTilingData::HasBorderTexels;
301 #else 286 #else
302 borderTexelOption = useLCDText ? LayerTilingData::NoBorderTexels : LayerTili ngData::HasBorderTexels; 287 borderTexelOption = useLCDText ? LayerTilingData::NoBorderTexels : LayerTili ngData::HasBorderTexels;
303 #endif 288 #endif
304 setBorderTexelOption(borderTexelOption); 289 setBorderTexelOption(borderTexelOption);
305 } 290 }
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 IntRect prepaintRect = visibleContentRect(); 777 IntRect prepaintRect = visibleContentRect();
793 prepaintRect.inflateX(m_tiler->tileSize().width() * prepaintColumns); 778 prepaintRect.inflateX(m_tiler->tileSize().width() * prepaintColumns);
794 prepaintRect.inflateY(m_tiler->tileSize().height() * prepaintRows); 779 prepaintRect.inflateY(m_tiler->tileSize().height() * prepaintRows);
795 IntRect contentRect(IntPoint::zero(), contentBounds()); 780 IntRect contentRect(IntPoint::zero(), contentBounds());
796 prepaintRect.intersect(contentRect); 781 prepaintRect.intersect(contentRect);
797 782
798 return prepaintRect; 783 return prepaintRect;
799 } 784 }
800 785
801 } 786 }
OLDNEW
« no previous file with comments | « cc/tiled_layer.h ('k') | cc/tiled_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698