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

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

Issue 2388293002: Disable GPU acceleration on 2D canvas when readbacks are needed (Closed)
Patch Set: fixed tests Created 4 years, 2 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 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 sk_sp<SkImage> skImage; 1283 sk_sp<SkImage> skImage;
1284 if (m_context->is3d()) { 1284 if (m_context->is3d()) {
1285 // Because WebGL sources always require making a copy of the back buffer, we 1285 // Because WebGL sources always require making a copy of the back buffer, we
1286 // use paintRenderingResultsToCanvas instead of getImage in order to keep a cached 1286 // use paintRenderingResultsToCanvas instead of getImage in order to keep a cached
1287 // copy of the backing in the canvas's ImageBuffer. 1287 // copy of the backing in the canvas's ImageBuffer.
1288 renderingContext()->paintRenderingResultsToCanvas(BackBuffer); 1288 renderingContext()->paintRenderingResultsToCanvas(BackBuffer);
1289 skImage = hasImageBuffer() 1289 skImage = hasImageBuffer()
1290 ? buffer()->newSkImageSnapshot(hint, reason) 1290 ? buffer()->newSkImageSnapshot(hint, reason)
1291 : createTransparentImage(size())->imageForCurrentFrame(); 1291 : createTransparentImage(size())->imageForCurrentFrame();
1292 } else { 1292 } else {
1293 if (ExpensiveCanvasHeuristicParameters::
1294 DisableAccelerationToAvoidReadbacks &&
1295 !RuntimeEnabledFeatures::canvas2dFixedRenderingModeEnabled() &&
1296 hint == PreferNoAcceleration && m_context->isAccelerated() &&
1297 hasImageBuffer())
1298 buffer()->disableAcceleration();
1293 RefPtr<blink::Image> image = renderingContext()->getImage(hint, reason); 1299 RefPtr<blink::Image> image = renderingContext()->getImage(hint, reason);
1294 skImage = image ? image->imageForCurrentFrame() 1300 skImage = image ? image->imageForCurrentFrame()
1295 : createTransparentImage(size())->imageForCurrentFrame(); 1301 : createTransparentImage(size())->imageForCurrentFrame();
1296 } 1302 }
1297 1303
1298 if (skImage) { 1304 if (skImage) {
1299 *status = NormalSourceImageStatus; 1305 *status = NormalSourceImageStatus;
1300 return StaticBitmapImage::create(std::move(skImage)); 1306 return StaticBitmapImage::create(std::move(skImage));
1301 } 1307 }
1302 1308
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 mojom::blink::OffscreenCanvasSurfacePtr service; 1425 mojom::blink::OffscreenCanvasSurfacePtr service;
1420 Platform::current()->interfaceProvider()->getInterface( 1426 Platform::current()->interfaceProvider()->getInterface(
1421 mojo::GetProxy(&service)); 1427 mojo::GetProxy(&service));
1422 m_surfaceLayerBridge = 1428 m_surfaceLayerBridge =
1423 wrapUnique(new CanvasSurfaceLayerBridge(std::move(service))); 1429 wrapUnique(new CanvasSurfaceLayerBridge(std::move(service)));
1424 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), 1430 return m_surfaceLayerBridge->createSurfaceLayer(this->width(),
1425 this->height()); 1431 this->height());
1426 } 1432 }
1427 1433
1428 } // namespace blink 1434 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698