Chromium Code Reviews| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 } | 83 } |
| 84 | 84 |
| 85 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, co nst Canvas2DContextAttributes* attrs, bool usesCSSCompatibilityParseMode) | 85 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, co nst Canvas2DContextAttributes* attrs, bool usesCSSCompatibilityParseMode) |
| 86 : CanvasRenderingContext(canvas) | 86 : CanvasRenderingContext(canvas) |
| 87 , m_usesCSSCompatibilityParseMode(usesCSSCompatibilityParseMode) | 87 , m_usesCSSCompatibilityParseMode(usesCSSCompatibilityParseMode) |
| 88 , m_hasAlpha(!attrs || attrs->alpha()) | 88 , m_hasAlpha(!attrs || attrs->alpha()) |
| 89 , m_isContextLost(false) | 89 , m_isContextLost(false) |
| 90 , m_contextRestorable(true) | 90 , m_contextRestorable(true) |
| 91 , m_storageMode(!attrs ? PersistentStorage : attrs->parsedStorage()) | 91 , m_storageMode(!attrs ? PersistentStorage : attrs->parsedStorage()) |
| 92 , m_tryRestoreContextAttemptCount(0) | 92 , m_tryRestoreContextAttemptCount(0) |
| 93 , m_clipCount(0) | |
| 93 , m_dispatchContextLostEventTimer(this, &CanvasRenderingContext2D::dispatchC ontextLostEvent) | 94 , m_dispatchContextLostEventTimer(this, &CanvasRenderingContext2D::dispatchC ontextLostEvent) |
| 94 , m_dispatchContextRestoredEventTimer(this, &CanvasRenderingContext2D::dispa tchContextRestoredEvent) | 95 , m_dispatchContextRestoredEventTimer(this, &CanvasRenderingContext2D::dispa tchContextRestoredEvent) |
| 95 , m_tryRestoreContextEventTimer(this, &CanvasRenderingContext2D::tryRestoreC ontextEvent) | 96 , m_tryRestoreContextEventTimer(this, &CanvasRenderingContext2D::tryRestoreC ontextEvent) |
| 96 { | 97 { |
| 97 m_stateStack.append(adoptPtrWillBeNoop(new State())); | 98 m_stateStack.append(adoptPtrWillBeNoop(new State())); |
| 98 ScriptWrappable::init(this); | 99 ScriptWrappable::init(this); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void CanvasRenderingContext2D::unwindStateStack() | 102 void CanvasRenderingContext2D::unwindStateStack() |
| 102 { | 103 { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 } | 225 } |
| 225 } | 226 } |
| 226 | 227 |
| 227 void CanvasRenderingContext2D::reset() | 228 void CanvasRenderingContext2D::reset() |
| 228 { | 229 { |
| 229 validateStateStack(); | 230 validateStateStack(); |
| 230 unwindStateStack(); | 231 unwindStateStack(); |
| 231 m_stateStack.resize(1); | 232 m_stateStack.resize(1); |
| 232 m_stateStack.first() = adoptPtrWillBeNoop(new State()); | 233 m_stateStack.first() = adoptPtrWillBeNoop(new State()); |
| 233 m_path.clear(); | 234 m_path.clear(); |
| 235 m_clipCount = 0; | |
| 234 validateStateStack(); | 236 validateStateStack(); |
| 235 } | 237 } |
| 236 | 238 |
| 237 // Important: Several of these properties are also stored in GraphicsContext's | 239 // Important: Several of these properties are also stored in GraphicsContext's |
| 238 // StrokeData. The default values that StrokeData uses may not the same values | 240 // StrokeData. The default values that StrokeData uses may not the same values |
| 239 // that the canvas 2d spec specifies. Make sure to sync the initial state of the | 241 // that the canvas 2d spec specifies. Make sure to sync the initial state of the |
| 240 // GraphicsContext in HTMLCanvasElement::createImageBuffer()! | 242 // GraphicsContext in HTMLCanvasElement::createImageBuffer()! |
| 241 CanvasRenderingContext2D::State::State() | 243 CanvasRenderingContext2D::State::State() |
| 242 : m_unrealizedSaveCount(0) | 244 : m_unrealizedSaveCount(0) |
| 243 , m_strokeStyle(CanvasStyle::createFromRGBA(Color::black)) | 245 , m_strokeStyle(CanvasStyle::createFromRGBA(Color::black)) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 GraphicsContext* context = drawingContext(); | 367 GraphicsContext* context = drawingContext(); |
| 366 if (context) | 368 if (context) |
| 367 context->save(); | 369 context->save(); |
| 368 validateStateStack(); | 370 validateStateStack(); |
| 369 } | 371 } |
| 370 } | 372 } |
| 371 | 373 |
| 372 void CanvasRenderingContext2D::restore() | 374 void CanvasRenderingContext2D::restore() |
| 373 { | 375 { |
| 374 validateStateStack(); | 376 validateStateStack(); |
| 377 if (isClipMode()) | |
| 378 --m_clipCount; | |
|
Justin Novosad
2014/07/02 15:12:31
I don't think this is correct. There could be mult
| |
| 375 if (state().m_unrealizedSaveCount) { | 379 if (state().m_unrealizedSaveCount) { |
| 376 // We never realized the save, so just record that it was unnecessary. | 380 // We never realized the save, so just record that it was unnecessary. |
| 377 --m_stateStack.last()->m_unrealizedSaveCount; | 381 --m_stateStack.last()->m_unrealizedSaveCount; |
| 378 return; | 382 return; |
| 379 } | 383 } |
| 380 ASSERT(m_stateStack.size() >= 1); | 384 ASSERT(m_stateStack.size() >= 1); |
| 381 if (m_stateStack.size() <= 1) | 385 if (m_stateStack.size() <= 1) |
| 382 return; | 386 return; |
| 383 m_path.transform(state().m_transform); | 387 m_path.transform(state().m_transform); |
| 384 m_stateStack.removeLast(); | 388 m_stateStack.removeLast(); |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1089 GraphicsContext* c = drawingContext(); | 1093 GraphicsContext* c = drawingContext(); |
| 1090 if (!c) { | 1094 if (!c) { |
| 1091 return; | 1095 return; |
| 1092 } | 1096 } |
| 1093 if (!state().m_invertibleCTM) { | 1097 if (!state().m_invertibleCTM) { |
| 1094 return; | 1098 return; |
| 1095 } | 1099 } |
| 1096 | 1100 |
| 1097 realizeSaves(); | 1101 realizeSaves(); |
| 1098 c->canvasClip(path, parseWinding(windingRuleString)); | 1102 c->canvasClip(path, parseWinding(windingRuleString)); |
| 1103 ++m_clipCount; | |
| 1099 } | 1104 } |
| 1100 | 1105 |
| 1101 void CanvasRenderingContext2D::clip(const String& windingRuleString) | 1106 void CanvasRenderingContext2D::clip(const String& windingRuleString) |
| 1102 { | 1107 { |
| 1103 clipInternal(m_path, windingRuleString); | 1108 clipInternal(m_path, windingRuleString); |
| 1104 } | 1109 } |
| 1105 | 1110 |
| 1106 void CanvasRenderingContext2D::clip(Path2D* domPath, const String& windingRuleSt ring) | 1111 void CanvasRenderingContext2D::clip(Path2D* domPath, const String& windingRuleSt ring) |
| 1107 { | 1112 { |
| 1108 clipInternal(domPath->path(), windingRuleString); | 1113 clipInternal(domPath->path(), windingRuleString); |
| (...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2378 | 2383 |
| 2379 if (m_path.isEmpty() || !context || !state().m_invertibleCTM | 2384 if (m_path.isEmpty() || !context || !state().m_invertibleCTM |
| 2380 || !context->getTransformedClipBounds(&clipBounds)) { | 2385 || !context->getTransformedClipBounds(&clipBounds)) { |
| 2381 exceptionState.throwDOMException(NotSupportedError, "The specified path has no pixels."); | 2386 exceptionState.throwDOMException(NotSupportedError, "The specified path has no pixels."); |
| 2382 return; | 2387 return; |
| 2383 } | 2388 } |
| 2384 | 2389 |
| 2385 Path specifiedPath = m_path; | 2390 Path specifiedPath = m_path; |
| 2386 specifiedPath.transform(state().m_transform); | 2391 specifiedPath.transform(state().m_transform); |
| 2387 | 2392 |
| 2388 if (context->isClipMode()) { | 2393 if (isClipMode()) { |
| 2389 // FIXME: The hit regions should take clipping region into account. | 2394 // FIXME: The hit regions should take clipping region into account. |
| 2390 // However, we have no way to get the region from canvas state stack by now. | 2395 // However, we have no way to get the region from canvas state stack by now. |
| 2391 // See http://crbug.com/387057 | 2396 // See http://crbug.com/387057 |
| 2392 exceptionState.throwDOMException(NotSupportedError, "The specified path has no pixels."); | 2397 exceptionState.throwDOMException(NotSupportedError, "The specified path has no pixels."); |
| 2393 return; | 2398 return; |
| 2394 } | 2399 } |
| 2395 | 2400 |
| 2396 passOptions.path = specifiedPath; | 2401 passOptions.path = specifiedPath; |
| 2397 addHitRegionInternal(passOptions, exceptionState); | 2402 addHitRegionInternal(passOptions, exceptionState); |
| 2398 } | 2403 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2433 | 2438 |
| 2434 unsigned CanvasRenderingContext2D::hitRegionsCount() const | 2439 unsigned CanvasRenderingContext2D::hitRegionsCount() const |
| 2435 { | 2440 { |
| 2436 if (m_hitRegionManager) | 2441 if (m_hitRegionManager) |
| 2437 return m_hitRegionManager->getHitRegionsCount(); | 2442 return m_hitRegionManager->getHitRegionsCount(); |
| 2438 | 2443 |
| 2439 return 0; | 2444 return 0; |
| 2440 } | 2445 } |
| 2441 | 2446 |
| 2442 } // namespace WebCore | 2447 } // namespace WebCore |
| OLD | NEW |