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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2063473002: Make 2D canvas disable gpu acceleration when getImageData is called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments and fix test failures Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 if (ro && (!m_context || !m_context->isAccelerated())) { 311 if (ro && (!m_context || !m_context->isAccelerated())) {
312 LayoutRect mappedDirtyRect(enclosingIntRect(mapRect(m_dirtyRect, srcRect , FloatRect(ro->contentBoxRect())))); 312 LayoutRect mappedDirtyRect(enclosingIntRect(mapRect(m_dirtyRect, srcRect , FloatRect(ro->contentBoxRect()))));
313 // For querying PaintLayer::compositingState() 313 // For querying PaintLayer::compositingState()
314 // FIXME: is this invalidation using the correct compositing state? 314 // FIXME: is this invalidation using the correct compositing state?
315 DisableCompositingQueryAsserts disabler; 315 DisableCompositingQueryAsserts disabler;
316 ro->invalidatePaintRectangle(mappedDirtyRect); 316 ro->invalidatePaintRectangle(mappedDirtyRect);
317 } 317 }
318 m_dirtyRect = FloatRect(); 318 m_dirtyRect = FloatRect();
319 } 319 }
320 320
321 void HTMLCanvasElement::didDisableAcceleration()
322 {
323 // We must force a paint invalidation on the canvas even if it's
324 // content did not change because it layer was destroyed.
325 didDraw(FloatRect(0, 0, size().width(), size().height()));
326 }
327
321 void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const 328 void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const
322 { 329 {
323 if (m_context) 330 if (m_context)
324 m_context->restoreCanvasMatrixClipStack(canvas); 331 m_context->restoreCanvasMatrixClipStack(canvas);
325 } 332 }
326 333
327 void HTMLCanvasElement::doDeferredPaintInvalidation() 334 void HTMLCanvasElement::doDeferredPaintInvalidation()
328 { 335 {
329 DCHECK(!m_dirtyRect.isEmpty()); 336 DCHECK(!m_dirtyRect.isEmpty());
330 if (!m_context->is2d()) { 337 if (!m_context->is2d()) {
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 1194
1188 bool HTMLCanvasElement::createSurfaceLayer() 1195 bool HTMLCanvasElement::createSurfaceLayer()
1189 { 1196 {
1190 DCHECK(!m_surfaceLayerBridge); 1197 DCHECK(!m_surfaceLayerBridge);
1191 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne w CanvasSurfaceLayerBridgeClientImpl()); 1198 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne w CanvasSurfaceLayerBridgeClientImpl());
1192 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri dgeClient))); 1199 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri dgeClient)));
1193 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height( )); 1200 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height( ));
1194 } 1201 }
1195 1202
1196 } // namespace blink 1203 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698