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

Side by Side Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 795833004: Use dictionaries for context creation attributes. Eliminate custom bindings. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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 | Annotate | Revision Log
OLDNEW
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
83 static const char ltr[] = "ltr"; 83 static const char ltr[] = "ltr";
84 static const double TryRestoreContextInterval = 0.5; 84 static const double TryRestoreContextInterval = 0.5;
85 static const unsigned MaxTryRestoreContextAttempts = 4; 85 static const unsigned MaxTryRestoreContextAttempts = 4;
86 static const unsigned FetchedFontsCacheLimit = 50; 86 static const unsigned FetchedFontsCacheLimit = 50;
87 87
88 static bool contextLostRestoredEventsEnabled() 88 static bool contextLostRestoredEventsEnabled()
89 { 89 {
90 return RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled(); 90 return RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled();
91 } 91 }
92 92
93 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, co nst Canvas2DContextAttributes* attrs, Document& document) 93 static Canvas2DContextStorage storageFromAttributes(const CanvasContextCreationA ttributes& attrs)
94 {
95 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled())
96 return PersistentStorage;
97
98 // The other valid option is "persistent" -- but since the default
99 // is Persistent, it isn't necessary to test for it explicitly.
100 if (attrs.hasStorage() && attrs.storage() == "discardable") {
101 return DiscardableStorage;
102 }
103 return PersistentStorage;
104 }
105
106 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, co nst CanvasContextCreationAttributes& attrs, Document& document)
94 : CanvasRenderingContext(canvas) 107 : CanvasRenderingContext(canvas)
95 , m_usesCSSCompatibilityParseMode(document.inQuirksMode()) 108 , m_usesCSSCompatibilityParseMode(document.inQuirksMode())
96 , m_clipAntialiasing(NotAntiAliased) 109 , m_clipAntialiasing(NotAntiAliased)
97 , m_hasAlpha(!attrs || attrs->alpha()) 110 , m_hasAlpha(attrs.alpha())
98 , m_isContextLost(false) 111 , m_isContextLost(false)
99 , m_contextRestorable(true) 112 , m_contextRestorable(true)
100 , m_storageMode(!attrs ? PersistentStorage : attrs->parsedStorage()) 113 , m_storageMode(storageFromAttributes(attrs))
101 , m_tryRestoreContextAttemptCount(0) 114 , m_tryRestoreContextAttemptCount(0)
102 , m_dispatchContextLostEventTimer(this, &CanvasRenderingContext2D::dispatchC ontextLostEvent) 115 , m_dispatchContextLostEventTimer(this, &CanvasRenderingContext2D::dispatchC ontextLostEvent)
103 , m_dispatchContextRestoredEventTimer(this, &CanvasRenderingContext2D::dispa tchContextRestoredEvent) 116 , m_dispatchContextRestoredEventTimer(this, &CanvasRenderingContext2D::dispa tchContextRestoredEvent)
104 , m_tryRestoreContextEventTimer(this, &CanvasRenderingContext2D::tryRestoreC ontextEvent) 117 , m_tryRestoreContextEventTimer(this, &CanvasRenderingContext2D::tryRestoreC ontextEvent)
105 { 118 {
106 if (document.settings() && document.settings()->antialiasedClips2dCanvasEnab led()) 119 if (document.settings() && document.settings()->antialiasedClips2dCanvasEnab led())
107 m_clipAntialiasing = AntiAliased; 120 m_clipAntialiasing = AntiAliased;
108 m_stateStack.append(adoptPtrWillBeNoop(new State())); 121 m_stateStack.append(adoptPtrWillBeNoop(new State()));
109 } 122 }
110 123
(...skipping 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 if (enabled == state().m_imageSmoothingEnabled) 2233 if (enabled == state().m_imageSmoothingEnabled)
2221 return; 2234 return;
2222 2235
2223 GraphicsContext* c = drawingContext(); 2236 GraphicsContext* c = drawingContext();
2224 realizeSaves(c); 2237 realizeSaves(c);
2225 modifiableState().m_imageSmoothingEnabled = enabled; 2238 modifiableState().m_imageSmoothingEnabled = enabled;
2226 if (c) 2239 if (c)
2227 c->setImageInterpolationQuality(enabled ? CanvasDefaultInterpolationQual ity : InterpolationNone); 2240 c->setImageInterpolationQuality(enabled ? CanvasDefaultInterpolationQual ity : InterpolationNone);
2228 } 2241 }
2229 2242
2230 PassRefPtrWillBeRawPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getC ontextAttributes() const 2243 void CanvasRenderingContext2D::getContextAttributes(Canvas2DContextAttributes& a ttrs) const
2231 { 2244 {
2232 RefPtrWillBeRawPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAt tributes::create(); 2245 attrs.setAlpha(m_hasAlpha);
2233 attributes->setAlpha(m_hasAlpha); 2246 if (RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled()) {
2234 return attributes.release(); 2247 attrs.setStorage(m_storageMode == PersistentStorage ? "persistent" : "di scardable");
2248 }
2235 } 2249 }
2236 2250
2237 void CanvasRenderingContext2D::drawFocusIfNeeded(Element* element) 2251 void CanvasRenderingContext2D::drawFocusIfNeeded(Element* element)
2238 { 2252 {
2239 drawFocusIfNeededInternal(m_path, element); 2253 drawFocusIfNeededInternal(m_path, element);
2240 } 2254 }
2241 2255
2242 void CanvasRenderingContext2D::drawFocusIfNeeded(Path2D* path2d, Element* elemen t) 2256 void CanvasRenderingContext2D::drawFocusIfNeeded(Path2D* path2d, Element* elemen t)
2243 { 2257 {
2244 drawFocusIfNeededInternal(path2d->path(), element); 2258 drawFocusIfNeededInternal(path2d->path(), element);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 2374
2361 unsigned CanvasRenderingContext2D::hitRegionsCount() const 2375 unsigned CanvasRenderingContext2D::hitRegionsCount() const
2362 { 2376 {
2363 if (m_hitRegionManager) 2377 if (m_hitRegionManager)
2364 return m_hitRegionManager->getHitRegionsCount(); 2378 return m_hitRegionManager->getHitRegionsCount();
2365 2379
2366 return 0; 2380 return 0;
2367 } 2381 }
2368 2382
2369 } // namespace blink 2383 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698