diff options
Diffstat (limited to 'WebCore/platform/graphics/win')
16 files changed, 511 insertions, 103 deletions
diff --git a/WebCore/platform/graphics/win/FontPlatformDataCairoWin.h b/WebCore/platform/graphics/win/FontPlatformDataCairoWin.h new file mode 100644 index 0000000..05f9eab --- /dev/null +++ b/WebCore/platform/graphics/win/FontPlatformDataCairoWin.h @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2006, 2007, 2008 Apple Inc. + * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com + * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2007 Pioneer Research Center USA, Inc. + * All rights reserved. + * + * 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 FontPlatformDataCairoWin_h +#define FontPlatformDataCairoWin_h + +#include "FontDescription.h" +#include "GlyphBuffer.h" +#include "RefCountedGDIHandle.h" +#include "StringImpl.h" +#include <cairo-win32.h> +#include <cairo.h> +#include <wtf/Forward.h> + +typedef struct HFONT__* HFONT; + +namespace WebCore { + +class FontPlatformData { +public: + FontPlatformData(WTF::HashTableDeletedValueType) + : m_fontFace(0) + , m_useGDI(false) + , m_font(WTF::HashTableDeletedValue) + , m_size(0) + , m_syntheticBold(false) + , m_syntheticOblique(false) + , m_scaledFont(0) + { } + + FontPlatformData() + : m_fontFace(0) + , m_useGDI(false) + , m_size(0) + , m_syntheticBold(false) + , m_syntheticOblique(false) + , m_scaledFont(0) + { } + + FontPlatformData(HFONT, float size, bool bold, bool oblique, bool useGDI); + FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool italic); + FontPlatformData(float size, bool bold, bool italic); + FontPlatformData(const FontPlatformData&); + ~FontPlatformData(); + + HFONT hfont() const { return m_font->handle(); } + bool useGDI() const { return m_useGDI; } + cairo_font_face_t* fontFace() const { return m_fontFace; } + + bool isFixedPitch(); + 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; } + cairo_scaled_font_t* scaledFont() const { return m_scaledFont; } + + unsigned hash() const + { + return m_font->hash(); + } + + bool operator==(const FontPlatformData&) const; + FontPlatformData& operator=(const FontPlatformData&); + bool isHashTableDeletedValue() const + { + return m_font.isHashTableDeletedValue(); + } + +#ifndef NDEBUG + String description() const; +#endif + +private: + void platformDataInit(HFONT, float size, HDC, WCHAR* faceName); + + RefPtr<RefCountedGDIHandle<HFONT> > m_font; + cairo_font_face_t* m_fontFace; + bool m_useGDI; + float m_size; + bool m_syntheticBold; + bool m_syntheticOblique; + cairo_scaled_font_t* m_scaledFont; +}; + +} + +#endif // FontPlatformDataCairoWin_h diff --git a/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp b/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp index 96ac0c1..dad5da1 100644 --- a/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp +++ b/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp @@ -121,11 +121,6 @@ static void clearLayerBackgroundColor(WKCACFLayer* layer) layer->setBackgroundColor(0); } -GraphicsLayer::CompositingCoordinatesOrientation GraphicsLayer::compositingCoordinatesOrientation() -{ - return CompositingCoordinatesBottomUp; -} - PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client) { return new GraphicsLayerCACF(client); @@ -395,15 +390,6 @@ void GraphicsLayerCACF::setContentsToMedia(PlatformLayer* mediaLayer) updateSublayerList(); } -void GraphicsLayerCACF::setGeometryOrientation(CompositingCoordinatesOrientation orientation) -{ - if (orientation == m_geometryOrientation) - return; - - GraphicsLayer::setGeometryOrientation(orientation); - updateGeometryOrientation(); -} - PlatformLayer* GraphicsLayerCACF::hostLayerForSublayers() const { return m_transformLayer ? m_transformLayer.get() : m_layer.get(); @@ -461,13 +447,6 @@ void GraphicsLayerCACF::swapFromOrToTiledLayer(bool useTiledLayer) m_layer = WebLayer::create(WKCACFLayer::Layer, this); m_usingTiledLayer = useTiledLayer; - - if (useTiledLayer) { - if (GraphicsLayer::compositingCoordinatesOrientation() == GraphicsLayer::CompositingCoordinatesBottomUp) - m_layer->setContentsGravity(WKCACFLayer::BottomLeft); - else - m_layer->setContentsGravity(WKCACFLayer::TopLeft); - } m_layer->adoptSublayers(oldLayer.get()); if (oldLayer->superlayer()) @@ -738,21 +717,6 @@ void GraphicsLayerCACF::updateContentsRect() m_contentsLayer->setBounds(rect); } -void GraphicsLayerCACF::updateGeometryOrientation() -{ - switch (geometryOrientation()) { - case CompositingCoordinatesTopDown: - m_layer->setGeometryFlipped(false); - break; - - case CompositingCoordinatesBottomUp: - m_layer->setGeometryFlipped(true); - break; - } - // Geometry orientation is mapped onto children transform in older QuartzCores, - // so is handled via setGeometryOrientation(). -} - void GraphicsLayerCACF::setupContentsLayer(WKCACFLayer* contentsLayer) { if (contentsLayer == m_contentsLayer) diff --git a/WebCore/platform/graphics/win/GraphicsLayerCACF.h b/WebCore/platform/graphics/win/GraphicsLayerCACF.h index 0b74266..c18a6e9 100644 --- a/WebCore/platform/graphics/win/GraphicsLayerCACF.h +++ b/WebCore/platform/graphics/win/GraphicsLayerCACF.h @@ -89,8 +89,6 @@ public: virtual void setDebugBackgroundColor(const Color&); virtual void setDebugBorder(const Color&, float borderWidth); - virtual void setGeometryOrientation(CompositingCoordinatesOrientation); - private: void updateOpacityOnLayer(); @@ -118,7 +116,6 @@ private: void updateContentsImage(); void updateContentsMedia(); void updateContentsRect(); - void updateGeometryOrientation(); void setupContentsLayer(WKCACFLayer*); WKCACFLayer* contentsLayer() const { return m_contentsLayer.get(); } diff --git a/WebCore/platform/graphics/win/LocalWindowsContext.h b/WebCore/platform/graphics/win/LocalWindowsContext.h index c216140..c216140 100755..100644 --- a/WebCore/platform/graphics/win/LocalWindowsContext.h +++ b/WebCore/platform/graphics/win/LocalWindowsContext.h diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp index e664f2a..4a7e45e 100644..100755 --- a/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp +++ b/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp @@ -107,7 +107,6 @@ void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<WKCACFLaye WKCACFLayer* rootLayer = m_rootChild->rootLayer(); CGRect rootBounds = m_rootChild->rootLayer()->bounds(); m_rootChild->setFrame(rootBounds); - m_layerRenderer->setScrollFrame(IntPoint(rootBounds.origin), IntSize(rootBounds.size)); m_rootChild->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack)); #ifndef NDEBUG RetainPtr<CGColorRef> redColor(AdoptCF, CGColorCreateGenericRGB(1, 0, 0, 1)); @@ -165,7 +164,6 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA CGRect rootBounds = m_rootChild->rootLayer()->bounds(); m_rootChild->setFrame(rootBounds); m_rootChild->setNeedsLayout(); - m_layerRenderer->setScrollFrame(IntPoint(rootBounds.origin), IntSize(rootBounds.size)); #endif } break; diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp index 9bc68d1..354e0bf 100644 --- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp +++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp @@ -97,6 +97,39 @@ public: private: MediaPlayerPrivateQuickTimeVisualContext* m_parent; }; + +class MediaPlayerPrivateQuickTimeVisualContext::LayoutClient : public WKCACFLayerLayoutClient { +public: + LayoutClient(MediaPlayerPrivateQuickTimeVisualContext* parent) : m_parent(parent) {} + virtual void layoutSublayersOfLayer(WKCACFLayer*); +private: + MediaPlayerPrivateQuickTimeVisualContext* m_parent; +}; + +void MediaPlayerPrivateQuickTimeVisualContext::LayoutClient::layoutSublayersOfLayer(WKCACFLayer* layer) +{ + ASSERT(m_parent); + ASSERT(m_parent->m_transformLayer->platformLayer() == layer); + + CGSize parentSize = layer->bounds().size; + CGSize naturalSize = m_parent->naturalSize(); + + // Calculate the ratio of these two sizes and use that ratio to scale the qtVideoLayer: + CGSize ratio = CGSizeMake(parentSize.width / naturalSize.width, parentSize.height / naturalSize.height); + + int videoWidth = 0; + int videoHeight = 0; + m_parent->m_movie->getNaturalSize(videoWidth, videoHeight); + CGRect videoBounds = CGRectMake(0, 0, videoWidth * ratio.width, videoHeight * ratio.height); + CGPoint videoAnchor = m_parent->m_qtVideoLayer->anchorPoint(); + + // Calculate the new position based on the parent's size: + CGPoint position = CGPointMake(parentSize.width * 0.5 - videoBounds.size.width * (0.5 - videoAnchor.x), + parentSize.height * 0.5 - videoBounds.size.height * (0.5 - videoAnchor.y)); + + m_parent->m_qtVideoLayer->setBounds(videoBounds); + m_parent->m_qtVideoLayer->setPosition(position); +} #endif class MediaPlayerPrivateQuickTimeVisualContext::VisualContextClient : public QTMovieVisualContextClient { @@ -137,6 +170,8 @@ MediaPlayerPrivateQuickTimeVisualContext::MediaPlayerPrivateQuickTimeVisualConte , m_movieClient(new MediaPlayerPrivateQuickTimeVisualContext::MovieClient(this)) #if USE(ACCELERATED_COMPOSITING) , m_layerClient(new MediaPlayerPrivateQuickTimeVisualContext::LayerClient(this)) + , m_layoutClient(new MediaPlayerPrivateQuickTimeVisualContext::LayoutClient(this)) + , m_movieTransform(CGAffineTransformIdentity) #endif , m_visualContextClient(new MediaPlayerPrivateQuickTimeVisualContext::VisualContextClient(this)) { @@ -169,7 +204,7 @@ PlatformMedia MediaPlayerPrivateQuickTimeVisualContext::platformMedia() const #if USE(ACCELERATED_COMPOSITING) PlatformLayer* MediaPlayerPrivateQuickTimeVisualContext::platformLayer() const { - return m_qtVideoLayer ? m_qtVideoLayer->platformLayer() : 0; + return m_transformLayer ? m_transformLayer->platformLayer() : 0; } #endif @@ -263,6 +298,24 @@ void MediaPlayerPrivateQuickTimeVisualContext::setUpCookiesForQuickTime(const St } } +static void disableComponentsOnce() +{ + static bool sComponentsDisabled = false; + if (sComponentsDisabled) + return; + sComponentsDisabled = true; + + uint32_t componentsToDisable[][5] = { + {'eat ', 'TEXT', 'text', 0, 0}, + {'eat ', 'TXT ', 'text', 0, 0}, + {'eat ', 'utxt', 'text', 0, 0}, + {'eat ', 'TEXT', 'tx3g', 0, 0}, + }; + + for (size_t i = 0; i < sizeof(componentsToDisable) / sizeof(componentsToDisable[0]); ++i) + QTMovie::disableComponent(componentsToDisable[i]); +} + void MediaPlayerPrivateQuickTimeVisualContext::load(const String& url) { if (!QTMovie::initializeQuickTime()) { @@ -272,6 +325,8 @@ void MediaPlayerPrivateQuickTimeVisualContext::load(const String& url) return; } + disableComponentsOnce(); + // Initialize the task timer. MediaPlayerPrivateTaskTimer::initialize(); @@ -404,7 +459,13 @@ IntSize MediaPlayerPrivateQuickTimeVisualContext::naturalSize() const int width; int height; m_movie->getNaturalSize(width, height); +#if USE(ACCELERATED_COMPOSITING) + CGSize originalSize = {width, height}; + CGSize transformedSize = CGSizeApplyAffineTransform(originalSize, m_movieTransform); + return IntSize(abs(transformedSize.width), abs(transformedSize.height)); +#else return IntSize(width, height); +#endif } bool MediaPlayerPrivateQuickTimeVisualContext::hasVideo() const @@ -763,7 +824,7 @@ void MediaPlayerPrivateQuickTimeVisualContext::retrieveCurrentImage() if (!buffer.pixelBufferRef()) return; - WKCACFLayer* layer = static_cast<WKCACFLayer*>(m_qtVideoLayer->platformLayer()); + WKCACFLayer* layer = m_qtVideoLayer.get(); if (!buffer.lockBaseAddress()) { if (requiredDllsAvailable()) { @@ -1017,6 +1078,40 @@ bool MediaPlayerPrivateQuickTimeVisualContext::hasSetUpVideoRendering() const #endif } +void MediaPlayerPrivateQuickTimeVisualContext::retrieveAndResetMovieTransform() +{ +#if USE(ACCELERATED_COMPOSITING) + // First things first, reset the total movie transform so that + // we can bail out early: + m_movieTransform = CGAffineTransformIdentity; + + if (!m_movie || !m_movie->hasVideo()) + return; + + // This trick will only work on movies with a single video track, + // so bail out early if the video contains more than one (or zero) + // video tracks. + QTTrackArray videoTracks = m_movie->videoTracks(); + if (videoTracks.size() != 1) + return; + + QTTrack* track = videoTracks[0].get(); + ASSERT(track); + + CGAffineTransform movieTransform = m_movie->getTransform(); + if (!CGAffineTransformEqualToTransform(movieTransform, CGAffineTransformIdentity)) + m_movie->resetTransform(); + + CGAffineTransform trackTransform = track->getTransform(); + if (!CGAffineTransformEqualToTransform(trackTransform, CGAffineTransformIdentity)) + track->resetTransform(); + + // Multiply the two transforms together, taking care to + // do so in the correct order, track * movie = final: + m_movieTransform = CGAffineTransformConcat(trackTransform, movieTransform); +#endif +} + void MediaPlayerPrivateQuickTimeVisualContext::createLayerForMovie() { #if USE(ACCELERATED_COMPOSITING) @@ -1028,17 +1123,35 @@ void MediaPlayerPrivateQuickTimeVisualContext::createLayerForMovie() // Create a GraphicsLayer that won't be inserted directly into the render tree, but will used // as a wrapper for a WKCACFLayer which gets inserted as the content layer of the video // renderer's GraphicsLayer. - m_qtVideoLayer.set(new GraphicsLayerCACF(m_layerClient.get())); - if (!m_qtVideoLayer) + m_transformLayer.set(new GraphicsLayerCACF(m_layerClient.get())); + if (!m_transformLayer) return; // Mark the layer as drawing itself, anchored in the top left, and bottom-up. - m_qtVideoLayer->setDrawsContent(true); - m_qtVideoLayer->setAnchorPoint(FloatPoint3D()); - m_qtVideoLayer->setContentsOrientation(GraphicsLayer::CompositingCoordinatesBottomUp); + m_transformLayer->setDrawsContent(false); + m_transformLayer->setAnchorPoint(FloatPoint3D()); + m_transformLayer->setContentsOrientation(GraphicsLayer::CompositingCoordinatesBottomUp); + m_transformLayer->platformLayer()->setLayoutClient(m_layoutClient.get()); + + m_qtVideoLayer = WKCACFLayer::create(WKCACFLayer::Layer); + if (!m_qtVideoLayer) + return; + + if (CGAffineTransformEqualToTransform(m_movieTransform, CGAffineTransformIdentity)) + retrieveAndResetMovieTransform(); + CGAffineTransform t = m_movieTransform; + + // Remove the translation portion of the transform, since we will always rotate about + // the layer's center point. In our limited use-case (a single video track), this is + // safe: + t.tx = t.ty = 0; + m_qtVideoLayer->setTransform(CATransform3DMakeAffineTransform(t)); + #ifndef NDEBUG m_qtVideoLayer->setName("Video layer"); #endif + m_transformLayer->platformLayer()->addSublayer(m_qtVideoLayer.get()); + m_transformLayer->platformLayer()->setNeedsLayout(); // The layer will get hooked up via RenderLayerBacking::updateGraphicsLayerConfiguration(). #endif @@ -1052,8 +1165,13 @@ void MediaPlayerPrivateQuickTimeVisualContext::createLayerForMovie() void MediaPlayerPrivateQuickTimeVisualContext::destroyLayerForMovie() { #if USE(ACCELERATED_COMPOSITING) - if (m_qtVideoLayer) + if (m_qtVideoLayer) { + m_qtVideoLayer->removeFromSuperlayer(); m_qtVideoLayer = 0; + } + + if (m_transformLayer) + m_transformLayer = 0; if (m_imageQueue) m_imageQueue = 0; diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h index 9c449dd..272b90f 100644 --- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h +++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h @@ -50,6 +50,7 @@ class IntSize; class IntRect; #if USE(ACCELERATED_COMPOSITING) +class WKCACFLayer; class WKCAImageQueue; #endif @@ -154,17 +155,25 @@ private: class LayerClient; friend class LayerClient; OwnPtr<LayerClient> m_layerClient; + + class LayoutClient; + friend class LayoutClient; + OwnPtr<LayoutClient> m_layoutClient; #endif class VisualContextClient; friend class VisualContextClient; OwnPtr<VisualContextClient> m_visualContextClient; + void retrieveAndResetMovieTransform(); + MediaPlayer* m_player; RefPtr<QTMovie> m_movie; #if USE(ACCELERATED_COMPOSITING) - OwnPtr<GraphicsLayer> m_qtVideoLayer; + RefPtr<WKCACFLayer> m_qtVideoLayer; + OwnPtr<GraphicsLayer> m_transformLayer; OwnPtr<WKCAImageQueue> m_imageQueue; + CGAffineTransform m_movieTransform; #endif RefPtr<QTMovieVisualContext> m_visualContext; float m_seekTo; @@ -185,6 +194,7 @@ private: double m_timeStartedPlaying; double m_timeStoppedPlaying; #endif + }; } diff --git a/WebCore/platform/graphics/win/QTMovie.cpp b/WebCore/platform/graphics/win/QTMovie.cpp index cc1349a..375d8c2 100644 --- a/WebCore/platform/graphics/win/QTMovie.cpp +++ b/WebCore/platform/graphics/win/QTMovie.cpp @@ -28,6 +28,7 @@ #include "QTMovieTask.h" #include "QTMovieWinTimer.h" +#include <FixMath.h> #include <GXMath.h> #include <Movies.h> #include <QTML.h> @@ -279,6 +280,16 @@ QTMovie::~QTMovie() delete m_private; } +void QTMovie::disableComponent(uint32_t cd[5]) +{ + ComponentDescription nullDesc = {'null', 'base', kAppleManufacturer, 0, 0}; + Component nullComp = FindNextComponent(0, &nullDesc); + Component disabledComp = 0; + + while (disabledComp = FindNextComponent(disabledComp, (ComponentDescription*)&cd[0])) + CaptureComponent(disabledComp, nullComp); +} + void QTMovie::addClient(QTMovieClient* client) { if (client) @@ -696,6 +707,16 @@ bool QTMovie::hasAudio() const return (GetMovieIndTrackType(m_private->m_movie, 1, AudioMediaCharacteristic, movieTrackCharacteristic | movieTrackEnabledOnly)); } +QTTrackArray QTMovie::videoTracks() const +{ + QTTrackArray tracks; + long trackIndex = 1; + + while (Track theTrack = GetMovieIndTrackType(m_private->m_movie, trackIndex++, VisualMediaCharacteristic, movieTrackCharacteristic | movieTrackEnabledOnly)) + tracks.append(QTTrack::create(theTrack)); + + return tracks; +} bool QTMovie::hasClosedCaptions() const { @@ -830,6 +851,45 @@ void QTMovie::getSupportedType(unsigned index, const UChar*& str, unsigned& len) } +CGAffineTransform QTMovie::getTransform() const +{ + ASSERT(m_private->m_movie); + MatrixRecord m = {0}; + GetMovieMatrix(m_private->m_movie, &m); + + ASSERT(!m.matrix[0][2]); + ASSERT(!m.matrix[1][2]); + CGAffineTransform transform = CGAffineTransformMake( + Fix2X(m.matrix[0][0]), + Fix2X(m.matrix[0][1]), + Fix2X(m.matrix[1][0]), + Fix2X(m.matrix[1][1]), + Fix2X(m.matrix[2][0]), + Fix2X(m.matrix[2][1])); + return transform; +} + +void QTMovie::setTransform(CGAffineTransform t) +{ + ASSERT(m_private->m_movie); + MatrixRecord m = {{ + {X2Fix(t.a), X2Fix(t.b), 0}, + {X2Fix(t.c), X2Fix(t.d), 0}, + {X2Fix(t.tx), X2Fix(t.ty), fract1}, + }}; + + SetMovieMatrix(m_private->m_movie, &m); + m_private->cacheMovieScale(); +} + +void QTMovie::resetTransform() +{ + ASSERT(m_private->m_movie); + SetMovieMatrix(m_private->m_movie, 0); + m_private->cacheMovieScale(); +} + + bool QTMovie::initializeQuickTime() { static bool initialized = false; diff --git a/WebCore/platform/graphics/win/QTMovie.h b/WebCore/platform/graphics/win/QTMovie.h index 8fa4b6e..e205b68 100644 --- a/WebCore/platform/graphics/win/QTMovie.h +++ b/WebCore/platform/graphics/win/QTMovie.h @@ -26,9 +26,8 @@ #ifndef QTMovie_h #define QTMovie_h -#include <Unicode.h> -#include <windows.h> -#include <wtf/RefCounted.h> +#include "QTTrack.h" +#include <WTF/Vector.h> #ifdef QTMOVIEWIN_EXPORTS #define QTMOVIEWIN_API __declspec(dllexport) @@ -39,6 +38,7 @@ class QTMovie; class QTMoviePrivate; typedef struct MovieType** Movie; +typedef Vector<RefPtr<QTTrack>> QTTrackArray; class QTMovieClient { public: @@ -62,6 +62,8 @@ public: static bool initializeQuickTime(); static void taskTimerFired(); + static void disableComponent(uint32_t[5]); + QTMovie(QTMovieClient*); ~QTMovie(); @@ -99,12 +101,18 @@ public: bool hasVideo() const; bool hasAudio() const; + QTTrackArray videoTracks() const; + bool hasClosedCaptions() const; void setClosedCaptionsVisible(bool); static unsigned countSupportedTypes(); static void getSupportedType(unsigned index, const UChar*& str, unsigned& len); + CGAffineTransform getTransform() const; + void setTransform(CGAffineTransform); + void resetTransform(); + Movie getMovieHandle() const; private: diff --git a/WebCore/platform/graphics/win/QTTrack.cpp b/WebCore/platform/graphics/win/QTTrack.cpp new file mode 100644 index 0000000..09142bc --- /dev/null +++ b/WebCore/platform/graphics/win/QTTrack.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2007, 2008, 2009, 2010 Apple, 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. + * + * 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 "QTTrack.h" + +#include <Movies.h> +#include <QTML.h> + +using namespace std; + +class QTTrackPrivate : public Noncopyable { +public: + QTTrackPrivate(); + ~QTTrackPrivate(); + + QTTrack* m_track; + Track m_trackHandle; +}; + +QTTrackPrivate::QTTrackPrivate() + : m_track(0) + , m_trackHandle(0) +{ +} + +QTTrackPrivate::~QTTrackPrivate() +{ + m_trackHandle = 0; +} + +PassRefPtr<QTTrack> QTTrack::create(Track trackHandle) +{ + return adoptRef(new QTTrack(trackHandle)); +} + +QTTrack::QTTrack(Track trackHandle) + : m_private(new QTTrackPrivate()) +{ + m_private->m_track = this; + m_private->m_trackHandle = trackHandle; +} + +QTTrack::~QTTrack() +{ + delete m_private; +} + +bool QTTrack::isEnabled() const +{ + ASSERT(m_private->m_track); + return GetTrackEnabled(m_private->m_trackHandle); +} + +void QTTrack::setEnabled(bool enabled) +{ + ASSERT(m_private->m_trackHandle); + SetTrackEnabled(m_private->m_trackHandle, enabled); +} + +CGAffineTransform QTTrack::getTransform() const +{ + ASSERT(m_private->m_trackHandle); + MatrixRecord m = {0}; + GetTrackMatrix(m_private->m_trackHandle, &m); + + ASSERT(!m.matrix[0][2]); + ASSERT(!m.matrix[1][2]); + CGAffineTransform transform = CGAffineTransformMake( + Fix2X(m.matrix[0][0]), + Fix2X(m.matrix[0][1]), + Fix2X(m.matrix[1][0]), + Fix2X(m.matrix[1][1]), + Fix2X(m.matrix[2][0]), + Fix2X(m.matrix[2][1])); + + return transform; +} + +void QTTrack::setTransform(CGAffineTransform t) +{ + ASSERT(m_private->m_trackHandle); + MatrixRecord m = {{ + {X2Fix(t.a), X2Fix(t.b), 0}, + {X2Fix(t.c), X2Fix(t.d), 0}, + {X2Fix(t.tx), X2Fix(t.ty), fract1}, + }}; + + SetTrackMatrix(m_private->m_trackHandle, &m); +} + +void QTTrack::resetTransform() +{ + ASSERT(m_private->m_trackHandle); + SetTrackMatrix(m_private->m_trackHandle, 0); +} + diff --git a/WebCore/platform/graphics/win/QTTrack.h b/WebCore/platform/graphics/win/QTTrack.h new file mode 100644 index 0000000..bda5644 --- /dev/null +++ b/WebCore/platform/graphics/win/QTTrack.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2007, 2008, 2009, 2010 Apple, 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. + * + * 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. + */ + +#ifndef QTTrack_h +#define QTTrack_h + +#include <Unicode.h> +#include <windows.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +// We must include this after <Unicode.h>, or the definition of OSErr will change: +#include <CoreGraphics/CGAffineTransform.h> + +#ifdef QTMOVIEWIN_EXPORTS +#define QTMOVIEWIN_API __declspec(dllexport) +#else +#define QTMOVIEWIN_API __declspec(dllimport) +#endif + +class QTTrack; +class QTTrackPrivate; +typedef struct TrackType** Track; + +class QTMOVIEWIN_API QTTrack : public RefCounted<QTTrack> { +public: + static PassRefPtr<QTTrack> create(Track); + ~QTTrack(); + + CGAffineTransform getTransform() const; + void setTransform(CGAffineTransform); + void resetTransform(); + + bool isEnabled() const; + void setEnabled(bool); + + Track getTrackHandle() const; +private: + QTTrack(Track); + QTTrackPrivate* m_private; + friend class QTTrackPrivate; +}; + +#endif diff --git a/WebCore/platform/graphics/win/WKCACFLayer.cpp b/WebCore/platform/graphics/win/WKCACFLayer.cpp index bbe5883..bf47925 100644 --- a/WebCore/platform/graphics/win/WKCACFLayer.cpp +++ b/WebCore/platform/graphics/win/WKCACFLayer.cpp @@ -355,6 +355,9 @@ void WKCACFLayer::setBounds(const CGRect& rect) if (m_needsDisplayOnBoundsChange) setNeedsDisplay(); + + if (m_layoutClient) + setNeedsLayout(); } void WKCACFLayer::setFrame(const CGRect& rect) @@ -368,6 +371,9 @@ void WKCACFLayer::setFrame(const CGRect& rect) if (m_needsDisplayOnBoundsChange && !CGSizeEqualToSize(rect.size, oldFrame.size)) setNeedsDisplay(); + + if (m_layoutClient) + setNeedsLayout(); } void WKCACFLayer::setContentsGravity(ContentsGravityType type) diff --git a/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp b/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp index 630a8af..4f39b13 100644..100755 --- a/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp +++ b/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp @@ -226,15 +226,11 @@ WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client) : m_client(client) , m_mightBeAbleToCreateDeviceLater(true) , m_rootLayer(WKCACFRootLayer::create(this)) - , m_scrollLayer(WKCACFLayer::create(WKCACFLayer::Layer)) - , m_clipLayer(WKCACFLayer::create(WKCACFLayer::Layer)) , m_context(AdoptCF, CACFContextCreate(0)) , m_renderContext(static_cast<CARenderContext*>(CACFContextGetRenderContext(m_context.get()))) , m_renderer(0) , m_hostWindow(0) , m_renderTimer(this, &WKCACFLayerRenderer::renderTimerFired) - , m_scrollPosition(0, 0) - , m_scrollSize(1, 1) , m_backingStoreDirty(false) , m_mustResetLostDeviceBeforeRendering(false) { @@ -250,15 +246,8 @@ WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client) // Scrolling will affect only the position of the scroll layer without affecting the bounds. m_rootLayer->setName("WKCACFLayerRenderer rootLayer"); - m_clipLayer->setName("WKCACFLayerRenderer clipLayer"); - m_scrollLayer->setName("WKCACFLayerRenderer scrollLayer"); - - m_rootLayer->addSublayer(m_clipLayer); - m_clipLayer->addSublayer(m_scrollLayer); - m_clipLayer->setMasksToBounds(true); m_rootLayer->setAnchorPoint(CGPointMake(0, 0)); - m_scrollLayer->setAnchorPoint(CGPointMake(0, 1)); - m_clipLayer->setAnchorPoint(CGPointMake(0, 1)); + m_rootLayer->setGeometryFlipped(true); #ifndef NDEBUG CGColorRef debugColor = createCGColor(Color(255, 0, 0, 204)); @@ -285,26 +274,6 @@ WKCACFLayer* WKCACFLayerRenderer::rootLayer() const return m_rootLayer.get(); } -void WKCACFLayerRenderer::setScrollFrame(const IntPoint& position, const IntSize& size) -{ - m_scrollSize = size; - m_scrollPosition = position; - - updateScrollFrame(); -} - -void WKCACFLayerRenderer::updateScrollFrame() -{ - CGRect frameBounds = bounds(); - m_clipLayer->setBounds(CGRectMake(0, 0, m_scrollSize.width(), m_scrollSize.height())); - m_clipLayer->setPosition(CGPointMake(0, frameBounds.size.height)); - if (m_rootChildLayer) { - CGRect rootBounds = m_rootChildLayer->bounds(); - m_scrollLayer->setBounds(rootBounds); - } - m_scrollLayer->setPosition(CGPointMake(-m_scrollPosition.x(), m_scrollPosition.y() + m_scrollSize.height())); -} - void WKCACFLayerRenderer::setRootContents(CGImageRef image) { ASSERT(m_rootLayer); @@ -321,16 +290,10 @@ void WKCACFLayerRenderer::setRootContentsAndDisplay(CGImageRef image) void WKCACFLayerRenderer::setRootChildLayer(WKCACFLayer* layer) { - if (!m_scrollLayer) - return; - - m_scrollLayer->removeAllSublayers(); + m_rootLayer->removeAllSublayers(); m_rootChildLayer = layer; - if (layer) { - m_scrollLayer->addSublayer(layer); - // Adjust the scroll frame accordingly - updateScrollFrame(); - } + if (m_rootChildLayer) + m_rootLayer->addSublayer(m_rootChildLayer); } void WKCACFLayerRenderer::layerTreeDidChange() @@ -435,8 +398,6 @@ void WKCACFLayerRenderer::destroyRenderer() s_d3d = 0; m_rootLayer = 0; - m_clipLayer = 0; - m_scrollLayer = 0; m_rootChildLayer = 0; m_mightBeAbleToCreateDeviceLater = true; @@ -454,7 +415,6 @@ void WKCACFLayerRenderer::resize() if (m_rootLayer) { m_rootLayer->setBounds(bounds()); WKCACFContextFlusher::shared().flushAllContexts(); - updateScrollFrame(); } } diff --git a/WebCore/platform/graphics/win/WKCACFLayerRenderer.h b/WebCore/platform/graphics/win/WKCACFLayerRenderer.h index 2647c5f..1d73b99 100644..100755 --- a/WebCore/platform/graphics/win/WKCACFLayerRenderer.h +++ b/WebCore/platform/graphics/win/WKCACFLayerRenderer.h @@ -66,7 +66,6 @@ public: static bool acceleratedCompositingAvailable(); static void didFlushContext(CACFContextRef); - void setScrollFrame(const IntPoint&, const IntSize&); void setRootContents(CGImageRef); void setRootContentsAndDisplay(CGImageRef); void setRootChildLayer(WKCACFLayer* layer); @@ -78,7 +77,6 @@ public: void destroyRenderer(); void resize(); void renderSoon(); - void updateScrollFrame(); protected: WKCACFLayer* rootLayer() const; @@ -105,16 +103,12 @@ private: bool m_mightBeAbleToCreateDeviceLater; COMPtr<IDirect3DDevice9> m_d3dDevice; RefPtr<WKCACFRootLayer> m_rootLayer; - RefPtr<WKCACFLayer> m_scrollLayer; RefPtr<WKCACFLayer> m_rootChildLayer; - RefPtr<WKCACFLayer> m_clipLayer; RetainPtr<CACFContextRef> m_context; CARenderContext* m_renderContext; CARenderOGLContext* m_renderer; HWND m_hostWindow; Timer<WKCACFLayerRenderer> m_renderTimer; - IntPoint m_scrollPosition; - IntSize m_scrollSize; bool m_backingStoreDirty; bool m_mustResetLostDeviceBeforeRendering; #ifndef NDEBUG diff --git a/WebCore/platform/graphics/win/WebLayer.cpp b/WebCore/platform/graphics/win/WebLayer.cpp index 70a522d..70a522d 100755..100644 --- a/WebCore/platform/graphics/win/WebLayer.cpp +++ b/WebCore/platform/graphics/win/WebLayer.cpp diff --git a/WebCore/platform/graphics/win/WebTiledLayer.cpp b/WebCore/platform/graphics/win/WebTiledLayer.cpp index 01dd6ae..01dd6ae 100755..100644 --- a/WebCore/platform/graphics/win/WebTiledLayer.cpp +++ b/WebCore/platform/graphics/win/WebTiledLayer.cpp |