diff options
Diffstat (limited to 'WebCore/platform/graphics/wx')
-rw-r--r-- | WebCore/platform/graphics/wx/AffineTransformWx.cpp | 157 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/ColorWx.cpp | 44 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/FloatRectWx.cpp | 47 | ||||
-rwxr-xr-x | WebCore/platform/graphics/wx/FontCacheWx.cpp | 73 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/FontPlatformData.h | 104 | ||||
-rwxr-xr-x | WebCore/platform/graphics/wx/FontPlatformDataWx.cpp | 107 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/FontWx.cpp | 78 | ||||
-rwxr-xr-x | WebCore/platform/graphics/wx/GlyphMapWx.cpp | 59 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/GraphicsContextWx.cpp | 491 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/ImageBufferWx.cpp | 60 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/ImageSourceWx.cpp | 233 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/ImageWx.cpp | 186 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/IntPointWx.cpp | 45 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/IntRectWx.cpp | 45 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/PathWx.cpp | 180 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/PenWx.cpp | 77 | ||||
-rwxr-xr-x | WebCore/platform/graphics/wx/SimpleFontDataWx.cpp | 96 |
17 files changed, 2082 insertions, 0 deletions
diff --git a/WebCore/platform/graphics/wx/AffineTransformWx.cpp b/WebCore/platform/graphics/wx/AffineTransformWx.cpp new file mode 100644 index 0000000..b9c504d --- /dev/null +++ b/WebCore/platform/graphics/wx/AffineTransformWx.cpp @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2007 Kevin Ollivier All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "AffineTransform.h" + +#include "FloatRect.h" +#include "IntRect.h" +#include "NotImplemented.h" + +#include <stdio.h> +#include <wx/defs.h> +#include <wx/graphics.h> + +namespace WebCore { + +#if USE(WXGC) +AffineTransform::AffineTransform(const wxGraphicsMatrix &matrix) +{ + m_transform = matrix; +} +#endif + +AffineTransform::AffineTransform(double a, double b, double c, double d, double e, double f) +{ +#if USE(WXGC) + wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer(); + m_transform = renderer->CreateMatrix(); + m_transform.Set(a, b, c, d, e, f); +#endif +} + +AffineTransform::AffineTransform() +{ + // NB: If we ever support using Cairo backend on Win/Mac, this will need to be + // changed somehow (though I'm not sure how as we don't have a reference to the + // graphics context here. +#if USE(WXGC) + wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer(); + m_transform = renderer->CreateMatrix(); +#endif +} + +AffineTransform AffineTransform::inverse() const +{ + notImplemented(); + return *this; +} + +void AffineTransform::map(double x, double y, double *x2, double *y2) const +{ + notImplemented(); +} + +IntRect AffineTransform::mapRect(const IntRect &rect) const +{ + notImplemented(); + return IntRect(); +} + +FloatRect AffineTransform::mapRect(const FloatRect &rect) const +{ + notImplemented(); + return FloatRect(); +} + + +AffineTransform& AffineTransform::scale(double sx, double sy) +{ +#if USE(WXGC) + m_transform.Scale((wxDouble)sx, (wxDouble)sy); +#endif + return *this; +} + +void AffineTransform::reset() +{ + notImplemented(); +} + +AffineTransform& AffineTransform::rotate(double d) +{ +#if USE(WXGC) + m_transform.Rotate((wxDouble)d); +#endif + return *this; +} + +AffineTransform& AffineTransform::translate(double tx, double ty) +{ +#if USE(WXGC) + m_transform.Translate((wxDouble)tx, (wxDouble)ty); +#endif + return *this; +} + +AffineTransform& AffineTransform::shear(double sx, double sy) +{ + notImplemented(); + return *this; +} + +AffineTransform& AffineTransform::operator*=(const AffineTransform& other) +{ + notImplemented(); + return *this; +} + +bool AffineTransform::operator== (const AffineTransform &other) const +{ +#if USE(WXGC) + return m_transform.IsEqual((wxGraphicsMatrix)other); +#endif +} + +AffineTransform AffineTransform::operator* (const AffineTransform &other) +{ + notImplemented(); + return *this; //m_transform * other.m_transform; +} + +double AffineTransform::det() const +{ + notImplemented(); + return 0; +} + +#if USE(WXGC) +AffineTransform::operator wxGraphicsMatrix() const +{ + return m_transform; +} +#endif + +} diff --git a/WebCore/platform/graphics/wx/ColorWx.cpp b/WebCore/platform/graphics/wx/ColorWx.cpp new file mode 100644 index 0000000..0381c59 --- /dev/null +++ b/WebCore/platform/graphics/wx/ColorWx.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2006, 2007 Kevin Ollivier. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Color.h" + +#include <wx/defs.h> +#include <wx/colour.h> + +namespace WebCore { + +Color::Color(const wxColour& color) +{ + m_color = makeRGBA((int)color.Red(), (int)color.Green(), (int)color.Blue(), (int)color.Alpha()); +} + +Color::operator wxColour() const +{ + return wxColour(red(), green(), blue(), alpha()); +} + +} diff --git a/WebCore/platform/graphics/wx/FloatRectWx.cpp b/WebCore/platform/graphics/wx/FloatRectWx.cpp new file mode 100644 index 0000000..bb460e5 --- /dev/null +++ b/WebCore/platform/graphics/wx/FloatRectWx.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2007 Kevin Ollivier. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "FloatRect.h" + +#include <wx/defs.h> +#include <wx/graphics.h> + +namespace WebCore { + +#if USE(WXGC) +FloatRect::FloatRect(const wxRect2DDouble& r) + : m_location(FloatPoint(r.m_x, r.m_y)) + , m_size(FloatSize(r.m_width, r.m_height)) +{ +} + +FloatRect::operator wxRect2DDouble() const +{ + return wxRect2DDouble(x(), y(), width(), height()); +} +#endif + +} diff --git a/WebCore/platform/graphics/wx/FontCacheWx.cpp b/WebCore/platform/graphics/wx/FontCacheWx.cpp new file mode 100755 index 0000000..eb41c89 --- /dev/null +++ b/WebCore/platform/graphics/wx/FontCacheWx.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "FontCache.h" +#include "Font.h" +#include "FontPlatformData.h" +#include "NotImplemented.h" +#include "SimpleFontData.h" + +namespace WebCore { + +void FontCache::platformInit() +{ +} + +const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) +{ + SimpleFontData* fontData = 0; + fontData = new SimpleFontData(FontPlatformData(font.fontDescription(), font.family().family())); + return fontData; +} + +FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font) +{ + return new FontPlatformData(font.fontDescription(), font.family().family()); +} + +FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription) +{ + // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick + // the default that the user would get without changing any prefs. + static AtomicString timesStr("systemfont"); + return getCachedFontPlatformData(fontDescription, timesStr); +} + +FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family) +{ + return new FontPlatformData(fontDescription,family); +} + +bool FontCache::fontExists(const FontDescription& fontDescription, const AtomicString& family) +{ + notImplemented(); + return true; +} + +} diff --git a/WebCore/platform/graphics/wx/FontPlatformData.h b/WebCore/platform/graphics/wx/FontPlatformData.h new file mode 100644 index 0000000..0f4c29b --- /dev/null +++ b/WebCore/platform/graphics/wx/FontPlatformData.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2006 Kevin Ollivier All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FontPlatformData_H +#define FontPlatformData_H + +#include "FontDescription.h" +#include "CString.h" +#include "AtomicString.h" +#include "StringImpl.h" + +#include <wx/defs.h> +#include <wx/font.h> + +namespace WebCore { + +class FontPlatformData { +public: + class Deleted {}; + + enum FontState { UNINITIALIZED, DELETED, VALID }; + + FontPlatformData(Deleted) + : m_fontState(DELETED) + { } + + ~FontPlatformData(); + + FontPlatformData(wxFont f) + : m_font(f) + , m_fontState(VALID) + { + m_fontHash = computeHash(); + } + + FontPlatformData(const FontDescription&, const AtomicString&); + + FontPlatformData() + : m_fontState(UNINITIALIZED) + { + } + + wxFont font() const { + return m_font; + } + + unsigned hash() const { + switch (m_fontState) { + case DELETED: + return -1; + case UNINITIALIZED: + return 0; + case VALID: + return computeHash(); + } + } + + bool operator==(const FontPlatformData& other) const + { + if (m_fontState == VALID) + return other.m_fontState == VALID && m_font.Ok() && other.m_font.Ok() && m_font.IsSameAs(other.m_font); + else + return m_fontState == other.m_fontState; + } + + unsigned computeHash() const { + ASSERT(m_font.Ok()); + return reinterpret_cast<unsigned>(&m_font); + } + +private: + wxFont m_font; + FontState m_fontState; + unsigned m_fontHash; +}; + +} + +#endif diff --git a/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp b/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp new file mode 100755 index 0000000..8e7c621 --- /dev/null +++ b/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "FontPlatformData.h" + +#include "FontDescription.h" + +#include <wx/defs.h> +#include <wx/gdicmn.h> +#include <wx/font.h> + +namespace WebCore { + +static wxFontFamily fontFamilyToWxFontFamily(const int family) +{ + switch (family) { + case FontDescription::StandardFamily: + return wxFONTFAMILY_DEFAULT; + case FontDescription::SerifFamily: + return wxFONTFAMILY_ROMAN; + case FontDescription::SansSerifFamily: + return wxFONTFAMILY_MODERN; + case FontDescription::MonospaceFamily: + return wxFONTFAMILY_TELETYPE; // TODO: Check these are equivalent + case FontDescription::CursiveFamily: + return wxFONTFAMILY_SCRIPT; + case FontDescription::FantasyFamily: + return wxFONTFAMILY_DECORATIVE; + default: + return wxFONTFAMILY_DEFAULT; + } +} + +static wxFontWeight fontWeightToWxFontWeight(bool isBold) +{ + if (isBold) + return wxFONTWEIGHT_BOLD; + + return wxFONTWEIGHT_NORMAL; +} + +static int italicToWxFontStyle(bool isItalic) +{ + if (isItalic) + return wxFONTSTYLE_ITALIC; + + return wxFONTSTYLE_NORMAL; +} + +FontPlatformData::FontPlatformData(const FontDescription& desc, const AtomicString& family) +{ +// NB: The Windows wxFont constructor has two forms, one taking a wxSize (with pixels) +// and one taking an int (points). When points are used, Windows calculates +// a pixel size using an algorithm which causes the size to be way off. However, +// this is a moot issue on Linux and Mac as they only accept the point argument. So, +// we use the pixel size constructor on Windows, but we use point size on Linux and Mac. +#if __WXMSW__ + m_font = wxFont( wxSize(0, -desc.computedPixelSize()), + fontFamilyToWxFontFamily(desc.genericFamily()), + italicToWxFontStyle(desc.italic()), + fontWeightToWxFontWeight(desc.bold()), + false, + family.string() + ); +#else + m_font = wxFont( desc.computedPixelSize(), + fontFamilyToWxFontFamily(desc.genericFamily()), + italicToWxFontStyle(desc.italic()), + fontWeightToWxFontWeight(desc.bold()), + false, + family.string() + ); +#endif + m_fontState = VALID; + m_fontHash = computeHash(); + +} + +FontPlatformData::~FontPlatformData() +{ + m_fontState = UNINITIALIZED; +} + +} diff --git a/WebCore/platform/graphics/wx/FontWx.cpp b/WebCore/platform/graphics/wx/FontWx.cpp new file mode 100644 index 0000000..07223e9 --- /dev/null +++ b/WebCore/platform/graphics/wx/FontWx.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2007 Kevin Ollivier. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Font.h" + +#include "FontFallbackList.h" +#include "GlyphBuffer.h" +#include "GraphicsContext.h" +#include "IntRect.h" +#include "NotImplemented.h" +#include "SimpleFontData.h" + +#include <wx/dcclient.h> +#include "fontprops.h" +#include "non-kerned-drawing.h" + +namespace WebCore { + +void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, + int from, int numGlyphs, const FloatPoint& point) const +{ + // prepare DC + Color color = graphicsContext->fillColor(); + + // We can't use wx drawing methods on Win/Linux because they automatically kern text + // so we've created a function with platform dependent drawing implementations that + // will hopefully be folded into wx once the API has solidified. + // see platform/wx/wxcode/<platform> for the implementations. + drawTextWithSpacing(graphicsContext, font, color, glyphBuffer, from, numGlyphs, point); +} + +FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int from, int to) const +{ + notImplemented(); + return FloatRect(); +} + +void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const FloatPoint& point, int from, int to) const +{ + notImplemented(); +} + +float Font::floatWidthForComplexText(const TextRun& run) const +{ + notImplemented(); + return 0; +} + +int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const +{ + notImplemented(); + return 0; +} + +} diff --git a/WebCore/platform/graphics/wx/GlyphMapWx.cpp b/WebCore/platform/graphics/wx/GlyphMapWx.cpp new file mode 100755 index 0000000..ebf86e4 --- /dev/null +++ b/WebCore/platform/graphics/wx/GlyphMapWx.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "GlyphPageTreeNode.h" + +#include "SimpleFontData.h" +#include <unicode/utf16.h> + +namespace WebCore +{ + +bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData) +{ + bool isUtf16 = bufferLength != length; + + for (unsigned i = 0; i < length; i++) { + UChar32 character; + + if(isUtf16) { + UChar lead = buffer[i * 2]; + UChar trail = buffer[i * 2 + 1]; + character = U16_GET_SUPPLEMENTARY(lead, trail); + } else { + character = buffer[i]; + } + + setGlyphDataForIndex(offset + i, character, fontData); + } + + return true; +} + +}
\ No newline at end of file diff --git a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp new file mode 100644 index 0000000..951d3a3 --- /dev/null +++ b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp @@ -0,0 +1,491 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "GraphicsContext.h" + +#include "AffineTransform.h" +#include "FloatRect.h" +#include "Font.h" +#include "IntRect.h" +#include "NotImplemented.h" +#include "Pen.h" +#include <wtf/MathExtras.h> + +#include <math.h> +#include <stdio.h> + +#include <wx/defs.h> +#include <wx/window.h> +#include <wx/dcclient.h> +#include <wx/dcgraph.h> +#include <wx/graphics.h> + +#if __WXMAC__ +#include <Carbon/Carbon.h> +#elif __WXMSW__ +#include <windows.h> +#endif + +namespace WebCore { + +int getWxCompositingOperation(CompositeOperator op, bool hasAlpha) +{ + // FIXME: Add support for more operators. + if (op == CompositeSourceOver && !hasAlpha) + op = CompositeCopy; + + int function; + switch (op) { + case CompositeClear: + function = wxCLEAR; + case CompositeCopy: + function = wxCOPY; + break; + default: + function = wxCOPY; + } + return function; +} + +static int strokeStyleToWxPenStyle(int p) +{ + if (p == SolidStroke) + return wxSOLID; + if (p == DottedStroke) + return wxDOT; + if (p == DashedStroke) + return wxLONG_DASH; + if (p == NoStroke) + return wxTRANSPARENT; + + return wxSOLID; +} + +class GraphicsContextPlatformPrivate { +public: + GraphicsContextPlatformPrivate(); + ~GraphicsContextPlatformPrivate(); + +#if USE(WXGC) + wxGCDC* context; +#else + wxWindowDC* context; +#endif + int mswDCStateID; + wxRegion gtkCurrentClipRgn; + wxRegion gtkPaintClipRgn; +}; + +GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate() : + context(0), + mswDCStateID(0), + gtkCurrentClipRgn(wxRegion()), + gtkPaintClipRgn(wxRegion()) +{ +} + +GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate() +{ +} + + +GraphicsContext::GraphicsContext(PlatformGraphicsContext* context) + : m_common(createGraphicsContextPrivate()) + , m_data(new GraphicsContextPlatformPrivate) +{ + setPaintingDisabled(!context); + if (context) { + // Make sure the context starts in sync with our state. + setPlatformFillColor(fillColor()); + setPlatformStrokeColor(strokeColor()); + } +#if USE(WXGC) + m_data->context = (wxGCDC*)context; +#else + m_data->context = (wxWindowDC*)context; +#endif +} + +GraphicsContext::~GraphicsContext() +{ + destroyGraphicsContextPrivate(m_common); + delete m_data; +} + +PlatformGraphicsContext* GraphicsContext::platformContext() const +{ + return (PlatformGraphicsContext*)m_data->context; +} + +void GraphicsContext::savePlatformState() +{ + if (m_data->context) + { +#if USE(WXGC) + wxGraphicsContext* gc = m_data->context->GetGraphicsContext(); + gc->PushState(); +#else + // when everything is working with USE_WXGC, we can remove this + #if __WXMAC__ + CGContextRef context; + wxGraphicsContext* gc = m_data->context->GetGraphicsContext(); + if (gc) + context = (CGContextRef)gc->GetNativeContext(); + if (context) + CGContextSaveGState(context); + #elif __WXMSW__ + HDC dc = (HDC)m_data->context->GetHDC(); + m_data->mswDCStateID = ::SaveDC(dc); + #elif __WXGTK__ + m_data->gtkCurrentClipRgn = m_data->context->m_currentClippingRegion; + m_data->gtkPaintClipRgn = m_data->context->m_paintClippingRegion; + #endif +#endif // __WXMAC__ + } +} + +void GraphicsContext::restorePlatformState() +{ + if (m_data->context) + { +#if USE(WXGC) + wxGraphicsContext* gc = m_data->context->GetGraphicsContext(); + gc->PopState(); +#else + #if __WXMAC__ + CGContextRef context; + wxGraphicsContext* gc = m_data->context->GetGraphicsContext(); + if (gc) + context = (CGContextRef)gc->GetNativeContext(); + if (context) + CGContextRestoreGState(context); + #elif __WXMSW__ + HDC dc = (HDC)m_data->context->GetHDC(); + ::RestoreDC(dc, m_data->mswDCStateID); + #elif __WXGTK__ + m_data->context->m_currentClippingRegion = m_data->gtkCurrentClipRgn; + m_data->context->m_paintClippingRegion = m_data->gtkPaintClipRgn; + #endif + +#endif // USE_WXGC + } +} + +// Draws a filled rectangle with a stroked border. +void GraphicsContext::drawRect(const IntRect& rect) +{ + if (paintingDisabled()) + return; + + m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle()))); + m_data->context->DrawRectangle(rect.x(), rect.y(), rect.width(), rect.height()); +} + +// This is only used to draw borders. +void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) +{ + if (paintingDisabled()) + return; + + FloatPoint p1 = point1; + FloatPoint p2 = point2; + + m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle()))); + m_data->context->DrawLine(point1.x(), point1.y(), point2.x(), point2.y()); +} + +// This method is only used to draw the little circles used in lists. +void GraphicsContext::drawEllipse(const IntRect& rect) +{ + if (paintingDisabled()) + return; + + m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle()))); + m_data->context->DrawEllipse(rect.x(), rect.y(), rect.width(), rect.height()); +} + +void GraphicsContext::drawImage(WebCore::ImageBuffer*, WebCore::FloatRect const&, WebCore::FloatRect const&) +{ + notImplemented(); +} + +void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan) +{ + if (paintingDisabled()) + return; + + m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle()))); + m_data->context->DrawEllipticArc(rect.x(), rect.y(), rect.width(), rect.height(), startAngle, angleSpan); +} + +void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias) +{ + if (paintingDisabled()) + return; + + if (npoints <= 1) + return; + + wxPoint* polygon = new wxPoint[npoints]; + for (size_t i = 0; i < npoints; i++) + polygon[i] = wxPoint(points[i].x(), points[i].y()); + m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle()))); + m_data->context->DrawPolygon((int)npoints, polygon); + delete [] polygon; +} + +void GraphicsContext::fillRect(const IntRect& rect, const Color& color) +{ + if (paintingDisabled()) + return; + + m_data->context->SetPen(*wxTRANSPARENT_PEN); + m_data->context->SetBrush(wxBrush(color)); + m_data->context->DrawRectangle(rect.x(), rect.y(), rect.width(), rect.height()); +} + +void GraphicsContext::fillRect(const FloatRect& rect, const Color& color) +{ + if (paintingDisabled()) + return; + + m_data->context->SetPen(wxPen(color)); + m_data->context->SetBrush(wxBrush(color)); + m_data->context->DrawRectangle(rect.x(), rect.y(), rect.width(), rect.height()); +} + +void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color) +{ + if (paintingDisabled()) + return; + + notImplemented(); +} + +void GraphicsContext::drawFocusRing(const Color& color) +{ + if (paintingDisabled()) + return; + + notImplemented(); +} + +void GraphicsContext::clip(const IntRect& r) +{ + wxWindowDC* windc = dynamic_cast<wxWindowDC*>(m_data->context); + wxPoint pos(0, 0); + + if (windc) { +#ifndef __WXGTK__ + wxWindow* window = windc->GetWindow(); +#else + wxWindow* window = windc->m_owner; +#endif + if (window) { + wxWindow* parent = window->GetParent(); + // we need to convert from WebView "global" to WebFrame "local" coords. + // FIXME: We only want to go to the top WebView. + while (parent) { + pos += window->GetPosition(); + parent = parent->GetParent(); + } + } + } + + m_data->context->SetClippingRegion(r.x() - pos.x, r.y() - pos.y, r.width() + pos.x, r.height() + pos.y); +} + +void GraphicsContext::clipOut(const Path&) +{ + notImplemented(); +} + +void GraphicsContext::clipOut(const IntRect&) +{ + notImplemented(); +} + +void GraphicsContext::clipOutEllipseInRect(const IntRect&) +{ + notImplemented(); +} + +void GraphicsContext::drawLineForText(const IntPoint& origin, int width, bool printing) +{ + if (paintingDisabled()) + return; + + IntPoint endPoint = origin + IntSize(width, 0); + m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle()))); + m_data->context->DrawLine(origin.x(), origin.y(), endPoint.x(), endPoint.y()); +} + + +void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint& origin, int width, bool grammar) +{ + if (grammar) + m_data->context->SetPen(wxPen(*wxGREEN, 2, wxLONG_DASH)); + else + m_data->context->SetPen(wxPen(*wxRED, 2, wxLONG_DASH)); + + m_data->context->DrawLine(origin.x(), origin.y(), origin.x() + width, origin.y()); +} + +void GraphicsContext::clip(const Path&) +{ + notImplemented(); +} + +AffineTransform GraphicsContext::getCTM() const +{ + notImplemented(); + return AffineTransform(); +} + +void GraphicsContext::translate(float tx, float ty) +{ +#if USE(WXGC) + if (m_data->context) { + wxGraphicsContext* gc = m_data->context->GetGraphicsContext(); + gc->Translate(tx, ty); + } +#endif +} + +void GraphicsContext::rotate(float angle) +{ +#if USE(WXGC) + if (m_data->context) { + wxGraphicsContext* gc = m_data->context->GetGraphicsContext(); + gc->Rotate(angle); + } +#endif +} + +void GraphicsContext::scale(const FloatSize& scale) +{ +#if USE(WXGC) + if (m_data->context) { + wxGraphicsContext* gc = m_data->context->GetGraphicsContext(); + gc->Scale(scale.width(), scale.height()); + } +#endif +} + + +FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect) +{ + FloatRect result; + + wxCoord x = (wxCoord)frect.x(); + wxCoord y = (wxCoord)frect.y(); + + x = m_data->context->LogicalToDeviceX(x); + y = m_data->context->LogicalToDeviceY(y); + result.setX((float)x); + result.setY((float)y); + x = (wxCoord)frect.width(); + y = (wxCoord)frect.height(); + x = m_data->context->LogicalToDeviceXRel(x); + y = m_data->context->LogicalToDeviceYRel(y); + result.setWidth((float)x); + result.setHeight((float)y); + return result; +} + +void GraphicsContext::setURLForRect(const KURL&, const IntRect&) +{ + notImplemented(); +} + +void GraphicsContext::setCompositeOperation(CompositeOperator op) +{ + if (m_data->context) + m_data->context->SetLogicalFunction(getWxCompositingOperation(op, false)); +} + +void GraphicsContext::beginPath() +{ + notImplemented(); +} + +void GraphicsContext::addPath(const Path& path) +{ + notImplemented(); +} + +void GraphicsContext::setPlatformStrokeColor(const Color& color) +{ + if (paintingDisabled()) + return; + + if (m_data->context) + m_data->context->SetPen(wxPen(color, strokeThickness(), strokeStyleToWxPenStyle(strokeStyle()))); +} + +void GraphicsContext::setPlatformStrokeThickness(float thickness) +{ + if (paintingDisabled()) + return; + + if (m_data->context) + m_data->context->SetPen(wxPen(strokeColor(), thickness, strokeStyleToWxPenStyle(strokeStyle()))); + +} + +void GraphicsContext::setPlatformFillColor(const Color& color) +{ + if (paintingDisabled()) + return; + + if (m_data->context) + m_data->context->SetBrush(wxBrush(color)); +} + +void GraphicsContext::concatCTM(const AffineTransform& transform) +{ + if (paintingDisabled()) + return; + + notImplemented(); + return; +} + +void GraphicsContext::setUseAntialiasing(bool enable) +{ + if (paintingDisabled()) + return; + notImplemented(); +} + +void GraphicsContext::paintBuffer(ImageBuffer* buffer, const IntRect& r) +{ + if (paintingDisabled()) + return; + notImplemented(); +} + +} diff --git a/WebCore/platform/graphics/wx/ImageBufferWx.cpp b/WebCore/platform/graphics/wx/ImageBufferWx.cpp new file mode 100644 index 0000000..0c832ea --- /dev/null +++ b/WebCore/platform/graphics/wx/ImageBufferWx.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ImageBuffer.h" + +#include "GraphicsContext.h" +#include "ImageData.h" +#include "NotImplemented.h" + +namespace WebCore { + +std::auto_ptr<ImageBuffer> ImageBuffer::create(const IntSize&, bool grayScale) +{ + return std::auto_ptr<ImageBuffer>(new ImageBuffer()); +} + +ImageBuffer::~ImageBuffer() +{ +} + +GraphicsContext* ImageBuffer::context() const +{ + return 0; +} + +PassRefPtr<ImageData> ImageBuffer::getImageData(const IntRect&) const +{ + notImplemented(); + return 0; +} + +void ImageBuffer::putImageData(ImageData*, const IntRect&, const IntPoint&) +{ + notImplemented(); +} + +} diff --git a/WebCore/platform/graphics/wx/ImageSourceWx.cpp b/WebCore/platform/graphics/wx/ImageSourceWx.cpp new file mode 100644 index 0000000..fc36635 --- /dev/null +++ b/WebCore/platform/graphics/wx/ImageSourceWx.cpp @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2006, 2007 Apple Computer, Kevin Ollivier. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ImageSource.h" + +#include "BMPImageDecoder.h" +#include "GIFImageDecoder.h" +#include "ICOImageDecoder.h" +#include "JPEGImageDecoder.h" +#include "PNGImageDecoder.h" +#include "SharedBuffer.h" +#include "XBMImageDecoder.h" + +#include <wx/defs.h> +#include <wx/bitmap.h> +#include <wx/image.h> +#include <wx/rawbmp.h> + +namespace WebCore { + +ImageDecoder* createDecoder(const SharedBuffer& data) +{ + // We need at least 4 bytes to figure out what kind of image we're dealing with. + int length = data.size(); + if (length < 4) + return 0; + + const unsigned char* uContents = (const unsigned char*)data.data(); + const char* contents = data.data(); + + // GIFs begin with GIF8(7 or 9). + if (strncmp(contents, "GIF8", 4) == 0) + return new GIFImageDecoder(); + + // Test for PNG. + if (uContents[0]==0x89 && + uContents[1]==0x50 && + uContents[2]==0x4E && + uContents[3]==0x47) + return new PNGImageDecoder(); + + // JPEG + if (uContents[0]==0xFF && + uContents[1]==0xD8 && + uContents[2]==0xFF) + return new JPEGImageDecoder(); + + // BMP + if (strncmp(contents, "BM", 2) == 0) + return new BMPImageDecoder(); + + // ICOs always begin with a 2-byte 0 followed by a 2-byte 1. + // CURs begin with 2-byte 0 followed by 2-byte 2. + if (!memcmp(contents, "\000\000\001\000", 4) || + !memcmp(contents, "\000\000\002\000", 4)) + return new ICOImageDecoder(); + + // XBMs require 8 bytes of info. + if (length >= 8 && strncmp(contents, "#define ", 8) == 0) + return new XBMImageDecoder(); + + // Give up. We don't know what the heck this is. + return 0; +} + +ImageSource::ImageSource() + : m_decoder(0) +{} + +ImageSource::~ImageSource() +{ + delete m_decoder; +} + +bool ImageSource::initialized() const +{ + return m_decoder; +} + +void ImageSource::setData(SharedBuffer* data, bool allDataReceived) +{ + // Make the decoder by sniffing the bytes. + // This method will examine the data and instantiate an instance of the appropriate decoder plugin. + // If insufficient bytes are available to determine the image type, no decoder plugin will be + // made. + m_decoder = createDecoder(*data); + if (!m_decoder) + return; + m_decoder->setData(data, allDataReceived); +} + +bool ImageSource::isSizeAvailable() +{ + if (!m_decoder) + return false; + + return m_decoder->isSizeAvailable(); +} + +IntSize ImageSource::size() const +{ + if (!m_decoder) + return IntSize(); + + return m_decoder->size(); +} + +int ImageSource::repetitionCount() +{ + if (!m_decoder) + return cAnimationNone; + + return m_decoder->repetitionCount(); +} + +size_t ImageSource::frameCount() const +{ + return m_decoder ? m_decoder->frameCount() : 0; +} + +bool ImageSource::frameIsCompleteAtIndex(size_t index) +{ + // FIXME: should we be testing the RGBA32Buffer's status as well? + return (m_decoder && m_decoder->frameBufferAtIndex(index) != 0); +} + +void ImageSource::clear() +{ + delete m_decoder; + m_decoder = 0; +} + +NativeImagePtr ImageSource::createFrameAtIndex(size_t index) +{ + if (!m_decoder) + return 0; + + RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index); + if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty) + return 0; + + IntRect imageRect = buffer->rect(); + unsigned char* bytes = (unsigned char*)buffer->bytes().data(); + long colorSize = buffer->bytes().size(); + + typedef wxPixelData<wxBitmap, wxAlphaPixelFormat> PixelData; + + int width = size().width(); + int height = size().height(); + + wxBitmap* bmp = new wxBitmap(width, height, 32); + PixelData data(*bmp); + + int rowCounter = 0; + long pixelCounter = 0; + + PixelData::Iterator p(data); + + PixelData::Iterator rowStart = p; + + // NB: It appears that the data is in BGRA format instead of RGBA format. + // This code works properly on both ppc and intel, meaning the issue is + // likely not an issue of byte order getting mixed up on different archs. + for (long i = 0; i < buffer->bytes().size()*4; i+=4) { + p.Red() = bytes[i+2]; + p.Green() = bytes[i+1]; + p.Blue() = bytes[i+0]; + p.Alpha() = bytes[i+3]; + + p++; + + pixelCounter++; + if ( (pixelCounter % width ) == 0 ) { + rowCounter++; + p = rowStart; + p.MoveTo(data, 0, rowCounter); + } + + } + + bmp->UseAlpha(); + ASSERT(bmp->IsOk()); + return bmp; +} + +float ImageSource::frameDurationAtIndex(size_t index) +{ + if (!m_decoder) + return 0; + + RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index); + if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty) + return 0; + + return buffer->duration() / 1000.0f; +} + +bool ImageSource::frameHasAlphaAtIndex(size_t index) +{ + if (!m_decoder || !m_decoder->supportsAlpha()) + return false; + + RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index); + if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty) + return false; + + return buffer->hasAlpha(); +} + +} diff --git a/WebCore/platform/graphics/wx/ImageWx.cpp b/WebCore/platform/graphics/wx/ImageWx.cpp new file mode 100644 index 0000000..785466c --- /dev/null +++ b/WebCore/platform/graphics/wx/ImageWx.cpp @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2007 Apple Computer, Kevin Ollivier. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Image.h" + +#include "AffineTransform.h" +#include "BitmapImage.h" +#include "FloatRect.h" +#include "GraphicsContext.h" +#include "NotImplemented.h" + +#include <math.h> +#include <stdio.h> + +#include <wx/defs.h> +#include <wx/bitmap.h> +#include <wx/dc.h> +#include <wx/dcmemory.h> +#include <wx/dcgraph.h> +#include <wx/graphics.h> +#include <wx/image.h> +#include <wx/thread.h> + +// This function loads resources from WebKit +Vector<char> loadResourceIntoArray(const char*); + +namespace WebCore { + +// this is in GraphicsContextWx.cpp +int getWxCompositingOperation(CompositeOperator op, bool hasAlpha); + +void FrameData::clear() +{ + if (m_frame) { + delete m_frame; + m_frame = 0; + m_duration = 0.; + m_hasAlpha = true; + } +} + +// ================================================ +// Image Class +// ================================================ + +Image* Image::loadPlatformResource(const char *name) +{ + Vector<char> arr = loadResourceIntoArray(name); + Image* img = new BitmapImage(); + RefPtr<SharedBuffer> buffer = new SharedBuffer(arr.data(), arr.size()); + img->setData(buffer, true); + return img; +} + +void BitmapImage::initPlatformData() +{ + // FIXME: NYI +} + +// Drawing Routines + +void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatRect& src, CompositeOperator op) +{ + if (!m_source.initialized()) + return; + +#if USE(WXGC) + wxGCDC* context = (wxGCDC*)ctxt->platformContext(); +#else + wxWindowDC* context = ctxt->platformContext(); +#endif + + wxBitmap* bitmap = frameAtIndex(m_currentFrame); + if (!bitmap) // If it's too early we won't have an image yet. + return; + + IntSize selfSize = size(); + FloatRect srcRect(src); + FloatRect dstRect(dst); + + // If we're drawing a sub portion of the image or scaling then create + // a pattern transformation on the image and draw the transformed pattern. + // Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html + // FIXME: NYI + + wxMemoryDC mydc; + ASSERT(bitmap->GetRefData()); + mydc.SelectObject(*bitmap); + context->Blit((wxCoord)dst.x(),(wxCoord)dst.y(), (wxCoord)dst.width(), (wxCoord)dst.height(), &mydc, + (wxCoord)src.x(), (wxCoord)src.y(), wxCOPY, true); + mydc.SelectObject(wxNullBitmap); + + // NB: delete is causing crashes during page load, but not during the deletion + // itself. It occurs later on when a valid bitmap created in frameAtIndex + // suddenly becomes invalid after returning. It's possible these errors deal + // with reentrancy and threding problems. + //delete bitmap; + startAnimation(); +} + + +void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, CompositeOperator, const FloatRect& dstRect) +{ + if (!m_source.initialized()) + return; + +#if USE(WXGC) + wxGCDC* context = (wxGCDC*)ctxt->platformContext(); +#else + wxWindowDC* context = ctxt->platformContext(); +#endif + + ctxt->save(); + ctxt->clip(IntRect(dstRect.x(), dstRect.y(), dstRect.width(), dstRect.height())); + wxBitmap* bitmap = frameAtIndex(m_currentFrame); + if (!bitmap) // If it's too early we won't have an image yet. + return; + + float currentW = 0; + float currentH = 0; + +#if USE(WXGC) + wxGraphicsContext* gc = context->GetGraphicsContext(); + gc->ConcatTransform(patternTransform); +#endif + + wxMemoryDC mydc; + mydc.SelectObject(*bitmap); + + while ( currentW < dstRect.width() ) { + while ( currentH < dstRect.height() ) { + context->Blit((wxCoord)dstRect.x() + currentW, (wxCoord)dstRect.y() + currentH, + (wxCoord)srcRect.width(), (wxCoord)srcRect.height(), &mydc, + (wxCoord)srcRect.x(), (wxCoord)srcRect.y(), wxCOPY, true); + currentH += srcRect.height(); + } + currentW += srcRect.width(); + currentH = 0; + } + ctxt->restore(); + mydc.SelectObject(wxNullBitmap); + + // NB: delete is causing crashes during page load, but not during the deletion + // itself. It occurs later on when a valid bitmap created in frameAtIndex + // suddenly becomes invalid after returning. It's possible these errors deal + // with reentrancy and threding problems. + //delete bitmap; + + startAnimation(); + +} + +void BitmapImage::checkForSolidColor() +{ + +} + +void BitmapImage::invalidatePlatformData() +{ + +} + +} diff --git a/WebCore/platform/graphics/wx/IntPointWx.cpp b/WebCore/platform/graphics/wx/IntPointWx.cpp new file mode 100644 index 0000000..389ac9f --- /dev/null +++ b/WebCore/platform/graphics/wx/IntPointWx.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2006, 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "IntPoint.h" + +#include <wx/defs.h> +#include <wx/gdicmn.h> + +namespace WebCore { + +IntPoint::IntPoint(const wxPoint& p) + : m_x(p.x) + , m_y(p.y) +{ +} + +IntPoint::operator wxPoint() const +{ + return wxPoint(m_x, m_y); +} + +} diff --git a/WebCore/platform/graphics/wx/IntRectWx.cpp b/WebCore/platform/graphics/wx/IntRectWx.cpp new file mode 100644 index 0000000..10c1b55 --- /dev/null +++ b/WebCore/platform/graphics/wx/IntRectWx.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2006, 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "IntRect.h" + +#include <wx/defs.h> +#include <wx/gdicmn.h> + +namespace WebCore { + +IntRect::IntRect(const wxRect& r) + : m_location(IntPoint(r.x, r.y)) + , m_size(IntSize(r.width, r.height)) +{ +} + +IntRect::operator wxRect() const +{ + return wxRect(x(), y(), width(), height()); +} + +} diff --git a/WebCore/platform/graphics/wx/PathWx.cpp b/WebCore/platform/graphics/wx/PathWx.cpp new file mode 100644 index 0000000..5ff9914 --- /dev/null +++ b/WebCore/platform/graphics/wx/PathWx.cpp @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2007 Kevin Ollivier All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Path.h" + +#include "AffineTransform.h" +#include "FloatPoint.h" +#include "FloatRect.h" +#include "NotImplemented.h" + +#include <stdio.h> + +#include <wx/defs.h> +#include <wx/graphics.h> + +namespace WebCore { + +int getWxWindRuleForWindRule(WindRule rule) +{ + if (rule == RULE_EVENODD) + return wxODDEVEN_RULE; + + return wxWINDING_RULE; +} + +Path::Path() +{ + m_path = 0; + // NB: This only supports the 'default' renderer as determined by wx on + // each platform. If an app uses a non-default renderer (e.g. Cairo on Win), + // there will be problems, but there's no way we can determine which + // renderer an app is using right now with wx API, so we will just handle + // the common case. +#if USE(WXGC) + wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer(); + if (renderer) { + wxGraphicsPath path = renderer->CreatePath(); + m_path = new wxGraphicsPath(path); + } +#endif +} + +Path::~Path() +{ +} + +Path::Path(const Path& path) +{ + m_path = (PlatformPath*)&path.m_path; +} + +bool Path::contains(const FloatPoint& point, const WindRule rule) const +{ + return false; +} + +void Path::translate(const FloatSize&) +{ + notImplemented(); +} + +FloatRect Path::boundingRect() const +{ +#if USE(WXGC) + if (m_path) { + return m_path->GetBox(); + } +#endif + + return FloatRect(); +} + +Path& Path::operator=(const Path&) +{ + notImplemented(); + return*this; +} + +void Path::clear() +{ + if (m_path) + delete m_path; + +#if USE(WXGC) + wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer(); + if (renderer) { + wxGraphicsPath path = renderer->CreatePath(); + m_path = new wxGraphicsPath(path); + } +#endif +} + +void Path::moveTo(const FloatPoint& point) +{ +#if USE(WXGC) + if (m_path) + m_path->MoveToPoint(point.x(), point.y()); +#endif +} + +void Path::addLineTo(const FloatPoint&) +{ + notImplemented(); +} + +void Path::addQuadCurveTo(const FloatPoint&, const FloatPoint&) +{ + notImplemented(); +} + +void Path::addBezierCurveTo(const FloatPoint&, const FloatPoint&, const FloatPoint&) +{ + notImplemented(); +} + +void Path::addArcTo(const FloatPoint&, const FloatPoint&, float) +{ + notImplemented(); +} + +void Path::closeSubpath() +{ + notImplemented(); +} + +void Path::addArc(const FloatPoint&, float, float, float, bool) +{ + notImplemented(); +} + +void Path::addRect(const FloatRect&) +{ + notImplemented(); +} + +void Path::addEllipse(const FloatRect&) +{ + notImplemented(); +} + +void Path::transform(const AffineTransform&) +{ + notImplemented(); +} + +void Path::apply(void* info, PathApplierFunction function) const +{ + notImplemented(); +} + +bool Path::isEmpty() const +{ + notImplemented(); + return false; +} + +} diff --git a/WebCore/platform/graphics/wx/PenWx.cpp b/WebCore/platform/graphics/wx/PenWx.cpp new file mode 100644 index 0000000..5a131e3 --- /dev/null +++ b/WebCore/platform/graphics/wx/PenWx.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Pen.h" + +#include <wx/defs.h> +#include <wx/pen.h> +#include <wx/colour.h> + +namespace WebCore { + +// Pen style conversion functions +static int penStyleToWxPenStyle(int p) +{ + if (p == Pen::SolidLine) + return wxSOLID; + if (p == Pen::DotLine) + return wxDOT; + if (p == Pen::DashLine) + return wxLONG_DASH; + if (p == Pen::NoPen) + return wxTRANSPARENT; + + return wxSOLID; +} + +static Pen::PenStyle wxPenStyleToPenStyle(int p) +{ + if (p == wxSOLID) + return Pen::SolidLine; + if (p == wxDOT) + return Pen::DotLine; + if (p == wxLONG_DASH || p == wxSHORT_DASH || p == wxDOT_DASH || p == wxUSER_DASH) + return Pen::DashLine; + if (p == wxTRANSPARENT) + return Pen::NoPen; + + return Pen::SolidLine; +} + +Pen::Pen(const wxPen& p) +{ + wxColour color = p.GetColour(); + setColor(Color(color.Red(), color.Green(), color.Blue())); + setWidth(p.GetWidth()); + setStyle(wxPenStyleToPenStyle(p.GetStyle())); +} + +Pen::operator wxPen() const +{ + return wxPen(wxColour(m_color.red(), m_color.blue(), m_color.green()), width(), penStyleToWxPenStyle(style())); +} + +} diff --git a/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp b/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp new file mode 100755 index 0000000..a509933 --- /dev/null +++ b/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SimpleFontData.h" + +#include "FontCache.h" +#include "FloatRect.h" +#include "FontDescription.h" +#include <wtf/MathExtras.h> +#include <unicode/uchar.h> +#include <unicode/unorm.h> + +#include <wx/defs.h> +#include <wx/dcscreen.h> +#include "fontprops.h" + +namespace WebCore +{ + +void SimpleFontData::platformInit() +{ + wxFont font = m_font.font(); + wxFontProperties props = wxFontProperties(&font); + m_ascent = props.GetAscent(); + m_descent = props.GetDescent(); + m_lineSpacing = props.GetLineSpacing(); + m_xHeight = props.GetXHeight(); + m_unitsPerEm = 1; // FIXME! + m_lineGap = props.GetLineGap(); +} + +void SimpleFontData::platformDestroy() +{ + delete m_smallCapsFontData; +} + +SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const +{ + if (!m_smallCapsFontData){ + FontDescription desc = FontDescription(fontDescription); + desc.setSpecifiedSize(0.70f*fontDescription.computedSize()); + const FontPlatformData* pdata = new FontPlatformData(desc, desc.family().family()); + m_smallCapsFontData = new SimpleFontData(*pdata); + } + return m_smallCapsFontData; +} + +bool SimpleFontData::containsCharacters(const UChar* characters, int length) const +{ + // FIXME: We will need to implement this to load non-ASCII encoding sites + return true; +} + +void SimpleFontData::determinePitch() +{ + if (m_font.font().Ok()) + m_treatAsFixedPitch = m_font.font().IsFixedWidth(); + else + m_treatAsFixedPitch = false; +} + +float SimpleFontData::platformWidthForGlyph(Glyph glyph) const +{ + // TODO: fix this! Make GetTextExtents a method of wxFont in 2.9 + int width = 10; + GetTextExtent(m_font.font(), (wxChar)glyph, &width, NULL); + return width; +} + +} |