summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/cg
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-04-27 16:31:00 +0100
committerSteve Block <steveblock@google.com>2010-05-11 14:42:12 +0100
commitdcc8cf2e65d1aa555cce12431a16547e66b469ee (patch)
tree92a8d65cd5383bca9749f5327fb5e440563926e6 /WebCore/platform/graphics/cg
parentccac38a6b48843126402088a309597e682f40fe6 (diff)
downloadexternal_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.zip
external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.gz
external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.bz2
Merge webkit.org at r58033 : Initial merge by git
Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1
Diffstat (limited to 'WebCore/platform/graphics/cg')
-rw-r--r--WebCore/platform/graphics/cg/FontPlatformData.h102
-rw-r--r--WebCore/platform/graphics/cg/GradientCG.cpp2
-rw-r--r--WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h1
-rw-r--r--WebCore/platform/graphics/cg/ImageBufferCG.cpp5
-rw-r--r--WebCore/platform/graphics/cg/ImageSourceCG.cpp31
-rw-r--r--WebCore/platform/graphics/cg/PDFDocumentImage.cpp7
-rw-r--r--WebCore/platform/graphics/cg/PDFDocumentImage.h2
-rw-r--r--WebCore/platform/graphics/cg/PathCG.cpp4
8 files changed, 146 insertions, 8 deletions
diff --git a/WebCore/platform/graphics/cg/FontPlatformData.h b/WebCore/platform/graphics/cg/FontPlatformData.h
new file mode 100644
index 0000000..da2b7e3
--- /dev/null
+++ b/WebCore/platform/graphics/cg/FontPlatformData.h
@@ -0,0 +1,102 @@
+/*
+ * This file is part of the internal font implementation. It should not be included by anyone other than
+ * FontMac.cpp, FontWin.cpp and Font.cpp.
+ *
+ * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef FontPlatformData_h
+#define FontPlatformData_h
+
+#include "RefCountedHFONT.h"
+#include "StringImpl.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RetainPtr.h>
+
+typedef struct HFONT__* HFONT;
+typedef struct CGFont* CGFontRef;
+
+namespace WebCore {
+
+class FontDescription;
+class String;
+
+class FontPlatformData {
+public:
+ FontPlatformData()
+ : m_size(0)
+ , m_syntheticBold(false)
+ , m_syntheticOblique(false)
+ , m_useGDI(false)
+ {
+ }
+
+ FontPlatformData(HFONT, float size, bool bold, bool oblique, bool useGDI);
+ FontPlatformData(float size, bool bold, bool oblique);
+
+ FontPlatformData(HFONT, CGFontRef, float size, bool bold, bool oblique, bool useGDI);
+ ~FontPlatformData();
+
+ FontPlatformData(WTF::HashTableDeletedValueType) : m_font(WTF::HashTableDeletedValue) { }
+ bool isHashTableDeletedValue() const { return m_font.isHashTableDeletedValue(); }
+
+ HFONT hfont() const { return m_font->hfont(); }
+ CGFontRef cgFont() const { return m_cgFont.get(); }
+
+ float size() const { return m_size; }
+ void setSize(float size) { m_size = size; }
+ bool syntheticBold() const { return m_syntheticBold; }
+ bool syntheticOblique() const { return m_syntheticOblique; }
+ bool useGDI() const { return m_useGDI; }
+
+ unsigned hash() const
+ {
+ return m_font->hash();
+ }
+
+ bool operator==(const FontPlatformData& other) const
+ {
+ return m_font == other.m_font
+ && m_cgFont == other.m_cgFont
+ && m_size == other.m_size
+ && m_syntheticBold == other.m_syntheticBold
+ && m_syntheticOblique == other.m_syntheticOblique
+ && m_useGDI == other.m_useGDI;
+ }
+
+#ifndef NDEBUG
+ String description() const;
+#endif
+
+private:
+ void platformDataInit(HFONT, float size, HDC, WCHAR* faceName);
+
+ RefPtr<RefCountedHFONT> m_font;
+ RetainPtr<CGFontRef> m_cgFont;
+
+ float m_size;
+ bool m_syntheticBold;
+ bool m_syntheticOblique;
+ bool m_useGDI;
+};
+
+}
+
+#endif
diff --git a/WebCore/platform/graphics/cg/GradientCG.cpp b/WebCore/platform/graphics/cg/GradientCG.cpp
index 9c91700..4aaaeaf 100644
--- a/WebCore/platform/graphics/cg/GradientCG.cpp
+++ b/WebCore/platform/graphics/cg/GradientCG.cpp
@@ -29,8 +29,8 @@
#include "CSSParser.h"
#include "GraphicsContext.h"
-
#include <ApplicationServices/ApplicationServices.h>
+#include <wtf/RetainPtr.h>
namespace WebCore {
diff --git a/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h b/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
index b1efba1..aac4f45 100644
--- a/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
+++ b/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
@@ -23,6 +23,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <wtf/RetainPtr.h>
#include <CoreGraphics/CGContext.h>
namespace WebCore {
diff --git a/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/WebCore/platform/graphics/cg/ImageBufferCG.cpp
index 0dc7a53..c82ebdc 100644
--- a/WebCore/platform/graphics/cg/ImageBufferCG.cpp
+++ b/WebCore/platform/graphics/cg/ImageBufferCG.cpp
@@ -29,15 +29,16 @@
#include "Base64.h"
#include "BitmapImage.h"
-#include "CString.h"
#include "GraphicsContext.h"
#include "ImageData.h"
#include "MIMETypeRegistry.h"
#include "PlatformString.h"
#include <ApplicationServices/ApplicationServices.h>
#include <wtf/Assertions.h>
+#include <wtf/text/CString.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/RetainPtr.h>
+#include <wtf/Threading.h>
#include <math.h>
using namespace std;
@@ -254,6 +255,8 @@ static RetainPtr<CFStringRef> utiFromMIMEType(const String& mimeType)
RetainPtr<CFStringRef> mimeTypeCFString(AdoptCF, mimeType.createCFString());
return RetainPtr<CFStringRef>(AdoptCF, UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeTypeCFString.get(), 0));
#else
+ ASSERT(isMainThread()); // It is unclear if CFSTR is threadsafe.
+
// FIXME: Add Windows support for all the supported UTIs when a way to convert from MIMEType to UTI reliably is found.
// For now, only support PNG, JPEG, and GIF. See <rdar://problem/6095286>.
static const CFStringRef kUTTypePNG = CFSTR("public.png");
diff --git a/WebCore/platform/graphics/cg/ImageSourceCG.cpp b/WebCore/platform/graphics/cg/ImageSourceCG.cpp
index 2b2c6b0..b4e1ca9 100644
--- a/WebCore/platform/graphics/cg/ImageSourceCG.cpp
+++ b/WebCore/platform/graphics/cg/ImageSourceCG.cpp
@@ -74,7 +74,7 @@ ImageSource::~ImageSource()
void ImageSource::clear(bool destroyAllFrames, size_t, SharedBuffer* data, bool allDataReceived)
{
-#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
// Recent versions of ImageIO discard previously decoded image frames if the client
// application no longer holds references to them, so there's no need to throw away
// the decoder unless we're explicitly asked to destroy all of the frames.
@@ -119,14 +119,22 @@ bool ImageSource::initialized() const
void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
{
- if (!m_decoder)
- m_decoder = CGImageSourceCreateIncremental(NULL);
#if PLATFORM(MAC)
+ if (!m_decoder)
+ m_decoder = CGImageSourceCreateIncremental(0);
// On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge. We use SharedBuffer's ability
// to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer.
RetainPtr<CFDataRef> cfData(AdoptCF, data->createCFData());
CGImageSourceUpdateData(m_decoder, cfData.get(), allDataReceived);
#else
+ if (!m_decoder) {
+ m_decoder = CGImageSourceCreateIncremental(0);
+ } else if (allDataReceived) {
+ // 10.6 bug workaround: image sources with final=false fail to draw into PDF contexts, so re-create image source
+ // when data is complete. <rdar://problem/7874035> (<http://openradar.appspot.com/7874035>)
+ CFRelease(m_decoder);
+ m_decoder = CGImageSourceCreateIncremental(0);
+ }
// Create a CGDataProvider to wrap the SharedBuffer.
data->ref();
// We use the GetBytesAtPosition callback rather than the GetBytePointer one because SharedBuffer
@@ -234,7 +242,22 @@ CGImageRef ImageSource::createFrameAtIndex(size_t index)
bool ImageSource::frameIsCompleteAtIndex(size_t index)
{
- return CGImageSourceGetStatusAtIndex(m_decoder, index) == kCGImageStatusComplete;
+ ASSERT(frameCount());
+
+ // CGImageSourceGetStatusAtIndex claims that all frames of a multi-frame image are incomplete
+ // when we've not yet received the complete data for an image that is using an incremental data
+ // source (<rdar://problem/7679174>). We work around this by special-casing all frames except the
+ // last in an image and treating them as complete if they are present and reported as being
+ // incomplete. We do this on the assumption that loading new data can only modify the existing last
+ // frame or append new frames. The last frame is only treated as being complete if the image source
+ // reports it as such. This ensures that it is truly the last frame of the image rather than just
+ // the last that we currently have data for.
+
+ CGImageSourceStatus frameStatus = CGImageSourceGetStatusAtIndex(m_decoder, index);
+ if (index < frameCount() - 1)
+ return frameStatus >= kCGImageStatusIncomplete;
+
+ return frameStatus == kCGImageStatusComplete;
}
float ImageSource::frameDurationAtIndex(size_t index)
diff --git a/WebCore/platform/graphics/cg/PDFDocumentImage.cpp b/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
index 67333ae..8bf04f1 100644
--- a/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
+++ b/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
@@ -31,7 +31,9 @@
#include "GraphicsContext.h"
#include "ImageObserver.h"
+#include "SharedBuffer.h"
#include <wtf/MathExtras.h>
+#include <wtf/RetainPtr.h>
#if !PLATFORM(MAC)
#include "ImageSourceCG.h"
@@ -54,6 +56,11 @@ PDFDocumentImage::~PDFDocumentImage()
CGPDFDocumentRelease(m_document);
}
+String PDFDocumentImage::filenameExtension() const
+{
+ return "pdf";
+}
+
IntSize PDFDocumentImage::size() const
{
const float sina = sinf(-m_rotation);
diff --git a/WebCore/platform/graphics/cg/PDFDocumentImage.h b/WebCore/platform/graphics/cg/PDFDocumentImage.h
index 12ab46c..790d620 100644
--- a/WebCore/platform/graphics/cg/PDFDocumentImage.h
+++ b/WebCore/platform/graphics/cg/PDFDocumentImage.h
@@ -46,6 +46,8 @@ namespace WebCore {
private:
virtual ~PDFDocumentImage();
+ virtual String filenameExtension() const;
+
virtual bool hasSingleSecurityOrigin() const { return true; }
virtual bool dataChanged(bool allDataReceived);
diff --git a/WebCore/platform/graphics/cg/PathCG.cpp b/WebCore/platform/graphics/cg/PathCG.cpp
index 81454b3..eb196d9 100644
--- a/WebCore/platform/graphics/cg/PathCG.cpp
+++ b/WebCore/platform/graphics/cg/PathCG.cpp
@@ -30,14 +30,14 @@
#if PLATFORM(CG)
#include "AffineTransform.h"
-#include <ApplicationServices/ApplicationServices.h>
#include "FloatRect.h"
#include "GraphicsContext.h"
#include "IntRect.h"
#include "PlatformString.h"
#include "StrokeStyleApplier.h"
-
+#include <ApplicationServices/ApplicationServices.h>
#include <wtf/MathExtras.h>
+#include <wtf/RetainPtr.h>
namespace WebCore {