OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 4 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
5 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
7 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 7 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
8 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 8 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
9 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. |
10 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 10 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 #include "public/platform/Platform.h" | 63 #include "public/platform/Platform.h" |
64 #include "third_party/skia/include/core/SkCanvas.h" | 64 #include "third_party/skia/include/core/SkCanvas.h" |
65 #include "third_party/skia/include/core/SkImageFilter.h" | 65 #include "third_party/skia/include/core/SkImageFilter.h" |
66 #include "wtf/MathExtras.h" | 66 #include "wtf/MathExtras.h" |
67 #include "wtf/text/StringBuilder.h" | 67 #include "wtf/text/StringBuilder.h" |
68 #include "wtf/typed_arrays/ArrayBufferContents.h" | 68 #include "wtf/typed_arrays/ArrayBufferContents.h" |
69 | 69 |
70 namespace blink { | 70 namespace blink { |
71 | 71 |
72 static const char defaultFont[] = "10px sans-serif"; | 72 static const char defaultFont[] = "10px sans-serif"; |
73 static const char inherit[] = "inherit"; | 73 static const char inheritDirectionString[] = "inherit"; |
74 static const char rtl[] = "rtl"; | 74 static const char rtlDirectionString[] = "rtl"; |
75 static const char ltr[] = "ltr"; | 75 static const char ltrDirectionString[] = "ltr"; |
76 static const double TryRestoreContextInterval = 0.5; | 76 static const double TryRestoreContextInterval = 0.5; |
77 static const unsigned MaxTryRestoreContextAttempts = 4; | 77 static const unsigned MaxTryRestoreContextAttempts = 4; |
78 static const double cDeviceScaleFactor = 1.0; // Canvas is device independent | 78 static const double cDeviceScaleFactor = 1.0; // Canvas is device independent |
79 | 79 |
80 static bool contextLostRestoredEventsEnabled() { | 80 static bool contextLostRestoredEventsEnabled() { |
81 return RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled(); | 81 return RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled(); |
82 } | 82 } |
83 | 83 |
84 // Drawing methods need to use this instead of SkAutoCanvasRestore in case | 84 // Drawing methods need to use this instead of SkAutoCanvasRestore in case |
85 // overdraw detection substitutes the recording canvas (to discard overdrawn | 85 // overdraw detection substitutes the recording canvas (to discard overdrawn |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 return TextDirection::Ltr; | 684 return TextDirection::Ltr; |
685 } | 685 } |
686 ASSERT_NOT_REACHED(); | 686 ASSERT_NOT_REACHED(); |
687 return TextDirection::Ltr; | 687 return TextDirection::Ltr; |
688 } | 688 } |
689 | 689 |
690 String CanvasRenderingContext2D::direction() const { | 690 String CanvasRenderingContext2D::direction() const { |
691 if (state().getDirection() == CanvasRenderingContext2DState::DirectionInherit) | 691 if (state().getDirection() == CanvasRenderingContext2DState::DirectionInherit) |
692 canvas()->document().updateStyleAndLayoutTreeForNode(canvas()); | 692 canvas()->document().updateStyleAndLayoutTreeForNode(canvas()); |
693 return toTextDirection(state().getDirection(), canvas()) == TextDirection::Rtl | 693 return toTextDirection(state().getDirection(), canvas()) == TextDirection::Rtl |
694 ? rtl | 694 ? rtlDirectionString |
695 : ltr; | 695 : ltrDirectionString; |
696 } | 696 } |
697 | 697 |
698 void CanvasRenderingContext2D::setDirection(const String& directionString) { | 698 void CanvasRenderingContext2D::setDirection(const String& directionString) { |
699 CanvasRenderingContext2DState::Direction direction; | 699 CanvasRenderingContext2DState::Direction direction; |
700 if (directionString == inherit) | 700 if (directionString == inheritDirectionString) |
701 direction = CanvasRenderingContext2DState::DirectionInherit; | 701 direction = CanvasRenderingContext2DState::DirectionInherit; |
702 else if (directionString == rtl) | 702 else if (directionString == rtlDirectionString) |
703 direction = CanvasRenderingContext2DState::DirectionRTL; | 703 direction = CanvasRenderingContext2DState::DirectionRTL; |
704 else if (directionString == ltr) | 704 else if (directionString == ltrDirectionString) |
705 direction = CanvasRenderingContext2DState::DirectionLTR; | 705 direction = CanvasRenderingContext2DState::DirectionLTR; |
706 else | 706 else |
707 return; | 707 return; |
708 | 708 |
709 if (state().getDirection() == direction) | 709 if (state().getDirection() == direction) |
710 return; | 710 return; |
711 | 711 |
712 modifiableState().setDirection(direction); | 712 modifiableState().setDirection(direction); |
713 } | 713 } |
714 | 714 |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 } | 1159 } |
1160 return true; | 1160 return true; |
1161 } | 1161 } |
1162 | 1162 |
1163 void CanvasRenderingContext2D::resetUsageTracking() { | 1163 void CanvasRenderingContext2D::resetUsageTracking() { |
1164 UsageCounters newCounters; | 1164 UsageCounters newCounters; |
1165 m_usageCounters = newCounters; | 1165 m_usageCounters = newCounters; |
1166 } | 1166 } |
1167 | 1167 |
1168 } // namespace blink | 1168 } // namespace blink |
OLD | NEW |