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

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: per edge anti-aliasing 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 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 for (int i = left; i <= right; ++i) { 157 for (int i = left; i <= right; ++i) {
158 DrawableTile* tile = tileAt(i, j); 158 DrawableTile* tile = tileAt(i, j);
159 gfx::Rect tileRect = m_tiler->tileBounds(i, j); 159 gfx::Rect tileRect = m_tiler->tileBounds(i, j);
160 gfx::Rect displayRect = tileRect; 160 gfx::Rect displayRect = tileRect;
161 tileRect.Intersect(contentRect); 161 tileRect.Intersect(contentRect);
162 162
163 // Skip empty tiles. 163 // Skip empty tiles.
164 if (tileRect.IsEmpty()) 164 if (tileRect.IsEmpty())
165 continue; 165 continue;
166 166
167 bool clipped = false;
168 gfx::QuadF visibleContentInTargetQuad = MathUtil::mapQuad(drawTransf orm(), gfx::QuadF(visibleContentRect()), clipped);
169 bool isAxisAlignedInTarget = !clipped && visibleContentInTargetQuad. IsRectilinear();
170 bool useAA = m_tiler->hasBorderTexels() && !isAxisAlignedInTarget;
171
172 bool leftEdgeAA = !i && useAA;
173 bool topEdgeAA = !j && useAA;
174 bool rightEdgeAA = i == m_tiler->numTilesX() - 1 && useAA;
175 bool bottomEdgeAA = j == m_tiler->numTilesY() - 1 && useAA;
176
167 if (!tile || !tile->resourceId()) { 177 if (!tile || !tile->resourceId()) {
168 if (drawCheckerboardForMissingTiles()) { 178 if (drawCheckerboardForMissingTiles()) {
169 SkColor checkerColor; 179 SkColor checkerColor;
170 if (showDebugBorders()) 180 if (showDebugBorders())
171 checkerColor = tile ? DebugColors::InvalidatedTileChecke rboardColor() : DebugColors::EvictedTileCheckerboardColor(); 181 checkerColor = tile ? DebugColors::InvalidatedTileChecke rboardColor() : DebugColors::EvictedTileCheckerboardColor();
172 else 182 else
173 checkerColor = DebugColors::DefaultCheckerboardColor(); 183 checkerColor = DebugColors::DefaultCheckerboardColor();
174 184
175 scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = Checkerb oardDrawQuad::Create(); 185 scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = Checkerb oardDrawQuad::Create();
176 checkerboardQuad->SetNew(sharedQuadState, tileRect, checkerC olor); 186 checkerboardQuad->SetNew(sharedQuadState, tileRect, checkerC olor);
177 if (quadSink.append(checkerboardQuad.PassAs<DrawQuad>(), app endQuadsData)) 187 if (quadSink.append(checkerboardQuad.PassAs<DrawQuad>(), app endQuadsData))
178 appendQuadsData.numMissingTiles++; 188 appendQuadsData.numMissingTiles++;
179 } else { 189 } else {
180 scoped_ptr<SolidColorDrawQuad> solidColorQuad = SolidColorDr awQuad::Create(); 190 scoped_ptr<SolidColorDrawQuad> solidColorQuad = SolidColorDr awQuad::Create();
181 solidColorQuad->SetNew(sharedQuadState, tileRect, background Color()); 191 solidColorQuad->SetNew(sharedQuadState, tileRect, background Color(), leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA);
182 if (quadSink.append(solidColorQuad.PassAs<DrawQuad>(), appen dQuadsData)) 192 if (quadSink.append(solidColorQuad.PassAs<DrawQuad>(), appen dQuadsData))
183 appendQuadsData.numMissingTiles++; 193 appendQuadsData.numMissingTiles++;
184 } 194 }
185 continue; 195 continue;
186 } 196 }
187 197
188 gfx::Rect tileOpaqueRect = contentsOpaque() ? tileRect : gfx::Inters ectRects(tile->opaqueRect(), contentRect); 198 gfx::Rect tileOpaqueRect = contentsOpaque() ? tileRect : gfx::Inters ectRects(tile->opaqueRect(), contentRect);
189 199
190 // Keep track of how the top left has moved, so the texture can be 200 // Keep track of how the top left has moved, so the texture can be
191 // offset the same amount. 201 // offset the same amount.
192 gfx::Vector2d displayOffset = tileRect.origin() - displayRect.origin (); 202 gfx::Vector2d displayOffset = tileRect.origin() - displayRect.origin ();
193 gfx::Vector2d textureOffset = m_tiler->textureOffset(i, j) + display Offset; 203 gfx::Vector2d textureOffset = m_tiler->textureOffset(i, j) + display Offset;
194 gfx::RectF texCoordRect = gfx::RectF(tileRect.size()) + textureOffse t; 204 gfx::RectF texCoordRect = gfx::RectF(tileRect.size()) + textureOffse t;
195 205
196 float tileWidth = static_cast<float>(m_tiler->tileSize().width()); 206 float tileWidth = static_cast<float>(m_tiler->tileSize().width());
197 float tileHeight = static_cast<float>(m_tiler->tileSize().height()); 207 float tileHeight = static_cast<float>(m_tiler->tileSize().height());
198 gfx::Size textureSize(tileWidth, tileHeight); 208 gfx::Size textureSize(tileWidth, tileHeight);
199 209
200 bool clipped = false;
201 gfx::QuadF visibleContentInTargetQuad = MathUtil::mapQuad(drawTransf orm(), gfx::QuadF(visibleContentRect()), clipped);
202 bool isAxisAlignedInTarget = !clipped && visibleContentInTargetQuad. IsRectilinear();
203 bool useAA = m_tiler->hasBorderTexels() && !isAxisAlignedInTarget;
204
205 bool leftEdgeAA = !i && useAA;
206 bool topEdgeAA = !j && useAA;
207 bool rightEdgeAA = i == m_tiler->numTilesX() - 1 && useAA;
208 bool bottomEdgeAA = j == m_tiler->numTilesY() - 1 && useAA;
209
210 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); 210 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create();
211 quad->SetNew(sharedQuadState, tileRect, tileOpaqueRect, tile->resour ceId(), texCoordRect, textureSize, tile->contentsSwizzled(), leftEdgeAA, topEdge AA, rightEdgeAA, bottomEdgeAA); 211 quad->SetNew(sharedQuadState, tileRect, tileOpaqueRect, tile->resour ceId(), texCoordRect, textureSize, tile->contentsSwizzled(), leftEdgeAA, topEdge AA, rightEdgeAA, bottomEdgeAA);
212 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); 212 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData);
213 } 213 }
214 } 214 }
215 } 215 }
216 216
217 void TiledLayerImpl::setTilingData(const LayerTilingData& tiler) 217 void TiledLayerImpl::setTilingData(const LayerTilingData& tiler)
218 { 218 {
219 safeToDeleteDrawableTile = true; 219 safeToDeleteDrawableTile = true;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 m_tiler->reset(); 264 m_tiler->reset();
265 safeToDeleteDrawableTile = false; 265 safeToDeleteDrawableTile = false;
266 } 266 }
267 267
268 const char* TiledLayerImpl::layerTypeAsString() const 268 const char* TiledLayerImpl::layerTypeAsString() const
269 { 269 {
270 return "ContentLayer"; 270 return "ContentLayer";
271 } 271 }
272 272
273 } // namespace cc 273 } // namespace cc
OLDNEW
« cc/solid_color_draw_quad.h ('K') | « cc/test/render_pass_test_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698