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

Side by Side Diff: Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp

Issue 10254020: Merge 114791 - [chromium] Clip TransparencyWin to prevent OOM from large Skia canvas (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1084/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « no previous file | Source/WebKit/chromium/tests/TransparencyWinTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 void TransparencyWin::computeLayerSize() 203 void TransparencyWin::computeLayerSize()
204 { 204 {
205 if (m_transformMode == Untransform) { 205 if (m_transformMode == Untransform) {
206 // The meaning of the "transformed" source rect is a little ambigous 206 // The meaning of the "transformed" source rect is a little ambigous
207 // here. The rest of the code doesn't care about it in the Untransform 207 // here. The rest of the code doesn't care about it in the Untransform
208 // case since we're using our own happy coordinate system. So we set it 208 // case since we're using our own happy coordinate system. So we set it
209 // to be the source rect since that matches how the code below actually 209 // to be the source rect since that matches how the code below actually
210 // uses the variable: to determine how to translate things to account 210 // uses the variable: to determine how to translate things to account
211 // for the offset of the layer. 211 // for the offset of the layer.
212 m_transformedSourceRect = m_sourceRect; 212 m_transformedSourceRect = m_sourceRect;
213 m_layerSize = IntSize(m_sourceRect.width(), m_sourceRect.height()); 213 } else if (m_transformMode == KeepTransform && m_layerMode != TextComposite) {
214 } else { 214 // FIXME: support clipping for other modes
215 IntRect clippedSourceRect = m_sourceRect;
216 SkRect clipBounds;
217 if (m_destContext->platformContext()->canvas()->getClipBounds(&clipBound s)) {
218 FloatRect clipRect(clipBounds.left(), clipBounds.top(), clipBounds.w idth(), clipBounds.height());
219 clippedSourceRect.intersect(enclosingIntRect(clipRect));
220 }
221 m_transformedSourceRect = m_orgTransform.mapRect(clippedSourceRect);
222 } else
215 m_transformedSourceRect = m_orgTransform.mapRect(m_sourceRect); 223 m_transformedSourceRect = m_orgTransform.mapRect(m_sourceRect);
216 m_layerSize = IntSize(m_transformedSourceRect.width(), m_transformedSour ceRect.height()); 224
217 } 225 m_layerSize = IntSize(m_transformedSourceRect.width(), m_transformedSourceRe ct.height());
218 } 226 }
219 227
220 void TransparencyWin::setupLayer() 228 void TransparencyWin::setupLayer()
221 { 229 {
222 switch (m_layerMode) { 230 switch (m_layerMode) {
223 case NoLayer: 231 case NoLayer:
224 setupLayerForNoLayer(); 232 setupLayerForNoLayer();
225 break; 233 break;
226 case OpaqueCompositeLayer: 234 case OpaqueCompositeLayer:
227 setupLayerForOpaqueCompositeLayer(); 235 setupLayerForOpaqueCompositeLayer();
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 SkBitmap& bitmap = const_cast<SkBitmap&>(m_drawContext->platformContext()-> 512 SkBitmap& bitmap = const_cast<SkBitmap&>(m_drawContext->platformContext()->
505 canvas()->getTopDevice()->accessBitmap(true)); 513 canvas()->getTopDevice()->accessBitmap(true));
506 for (int y = 0; y < m_layerSize.height(); y++) { 514 for (int y = 0; y < m_layerSize.height(); y++) {
507 uint32_t* row = bitmap.getAddr32(0, y); 515 uint32_t* row = bitmap.getAddr32(0, y);
508 for (int x = 0; x < m_layerSize.width(); x++) 516 for (int x = 0; x < m_layerSize.width(); x++)
509 row[x] |= 0xFF000000; 517 row[x] |= 0xFF000000;
510 } 518 }
511 } 519 }
512 520
513 } // namespace WebCore 521 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/WebKit/chromium/tests/TransparencyWinTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698