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

Side by Side Diff: cc/tiled_layer_impl.cc

Issue 11649005: cc: Support anti-aliasing for solid color layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and add DrawQuad::AntiAliasing struct. 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 unified diff | Download patch | Annotate | Revision Log
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 "cc/tiled_layer_impl.h" 5 #include "cc/tiled_layer_impl.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "cc/append_quads_data.h" 9 #include "cc/append_quads_data.h"
10 #include "cc/checkerboard_draw_quad.h" 10 #include "cc/checkerboard_draw_quad.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 for (int i = left; i <= right; ++i) { 155 for (int i = left; i <= right; ++i) {
156 DrawableTile* tile = tileAt(i, j); 156 DrawableTile* tile = tileAt(i, j);
157 gfx::Rect tileRect = m_tiler->tileBounds(i, j); 157 gfx::Rect tileRect = m_tiler->tileBounds(i, j);
158 gfx::Rect displayRect = tileRect; 158 gfx::Rect displayRect = tileRect;
159 tileRect.Intersect(contentRect); 159 tileRect.Intersect(contentRect);
160 160
161 // Skip empty tiles. 161 // Skip empty tiles.
162 if (tileRect.IsEmpty()) 162 if (tileRect.IsEmpty())
163 continue; 163 continue;
164 164
165 bool clipped = false;
166 gfx::QuadF visibleContentInTargetQuad = MathUtil::mapQuad(drawTransf orm(), gfx::QuadF(visibleContentRect()), clipped);
167 bool isAxisAlignedInTarget = !clipped && visibleContentInTargetQuad. IsRectilinear();
168 bool useAA = m_tiler->hasBorderTexels() && !isAxisAlignedInTarget;
169
170 bool leftEdgeAA = !i && useAA;
171 bool topEdgeAA = !j && useAA;
172 bool rightEdgeAA = i == m_tiler->numTilesX() - 1 && useAA;
173 bool bottomEdgeAA = j == m_tiler->numTilesY() - 1 && useAA;
174
165 if (!tile || !tile->resourceId()) { 175 if (!tile || !tile->resourceId()) {
166 if (drawCheckerboardForMissingTiles()) { 176 if (drawCheckerboardForMissingTiles()) {
167 SkColor checkerColor; 177 SkColor checkerColor;
168 if (showDebugBorders()) 178 if (showDebugBorders())
169 checkerColor = tile ? DebugColors::InvalidatedTileChecke rboardColor() : DebugColors::EvictedTileCheckerboardColor(); 179 checkerColor = tile ? DebugColors::InvalidatedTileChecke rboardColor() : DebugColors::EvictedTileCheckerboardColor();
170 else 180 else
171 checkerColor = DebugColors::DefaultCheckerboardColor(); 181 checkerColor = DebugColors::DefaultCheckerboardColor();
172 182
173 scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = Checkerb oardDrawQuad::Create(); 183 scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = Checkerb oardDrawQuad::Create();
174 checkerboardQuad->SetNew(sharedQuadState, tileRect, checkerC olor); 184 checkerboardQuad->SetNew(sharedQuadState, tileRect, checkerC olor);
175 if (quadSink.append(checkerboardQuad.PassAs<DrawQuad>(), app endQuadsData)) 185 if (quadSink.append(checkerboardQuad.PassAs<DrawQuad>(), app endQuadsData))
176 appendQuadsData.numMissingTiles++; 186 appendQuadsData.numMissingTiles++;
177 } else { 187 } else {
178 scoped_ptr<SolidColorDrawQuad> solidColorQuad = SolidColorDr awQuad::Create(); 188 scoped_ptr<SolidColorDrawQuad> solidColorQuad = SolidColorDr awQuad::Create();
179 solidColorQuad->SetNew(sharedQuadState, tileRect, background Color()); 189 solidColorQuad->SetNew(sharedQuadState, tileRect, DrawQuad:: AntiAliasing(leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA), backgroundColor( ));
180 if (quadSink.append(solidColorQuad.PassAs<DrawQuad>(), appen dQuadsData)) 190 if (quadSink.append(solidColorQuad.PassAs<DrawQuad>(), appen dQuadsData))
181 appendQuadsData.numMissingTiles++; 191 appendQuadsData.numMissingTiles++;
182 } 192 }
183 continue; 193 continue;
184 } 194 }
185 195
186 gfx::Rect tileOpaqueRect = contentsOpaque() ? tileRect : gfx::Inters ectRects(tile->opaqueRect(), contentRect); 196 gfx::Rect tileOpaqueRect = contentsOpaque() ? tileRect : gfx::Inters ectRects(tile->opaqueRect(), contentRect);
187 197
188 // Keep track of how the top left has moved, so the texture can be 198 // Keep track of how the top left has moved, so the texture can be
189 // offset the same amount. 199 // offset the same amount.
190 gfx::Vector2d displayOffset = tileRect.origin() - displayRect.origin (); 200 gfx::Vector2d displayOffset = tileRect.origin() - displayRect.origin ();
191 gfx::Vector2d textureOffset = m_tiler->textureOffset(i, j) + display Offset; 201 gfx::Vector2d textureOffset = m_tiler->textureOffset(i, j) + display Offset;
192 gfx::RectF texCoordRect = gfx::RectF(tileRect.size()) + textureOffse t; 202 gfx::RectF texCoordRect = gfx::RectF(tileRect.size()) + textureOffse t;
193 203
194 float tileWidth = static_cast<float>(m_tiler->tileSize().width()); 204 float tileWidth = static_cast<float>(m_tiler->tileSize().width());
195 float tileHeight = static_cast<float>(m_tiler->tileSize().height()); 205 float tileHeight = static_cast<float>(m_tiler->tileSize().height());
196 gfx::Size textureSize(tileWidth, tileHeight); 206 gfx::Size textureSize(tileWidth, tileHeight);
197 207
198 bool clipped = false;
199 gfx::QuadF visibleContentInTargetQuad = MathUtil::mapQuad(drawTransf orm(), gfx::QuadF(visibleContentRect()), clipped);
200 bool isAxisAlignedInTarget = !clipped && visibleContentInTargetQuad. IsRectilinear();
201 bool useAA = m_tiler->hasBorderTexels() && !isAxisAlignedInTarget;
202
203 bool leftEdgeAA = !i && useAA;
204 bool topEdgeAA = !j && useAA;
205 bool rightEdgeAA = i == m_tiler->numTilesX() - 1 && useAA;
206 bool bottomEdgeAA = j == m_tiler->numTilesY() - 1 && useAA;
207
208 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); 208 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create();
209 quad->SetNew(sharedQuadState, tileRect, tileOpaqueRect, tile->resour ceId(), texCoordRect, textureSize, tile->contentsSwizzled(), leftEdgeAA, topEdge AA, rightEdgeAA, bottomEdgeAA); 209 quad->SetNew(sharedQuadState, tileRect, tileOpaqueRect, DrawQuad::An tiAliasing(leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA), tile->resourceId() , texCoordRect, textureSize, tile->contentsSwizzled());
210 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); 210 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData);
211 } 211 }
212 } 212 }
213 } 213 }
214 214
215 void TiledLayerImpl::setTilingData(const LayerTilingData& tiler) 215 void TiledLayerImpl::setTilingData(const LayerTilingData& tiler)
216 { 216 {
217 safeToDeleteDrawableTile = true; 217 safeToDeleteDrawableTile = true;
218 218
219 if (m_tiler) 219 if (m_tiler)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 m_tiler->reset(); 262 m_tiler->reset();
263 safeToDeleteDrawableTile = false; 263 safeToDeleteDrawableTile = false;
264 } 264 }
265 265
266 const char* TiledLayerImpl::layerTypeAsString() const 266 const char* TiledLayerImpl::layerTypeAsString() const
267 { 267 {
268 return "ContentLayer"; 268 return "ContentLayer";
269 } 269 }
270 270
271 } // namespace cc 271 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698