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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp

Issue 1877473002: Disable 2D canvas switch to CPU rendering while backgrounded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 { 276 {
277 if (m_surface) 277 if (m_surface)
278 return m_surface.get(); 278 return m_surface.get();
279 279
280 if (m_layer && !isHibernating() && hint == PreferAcceleration) { 280 if (m_layer && !isHibernating() && hint == PreferAcceleration) {
281 return nullptr; // re-creation will happen through restore() 281 return nullptr; // re-creation will happen through restore()
282 } 282 }
283 283
284 bool wantAcceleration = shouldAccelerate(hint); 284 bool wantAcceleration = shouldAccelerate(hint);
285 bool surfaceIsAccelerated; 285 bool surfaceIsAccelerated;
286 286 if (CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU && isHidden() && wantAccelerati on) {
287 if (isHidden() && wantAcceleration) {
288 wantAcceleration = false; 287 wantAcceleration = false;
289 m_softwareRenderingWhileHidden = true; 288 m_softwareRenderingWhileHidden = true;
290 } 289 }
291 290
292 m_surface = createSkSurface(wantAcceleration ? m_contextProvider->grContext( ) : nullptr, m_size, m_msaaSampleCount, m_opacityMode, &surfaceIsAccelerated); 291 m_surface = createSkSurface(wantAcceleration ? m_contextProvider->grContext( ) : nullptr, m_size, m_msaaSampleCount, m_opacityMode, &surfaceIsAccelerated);
293 292
294 if (!m_surface) 293 if (!m_surface)
295 reportSurfaceCreationFailure(); 294 reportSurfaceCreationFailure();
296 295
297 if (m_surface && surfaceIsAccelerated && !m_layer) { 296 if (m_surface && surfaceIsAccelerated && !m_layer) {
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 m_parentLayerBridge = other.m_parentLayerBridge; 832 m_parentLayerBridge = other.m_parentLayerBridge;
834 } 833 }
835 834
836 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) 835 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event)
837 { 836 {
838 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount)); 837 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount));
839 hibernationHistogram.count(event); 838 hibernationHistogram.count(event);
840 } 839 }
841 840
842 } // namespace blink 841 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698