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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp

Issue 2212163002: Add some plumbing for the color management of canvases (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build and tests Created 4 years, 4 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, 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if (c) 102 if (c)
103 c->restoreToCount(m_saveCount); 103 c->restoreToCount(m_saveCount);
104 m_context->validateStateStack(); 104 m_context->validateStateStack();
105 } 105 }
106 private: 106 private:
107 Member<CanvasRenderingContext2D> m_context; 107 Member<CanvasRenderingContext2D> m_context;
108 int m_saveCount; 108 int m_saveCount;
109 }; 109 };
110 110
111 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, co nst CanvasContextCreationAttributes& attrs, Document& document) 111 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, co nst CanvasContextCreationAttributes& attrs, Document& document)
112 : CanvasRenderingContext(canvas) 112 : CanvasRenderingContext(canvas, nullptr, attrs)
113 , m_hasAlpha(attrs.alpha())
114 , m_contextLostMode(NotLostContext) 113 , m_contextLostMode(NotLostContext)
115 , m_contextRestorable(true) 114 , m_contextRestorable(true)
116 , m_tryRestoreContextAttemptCount(0) 115 , m_tryRestoreContextAttemptCount(0)
117 , m_dispatchContextLostEventTimer(this, &CanvasRenderingContext2D::dispatchC ontextLostEvent) 116 , m_dispatchContextLostEventTimer(this, &CanvasRenderingContext2D::dispatchC ontextLostEvent)
118 , m_dispatchContextRestoredEventTimer(this, &CanvasRenderingContext2D::dispa tchContextRestoredEvent) 117 , m_dispatchContextRestoredEventTimer(this, &CanvasRenderingContext2D::dispa tchContextRestoredEvent)
119 , m_tryRestoreContextEventTimer(this, &CanvasRenderingContext2D::tryRestoreC ontextEvent) 118 , m_tryRestoreContextEventTimer(this, &CanvasRenderingContext2D::tryRestoreC ontextEvent)
120 , m_pruneLocalFontCacheScheduled(false) 119 , m_pruneLocalFontCacheScheduled(false)
121 { 120 {
122 if (document.settings() && document.settings()->antialiasedClips2dCanvasEnab led()) 121 if (document.settings() && document.settings()->antialiasedClips2dCanvasEnab led())
123 m_clipAntialiasing = AntiAliased; 122 m_clipAntialiasing = AntiAliased;
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 SkCanvas* c = drawingCanvas(); 776 SkCanvas* c = drawingCanvas();
778 if (!c) 777 if (!c)
779 return; 778 return;
780 779
781 if (!std::isfinite(x) || !std::isfinite(y)) 780 if (!std::isfinite(x) || !std::isfinite(y))
782 return; 781 return;
783 if (maxWidth && (!std::isfinite(*maxWidth) || *maxWidth <= 0)) 782 if (maxWidth && (!std::isfinite(*maxWidth) || *maxWidth <= 0))
784 return; 783 return;
785 784
786 // Currently, SkPictureImageFilter does not support subpixel text anti-alias ing, which 785 // Currently, SkPictureImageFilter does not support subpixel text anti-alias ing, which
787 // is expected when !m_hasAlpha, so we need to fall out of display list mode when 786 // is expected when !creationAttributes().alpha(), so we need to fall out of display
788 // drawing text to an opaque canvas 787 // list mode when drawing text to an opaque canvas.
789 // crbug.com/583809 788 // crbug.com/583809
790 if (!m_hasAlpha && !isAccelerated()) 789 if (!creationAttributes().alpha() && !isAccelerated())
791 canvas()->disableDeferral(DisableDeferralReasonSubPixelTextAntiAliasingS upport); 790 canvas()->disableDeferral(DisableDeferralReasonSubPixelTextAntiAliasingS upport);
792 791
793 const Font& font = accessFont(); 792 const Font& font = accessFont();
794 if (!font.primaryFont()) 793 if (!font.primaryFont())
795 return; 794 return;
796 795
797 const FontMetrics& fontMetrics = font.getFontMetrics(); 796 const FontMetrics& fontMetrics = font.getFontMetrics();
798 797
799 // FIXME: Need to turn off font smoothing. 798 // FIXME: Need to turn off font smoothing.
800 799
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 return state().isTransformInvertible(); 902 return state().isTransformInvertible();
904 } 903 }
905 904
906 WebLayer* CanvasRenderingContext2D::platformLayer() const 905 WebLayer* CanvasRenderingContext2D::platformLayer() const
907 { 906 {
908 return canvas()->buffer() ? canvas()->buffer()->platformLayer() : 0; 907 return canvas()->buffer() ? canvas()->buffer()->platformLayer() : 0;
909 } 908 }
910 909
911 void CanvasRenderingContext2D::getContextAttributes(Canvas2DContextAttributes& a ttrs) const 910 void CanvasRenderingContext2D::getContextAttributes(Canvas2DContextAttributes& a ttrs) const
912 { 911 {
913 attrs.setAlpha(m_hasAlpha); 912 attrs.setAlpha(creationAttributes().alpha());
913 attrs.setColorSpace(colorSpaceAsString());
914 } 914 }
915 915
916 void CanvasRenderingContext2D::drawFocusIfNeeded(Element* element) 916 void CanvasRenderingContext2D::drawFocusIfNeeded(Element* element)
917 { 917 {
918 drawFocusIfNeededInternal(m_path, element); 918 drawFocusIfNeededInternal(m_path, element);
919 } 919 }
920 920
921 void CanvasRenderingContext2D::drawFocusIfNeeded(Path2D* path2d, Element* elemen t) 921 void CanvasRenderingContext2D::drawFocusIfNeeded(Path2D* path2d, Element* elemen t)
922 { 922 {
923 drawFocusIfNeededInternal(path2d->path(), element); 923 drawFocusIfNeededInternal(path2d->path(), element);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 return true; 1089 return true;
1090 } 1090 }
1091 1091
1092 void CanvasRenderingContext2D::resetUsageTracking() 1092 void CanvasRenderingContext2D::resetUsageTracking()
1093 { 1093 {
1094 UsageCounters newCounters; 1094 UsageCounters newCounters;
1095 m_usageCounters = newCounters; 1095 m_usageCounters = newCounters;
1096 } 1096 }
1097 1097
1098 } // namespace blink 1098 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698