Changeset 190383 in webkit
- Timestamp:
- Sep 30, 2015 8:17:26 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r190379 r190383 1 2015-09-30 Katlyn Graff <kgraff@apple.com> 2 3 Tests support for imageSmoothingQuality attribute of Canvas element. 4 https://bugs.webkit.org/show_bug.cgi?id=149541 5 6 Reviewed by Ryosuke Niwa. 7 8 Tests low, medium, high, and default values, value persistence when 9 imageSmoothingEnabled is changed, and invalid input. 10 11 * fast/canvas/canvas-imageSmoothingQuality-expected.txt: Added. 12 * fast/canvas/canvas-imageSmoothingQuality.html: Added. 13 1 14 2015-09-30 Brady Eidson <beidson@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r190382 r190383 1 2015-09-30 Katlyn Graff <kgraff@apple.com> 2 3 Add support for the imageSmoothingQuality property for CanvasRenderingContext2D. 4 https://bugs.webkit.org/show_bug.cgi?id=149541 5 6 Reviewed by Ryosuke Niwa. 7 8 As documented here: https://html.spec.whatwg.org/multipage/scripting.html#image-smoothing 9 Exposes the smooothing quality of algorithms used for scaling images. Valid input 10 values are low, medium, and high: associated algorithms are expected to vary for 11 differing hardware. setImageSmoothingQuality provides a handle into CGInterpolationQuality. 12 13 Test: fast/canvas/canvas-imageSmoothingQuality.html 14 15 * html/canvas/CanvasRenderingContext2D.cpp: 16 (WebCore::CanvasRenderingContext2D::State::State): 17 (WebCore::CanvasRenderingContext2D::State::operator=): 18 (WebCore::smoothingToInterpolationQuality): 19 (WebCore::CanvasRenderingContext2D::imageSmoothingQuality): 20 (WebCore::CanvasRenderingContext2D::setImageSmoothingQuality): 21 (WebCore::CanvasRenderingContext2D::setImageSmoothingEnabled): 22 * html/canvas/CanvasRenderingContext2D.h: 23 * html/canvas/CanvasRenderingContext2D.idl: 24 1 25 2015-09-30 Dean Jackson <dino@apple.com> 2 26 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r190274 r190383 43 43 #include "ExceptionCodePlaceholder.h" 44 44 #include "FloatQuad.h" 45 #include "GraphicsContext.h"46 45 #include "HTMLImageElement.h" 47 46 #include "HTMLVideoElement.h" … … 174 173 , lineDashOffset(0) 175 174 , imageSmoothingEnabled(true) 175 , imageSmoothingQuality(SmoothingQuality::Low) 176 176 , textAlign(StartTextAlign) 177 177 , textBaseline(AlphabeticTextBaseline) … … 200 200 , lineDashOffset(other.lineDashOffset) 201 201 , imageSmoothingEnabled(other.imageSmoothingEnabled) 202 , imageSmoothingQuality(other.imageSmoothingQuality) 202 203 , textAlign(other.textAlign) 203 204 , textBaseline(other.textBaseline) … … 230 231 hasInvertibleTransform = other.hasInvertibleTransform; 231 232 imageSmoothingEnabled = other.imageSmoothingEnabled; 233 imageSmoothingQuality = other.imageSmoothingQuality; 232 234 textAlign = other.textAlign; 233 235 textBaseline = other.textBaseline; … … 2540 2542 #endif 2541 2543 2544 static InterpolationQuality smoothingToInterpolationQuality(CanvasRenderingContext2D::SmoothingQuality quality) 2545 { 2546 switch (quality) { 2547 case CanvasRenderingContext2D::SmoothingQuality::Low: 2548 return InterpolationLow; 2549 case CanvasRenderingContext2D::SmoothingQuality::Medium: 2550 return InterpolationMedium; 2551 case CanvasRenderingContext2D::SmoothingQuality::High: 2552 return InterpolationHigh; 2553 } 2554 2555 ASSERT_NOT_REACHED(); 2556 return InterpolationLow; 2557 }; 2558 2559 String CanvasRenderingContext2D::imageSmoothingQuality() const 2560 { 2561 switch (state().imageSmoothingQuality) { 2562 case SmoothingQuality::Low: 2563 return ASCIILiteral("low"); 2564 case SmoothingQuality::Medium: 2565 return ASCIILiteral("medium"); 2566 case SmoothingQuality::High: 2567 return ASCIILiteral("high"); 2568 } 2569 2570 ASSERT_NOT_REACHED(); 2571 return ASCIILiteral("low"); 2572 } 2573 2574 void CanvasRenderingContext2D::setImageSmoothingQuality(const String& smoothingQualityString) 2575 { 2576 SmoothingQuality quality; 2577 if (smoothingQualityString == "low") 2578 quality = SmoothingQuality::Low; 2579 else if (smoothingQualityString == "medium") 2580 quality = SmoothingQuality::Medium; 2581 else if (smoothingQualityString == "high") 2582 quality = SmoothingQuality::High; 2583 else { 2584 ASSERT_NOT_REACHED(); 2585 return; 2586 } 2587 2588 if (quality == state().imageSmoothingQuality) 2589 return; 2590 2591 realizeSaves(); 2592 modifiableState().imageSmoothingQuality = quality; 2593 2594 if (!modifiableState().imageSmoothingEnabled) 2595 return; 2596 2597 if (auto* context = drawingContext()) 2598 context->setImageInterpolationQuality(smoothingToInterpolationQuality(quality)); 2599 } 2600 2542 2601 bool CanvasRenderingContext2D::imageSmoothingEnabled() const 2543 2602 { … … 2554 2613 GraphicsContext* c = drawingContext(); 2555 2614 if (c) 2556 c->setImageInterpolationQuality(enabled ? DefaultInterpolationQuality: InterpolationNone);2615 c->setImageInterpolationQuality(enabled ? smoothingToInterpolationQuality(state().imageSmoothingQuality) : InterpolationNone); 2557 2616 } 2558 2617 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h
r189830 r190383 35 35 #include "FloatSize.h" 36 36 #include "FontCascade.h" 37 #include "GraphicsContext.h" 37 38 #include "GraphicsTypes.h" 38 39 #include "ImageBuffer.h" … … 228 229 bool imageSmoothingEnabled() const; 229 230 void setImageSmoothingEnabled(bool); 231 232 String imageSmoothingQuality() const; 233 void setImageSmoothingQuality(const String&); 234 235 enum class SmoothingQuality { 236 Low, 237 Medium, 238 High 239 }; 230 240 231 241 private: … … 282 292 float lineDashOffset; 283 293 bool imageSmoothingEnabled; 294 SmoothingQuality imageSmoothingQuality; 284 295 285 296 // Text state. -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl
r190021 r190383 24 24 */ 25 25 26 enum ImageSmoothingQuality { "low", "medium", "high" }; 26 27 enum CanvasWindingRule { "nonzero", "evenodd" }; 27 28 … … 189 190 attribute boolean imageSmoothingEnabled; 190 191 [ImplementedAs=imageSmoothingEnabled] attribute boolean webkitImageSmoothingEnabled; 192 attribute ImageSmoothingQuality imageSmoothingQuality; 191 193 }; 192 194
Note: See TracChangeset
for help on using the changeset viewer.