Changeset 28969 in webkit
- Timestamp:
- Dec 23, 2007 4:47:05 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r28966 r28969 1 2007-12-23 Alp Toker <alp@atoker.com> 2 3 Reviewed by Holger Freyther. 4 5 http://bugs.webkit.org/show_bug.cgi?id=16577 6 Merge Cairo enhancements from Apollo project 7 8 This patch is based on initial merging work by Brent Fulgham. Adobe's 9 code has been modified in a few places to better suit the existing 10 coding style. 11 12 Implement more clipping and drawing functions. 13 14 Save and restore the fill rule manually when clipping. 15 16 Avoid image surface creation when the image buffer has height zero. 17 18 * platform/graphics/cairo/GraphicsContextCairo.cpp: 19 (WebCore::GraphicsContext::clip): 20 (WebCore::GraphicsContext::addInnerRoundedRectClip): 21 (WebCore::GraphicsContext::addPath): 22 (WebCore::GraphicsContext::clipOut): 23 (WebCore::GraphicsContext::clipOutEllipseInRect): 24 (WebCore::GraphicsContext::fillRoundedRect): 25 * platform/graphics/cairo/ImageSourceCairo.cpp: 26 (WebCore::ImageSource::createFrameAtIndex): 27 1 28 2007-12-23 Nikolas Zimmermann <zimmermann@kde.org> 2 29 -
trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r28861 r28969 410 410 cairo_t* cr = m_data->cr; 411 411 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); 412 cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); 413 cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING); 412 414 cairo_clip(cr); 415 cairo_set_fill_rule(cr, savedFillRule); 413 416 } 414 417 … … 604 607 605 608 clip(rect); 606 Path path; 607 608 path.addEllipse(rect); 609 610 IntRect inner(rect); 611 inner.inflate(-thickness); 612 path.addEllipse(inner); 613 614 cairo_t* cr = m_data->cr; 609 610 Path p; 611 FloatRect r(rect); 612 // Add outer ellipse 613 p.addEllipse(r); 614 // Add inner ellipse 615 r.inflate(-thickness); 616 p.addEllipse(r); 617 addPath(p); 618 619 cairo_t* cr = m_data->cr; 620 cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); 615 621 cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); 616 617 clip(path); 618 } 622 cairo_clip(cr); 623 cairo_set_fill_rule(cr, savedFillRule); 624 } 625 619 626 620 627 void GraphicsContext::setShadow(IntSize const&, int, Color const&) … … 791 798 792 799 cairo_t* cr = m_data->cr; 793 cairo_path_t *p = cairo_copy_path(path.platformPath()->m_cr);800 cairo_path_t* p = cairo_copy_path(path.platformPath()->m_cr); 794 801 cairo_append_path(cr, p); 795 802 cairo_path_destroy(p); … … 802 809 803 810 cairo_t* cr = m_data->cr; 804 cairo_path_t *p = cairo_copy_path(path.platformPath()->m_cr);811 cairo_path_t* p = cairo_copy_path(path.platformPath()->m_cr); 805 812 cairo_append_path(cr, p); 806 813 cairo_path_destroy(p); 814 cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); 815 cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING); 807 816 cairo_clip(cr); 808 } 809 810 void GraphicsContext::clipOut(const Path&) 811 { 812 notImplemented(); 817 cairo_set_fill_rule(cr, savedFillRule); 818 } 819 820 void GraphicsContext::clipOut(const Path& path) 821 { 822 if (paintingDisabled()) 823 return; 824 825 cairo_t* cr = m_data->cr; 826 double x1, y1, x2, y2; 827 cairo_clip_extents(cr, &x1, &y1, &x2, &y2); 828 cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1); 829 addPath(path); 830 831 cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); 832 cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); 833 cairo_clip(cr); 834 cairo_set_fill_rule(cr, savedFillRule); 813 835 } 814 836 … … 829 851 } 830 852 831 void GraphicsContext::clipOut(const IntRect&) 832 { 833 notImplemented(); 834 } 835 836 void GraphicsContext::clipOutEllipseInRect(const IntRect&) 837 { 838 notImplemented(); 839 } 840 841 void GraphicsContext::fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&) 842 { 843 notImplemented(); 853 void GraphicsContext::clipOut(const IntRect& r) 854 { 855 if (paintingDisabled()) 856 return; 857 858 cairo_t* cr = m_data->cr; 859 double x1, y1, x2, y2; 860 cairo_clip_extents(cr, &x1, &y1, &x2, &y2); 861 cairo_rectangle(cr, x1, x2, x2 - x1, y2 - y1); 862 cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height()); 863 cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); 864 cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); 865 cairo_clip(cr); 866 cairo_set_fill_rule(cr, savedFillRule); 867 } 868 869 void GraphicsContext::clipOutEllipseInRect(const IntRect& r) 870 { 871 if (paintingDisabled()) 872 return; 873 874 Path p; 875 p.addEllipse(r); 876 clipOut(p); 877 } 878 879 void GraphicsContext::fillRoundedRect(const IntRect& r, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color) 880 { 881 if (paintingDisabled()) 882 return; 883 884 cairo_t* cr = m_data->cr; 885 cairo_save(cr); 886 beginPath(); 887 addPath(Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight)); 888 setColor(cr, color); 889 cairo_fill(cr); 890 cairo_restore(cr); 844 891 } 845 892 -
trunk/WebCore/platform/graphics/cairo/ImageSourceCairo.cpp
r28345 r28969 160 160 return 0; 161 161 162 // Cairo does not like zero height images. 163 // If we have a zero height image, just pretend we don't have enough data yet. 164 if (!buffer->height()) 165 return 0; 166 162 167 return cairo_image_surface_create_for_data((unsigned char*)buffer->bytes().data(), 163 168 CAIRO_FORMAT_ARGB32,
Note: See TracChangeset
for help on using the changeset viewer.