| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
| 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
| 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. |
| 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 10 * | 10 * |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } | 190 } |
| 191 | 191 |
| 192 void CanvasRenderingContext2D::loseContext(LostContextMode lostMode) | 192 void CanvasRenderingContext2D::loseContext(LostContextMode lostMode) |
| 193 { | 193 { |
| 194 if (m_contextLostMode != NotLostContext) | 194 if (m_contextLostMode != NotLostContext) |
| 195 return; | 195 return; |
| 196 m_contextLostMode = lostMode; | 196 m_contextLostMode = lostMode; |
| 197 if (m_contextLostMode == SyntheticLostContext) { | 197 if (m_contextLostMode == SyntheticLostContext) { |
| 198 canvas()->discardImageBuffer(); | 198 canvas()->discardImageBuffer(); |
| 199 } | 199 } |
| 200 m_dispatchContextLostEventTimer.startOneShot(0, FROM_HERE); | 200 m_dispatchContextLostEventTimer.startOneShot(0, BLINK_FROM_HERE); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void CanvasRenderingContext2D::didSetSurfaceSize() | 203 void CanvasRenderingContext2D::didSetSurfaceSize() |
| 204 { | 204 { |
| 205 if (!m_contextRestorable) | 205 if (!m_contextRestorable) |
| 206 return; | 206 return; |
| 207 // This code path is for restoring from an eviction | 207 // This code path is for restoring from an eviction |
| 208 // Restoring from surface failure is handled internally | 208 // Restoring from surface failure is handled internally |
| 209 ASSERT(m_contextLostMode != NotLostContext && !canvas()->hasImageBuffer()); | 209 ASSERT(m_contextLostMode != NotLostContext && !canvas()->hasImageBuffer()); |
| 210 | 210 |
| 211 if (canvas()->buffer()) { | 211 if (canvas()->buffer()) { |
| 212 if (contextLostRestoredEventsEnabled()) { | 212 if (contextLostRestoredEventsEnabled()) { |
| 213 m_dispatchContextRestoredEventTimer.startOneShot(0, FROM_HERE); | 213 m_dispatchContextRestoredEventTimer.startOneShot(0, BLINK_FROM_HERE)
; |
| 214 } else { | 214 } else { |
| 215 // legacy synchronous context restoration. | 215 // legacy synchronous context restoration. |
| 216 reset(); | 216 reset(); |
| 217 m_contextLostMode = NotLostContext; | 217 m_contextLostMode = NotLostContext; |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 DEFINE_TRACE(CanvasRenderingContext2D) | 222 DEFINE_TRACE(CanvasRenderingContext2D) |
| 223 { | 223 { |
| 224 visitor->trace(m_stateStack); | 224 visitor->trace(m_stateStack); |
| 225 visitor->trace(m_hitRegionManager); | 225 visitor->trace(m_hitRegionManager); |
| 226 CanvasRenderingContext::trace(visitor); | 226 CanvasRenderingContext::trace(visitor); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void CanvasRenderingContext2D::dispatchContextLostEvent(Timer<CanvasRenderingCon
text2D>*) | 229 void CanvasRenderingContext2D::dispatchContextLostEvent(Timer<CanvasRenderingCon
text2D>*) |
| 230 { | 230 { |
| 231 if (contextLostRestoredEventsEnabled()) { | 231 if (contextLostRestoredEventsEnabled()) { |
| 232 RefPtrWillBeRawPtr<Event> event = Event::createCancelable(EventTypeNames
::contextlost); | 232 RefPtrWillBeRawPtr<Event> event = Event::createCancelable(EventTypeNames
::contextlost); |
| 233 canvas()->dispatchEvent(event); | 233 canvas()->dispatchEvent(event); |
| 234 if (event->defaultPrevented()) { | 234 if (event->defaultPrevented()) { |
| 235 m_contextRestorable = false; | 235 m_contextRestorable = false; |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 | 238 |
| 239 // If RealLostContext, it means the context was not lost due to surface fail
ure | 239 // If RealLostContext, it means the context was not lost due to surface fail
ure |
| 240 // but rather due to a an eviction, which means image buffer exists. | 240 // but rather due to a an eviction, which means image buffer exists. |
| 241 if (m_contextRestorable && m_contextLostMode == RealLostContext) { | 241 if (m_contextRestorable && m_contextLostMode == RealLostContext) { |
| 242 m_tryRestoreContextAttemptCount = 0; | 242 m_tryRestoreContextAttemptCount = 0; |
| 243 m_tryRestoreContextEventTimer.startRepeating(TryRestoreContextInterval,
FROM_HERE); | 243 m_tryRestoreContextEventTimer.startRepeating(TryRestoreContextInterval,
BLINK_FROM_HERE); |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 | 246 |
| 247 void CanvasRenderingContext2D::tryRestoreContextEvent(Timer<CanvasRenderingConte
xt2D>* timer) | 247 void CanvasRenderingContext2D::tryRestoreContextEvent(Timer<CanvasRenderingConte
xt2D>* timer) |
| 248 { | 248 { |
| 249 if (m_contextLostMode == NotLostContext) { | 249 if (m_contextLostMode == NotLostContext) { |
| 250 // Canvas was already restored (possibly thanks to a resize), so stop tr
ying. | 250 // Canvas was already restored (possibly thanks to a resize), so stop tr
ying. |
| 251 m_tryRestoreContextEventTimer.stop(); | 251 m_tryRestoreContextEventTimer.stop(); |
| 252 return; | 252 return; |
| 253 } | 253 } |
| (...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2324 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) | 2324 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) |
| 2325 return; | 2325 return; |
| 2326 if (alpha < 0xFF) | 2326 if (alpha < 0xFF) |
| 2327 return; | 2327 return; |
| 2328 } | 2328 } |
| 2329 | 2329 |
| 2330 canvas()->buffer()->willOverwriteCanvas(); | 2330 canvas()->buffer()->willOverwriteCanvas(); |
| 2331 } | 2331 } |
| 2332 | 2332 |
| 2333 } // namespace blink | 2333 } // namespace blink |
| OLD | NEW |