summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/mac
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/mac')
-rw-r--r--WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp57
-rw-r--r--WebCore/platform/graphics/mac/IconMac.mm1
-rw-r--r--WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h3
-rw-r--r--WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm25
-rw-r--r--WebCore/platform/graphics/mac/SimpleFontDataMac.mm69
5 files changed, 68 insertions, 87 deletions
diff --git a/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp b/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp
index 99ad130..096cdbd 100644
--- a/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp
+++ b/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp
@@ -1126,31 +1126,6 @@ long GraphicsContext3D::getVertexAttribOffset(unsigned long index, unsigned long
return reinterpret_cast<long>(pointer);
}
-// Returned pointer must be freed by fastFree()
-static bool imageToTexture(Image* image, GLubyte*& buffer, size_t& width, size_t& height)
-{
- if (!image)
- return false;
-
- CGImageRef textureImage = image->getCGImageRef();
- if (!textureImage)
- return false;
-
- width = CGImageGetWidth(textureImage);
- height = CGImageGetHeight(textureImage);
-
- buffer = (GLubyte*) fastMalloc(width * height * 4);
- if (!buffer)
- return false;
-
- CGContextRef textureContext = CGBitmapContextCreate(buffer, width, height, 8, width * 4,
- CGImageGetColorSpace(textureImage), kCGImageAlphaPremultipliedLast);
- CGContextSetBlendMode(textureContext, kCGBlendModeCopy);
- CGContextDrawImage(textureContext, CGRectMake(0, 0, (CGFloat)width, (CGFloat)height), textureImage);
- CGContextRelease(textureContext);
- return true;
-}
-
int GraphicsContext3D::texImage2D(unsigned target, unsigned level, unsigned internalformat, unsigned width, unsigned height, unsigned border, unsigned format, unsigned type, void* pixels)
{
// FIXME: Need to do bounds checking on the buffer here.
@@ -1160,20 +1135,12 @@ int GraphicsContext3D::texImage2D(unsigned target, unsigned level, unsigned inte
int GraphicsContext3D::texImage2D(unsigned target, unsigned level, Image* image, bool flipY, bool premultiplyAlpha)
{
- // FIXME: need to support flipY and premultiplyAlpha
- UNUSED_PARAM(flipY);
- UNUSED_PARAM(premultiplyAlpha);
- ASSERT(image);
-
ensureContext(m_contextObj);
- GLubyte* buffer;
- size_t width;
- size_t height;
- if (!imageToTexture(image, buffer, width, height))
+ Vector<uint8_t> imageData;
+ unsigned int format, internalFormat;
+ if (!extractImageData(image, flipY, premultiplyAlpha, imageData, &format, &internalFormat))
return -1;
-
- ::glTexImage2D(target, level, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
- fastFree(buffer);
+ ::glTexImage2D(target, level, internalFormat, image->width(), image->height(), 0, format, GL_UNSIGNED_BYTE, imageData.data());
return 0;
}
@@ -1188,20 +1155,12 @@ int GraphicsContext3D::texSubImage2D(unsigned target, unsigned level, unsigned x
int GraphicsContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoff, unsigned yoff, Image* image, bool flipY, bool premultiplyAlpha)
{
// FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size
- // FIXME: need to support flipY and premultiplyAlpha
- UNUSED_PARAM(flipY);
- UNUSED_PARAM(premultiplyAlpha);
- ASSERT(image);
-
ensureContext(m_contextObj);
- GLubyte* buffer;
- size_t width;
- size_t height;
- if (!imageToTexture(image, buffer, width, height))
+ Vector<uint8_t> imageData;
+ unsigned int format, internalFormat;
+ if (!extractImageData(image, flipY, premultiplyAlpha, imageData, &format, &internalFormat))
return -1;
-
- ::glTexSubImage2D(target, level, xoff, yoff, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
- fastFree(buffer);
+ ::glTexSubImage2D(target, level, xoff, yoff, image->width(), image->height(), format, GL_UNSIGNED_BYTE, imageData.data());
return 0;
}
diff --git a/WebCore/platform/graphics/mac/IconMac.mm b/WebCore/platform/graphics/mac/IconMac.mm
index aee7234..bc8c312 100644
--- a/WebCore/platform/graphics/mac/IconMac.mm
+++ b/WebCore/platform/graphics/mac/IconMac.mm
@@ -39,6 +39,7 @@ Icon::~Icon()
{
}
+// FIXME: Move the code to ChromeClient::iconForFiles().
PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
{
if (filenames.isEmpty())
diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
index e9f64be..355aa68 100644
--- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
+++ b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
@@ -78,6 +78,9 @@ private:
static bool isAvailable();
PlatformMedia platformMedia() const;
+#if USE(ACCELERATED_COMPOSITING)
+ PlatformLayer* platformLayer() const;
+#endif
IntSize naturalSize() const;
bool hasVideo() const;
diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
index dd87bb5..2b90f7a 100644
--- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
+++ b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
@@ -445,12 +445,7 @@ void MediaPlayerPrivate::createQTMovieLayer()
#ifndef NDEBUG
[(CALayer *)m_qtVideoLayer.get() setName:@"Video layer"];
#endif
-
- // Hang the video layer from the render layer, if we have one yet. If not, we'll do this
- // later via acceleratedRenderingStateChanged().
- GraphicsLayer* videoGraphicsLayer = m_player->mediaPlayerClient()->mediaPlayerGraphicsLayer(m_player);
- if (videoGraphicsLayer)
- videoGraphicsLayer->setContentsToMedia(m_qtVideoLayer.get());
+ // The layer will get hooked up via RenderLayerBacking::updateGraphicsLayerConfiguration().
}
#endif
}
@@ -522,6 +517,11 @@ void MediaPlayerPrivate::setUpVideoRendering()
createQTMovieLayer();
break;
}
+
+#if USE(ACCELERATED_COMPOSITING)
+ if (currentMode == MediaRenderingMovieLayer || preferredMode == MediaRenderingMovieLayer)
+ m_player->mediaPlayerClient()->mediaPlayerRenderingModeChanged(m_player);
+#endif
}
void MediaPlayerPrivate::tearDownVideoRendering()
@@ -576,6 +576,13 @@ PlatformMedia MediaPlayerPrivate::platformMedia() const
return plaftformMedia;
}
+#if USE(ACCELERATED_COMPOSITING)
+PlatformLayer* MediaPlayerPrivate::platformLayer() const
+{
+ return m_qtVideoLayer.get();
+}
+#endif
+
void MediaPlayerPrivate::play()
{
if (!metaDataAvailable())
@@ -1406,12 +1413,6 @@ void MediaPlayerPrivate::acceleratedRenderingStateChanged()
{
// Set up or change the rendering path if necessary.
setUpVideoRendering();
-
- if (currentRenderingMode() == MediaRenderingMovieLayer) {
- GraphicsLayer* videoGraphicsLayer = m_player->mediaPlayerClient()->mediaPlayerGraphicsLayer(m_player);
- if (videoGraphicsLayer)
- videoGraphicsLayer->setContentsToMedia(m_qtVideoLayer.get());
- }
}
#endif
diff --git a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
index ef7c58f..09947d8 100644
--- a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
+++ b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
@@ -273,37 +273,54 @@ void SimpleFontData::platformInit()
} else
m_xHeight = [m_platformData.font() xHeight];
}
+
+static CFDataRef copyFontTableForTag(FontPlatformData platformData, FourCharCode tableName)
+{
+#ifdef BUILDING_ON_TIGER
+ ATSFontRef atsFont = FMGetATSFontRefFromFont(platformData.m_atsuFontID);
+
+ ByteCount tableSize;
+ if (ATSFontGetTable(atsFont, tableName, 0, 0, NULL, &tableSize) != noErr)
+ return 0;
+
+ CFMutableDataRef data = CFDataCreateMutable(kCFAllocatorDefault, tableSize);
+ if (!data)
+ return 0;
+
+ CFDataIncreaseLength(data, tableSize);
+ if (ATSFontGetTable(atsFont, tableName, 0, tableSize, CFDataGetMutableBytePtr(data), &tableSize) != noErr) {
+ CFRelease(data);
+ return 0;
+ }
+
+ return data;
+#else
+ return CGFontCopyTableForTag(platformData.cgFont(), tableName);
+#endif
+}
void SimpleFontData::platformCharWidthInit()
{
- m_avgCharWidth = 0.f;
-
- // Calculate avgCharWidth according to http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6OS2.html
- // We can try grabbing it out of the OS/2 table or via ATSFontGetHorizontalMetrics, but
- // ATSFontGetHorizontalMetrics never seems to return a non-zero value and the OS/2 table
- // contains zero for a large number of fonts.
- GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
- if (glyphPageZero) {
- static int weights[] = { 64, 14, 27, 35, 100, 20, 14, 42, 63, 3, 6, 35, 20, 56, 56, 17, 4, 49, 56, 71, 31, 10, 18, 3, 18, 2, 166 };
- int numGlyphs = 27;
- ASSERT(numGlyphs == sizeof(weights) / sizeof(int));
- // Compute the weighted sum of the space character and the lowercase letters in the Latin alphabet.
- float sum = 0.f;
- int totalWeight = 0;
- for (int i = 0; i < numGlyphs; i++) {
- Glyph glyph = glyphPageZero->glyphDataForCharacter((i < 26 ? i + 'a' : ' ')).glyph;
- if (glyph) {
- totalWeight += weights[i];
- sum += widthForGlyph(glyph) * weights[i];
- }
- }
- if (sum > 0.f && totalWeight > 0)
- m_avgCharWidth = sum / totalWeight;
+ m_avgCharWidth = 0;
+ m_maxCharWidth = 0;
+
+ RetainPtr<CFDataRef> os2Table(AdoptCF, copyFontTableForTag(m_platformData, 'OS/2'));
+ if (os2Table && CFDataGetLength(os2Table.get()) >= 4) {
+ const UInt8* os2 = CFDataGetBytePtr(os2Table.get());
+ SInt16 os2AvgCharWidth = os2[2] * 256 + os2[3];
+ m_avgCharWidth = scaleEmToUnits(os2AvgCharWidth, m_unitsPerEm) * m_platformData.m_size;
}
- m_maxCharWidth = 0.f;
- if (m_platformData.font())
- m_maxCharWidth = [m_platformData.font() maximumAdvancement].width;
+ RetainPtr<CFDataRef> headTable(AdoptCF, copyFontTableForTag(m_platformData, 'head'));
+ if (headTable && CFDataGetLength(headTable.get()) >= 42) {
+ const UInt8* head = CFDataGetBytePtr(headTable.get());
+ ushort uxMin = head[36] * 256 + head[37];
+ ushort uxMax = head[40] * 256 + head[41];
+ SInt16 xMin = static_cast<SInt16>(uxMin);
+ SInt16 xMax = static_cast<SInt16>(uxMax);
+ float diff = static_cast<float>(xMax - xMin);
+ m_maxCharWidth = scaleEmToUnits(diff, m_unitsPerEm) * m_platformData.m_size;
+ }
// Fallback to a cross-platform estimate, which will populate these values if they are non-positive.
initCharWidths();