diff options
Diffstat (limited to 'WebCore/platform/graphics/win')
19 files changed, 224 insertions, 111 deletions
diff --git a/WebCore/platform/graphics/win/FontCGWin.cpp b/WebCore/platform/graphics/win/FontCGWin.cpp index c6437f2..2f1fb41 100644 --- a/WebCore/platform/graphics/win/FontCGWin.cpp +++ b/WebCore/platform/graphics/win/FontCGWin.cpp @@ -360,14 +360,14 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* fo graphicsContext->clearShadow(); Color fillColor = graphicsContext->fillColor(); Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255); - graphicsContext->setFillColor(shadowFillColor, DeviceColorSpace); + graphicsContext->setFillColor(shadowFillColor, ColorSpaceDeviceRGB); CGContextSetTextPosition(cgContext, point.x() + translation.width() + shadowOffset.width(), point.y() + translation.height() + shadowOffset.height()); CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs); if (font->syntheticBoldOffset()) { CGContextSetTextPosition(cgContext, point.x() + translation.width() + shadowOffset.width() + font->syntheticBoldOffset(), point.y() + translation.height() + shadowOffset.height()); CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs); } - graphicsContext->setFillColor(fillColor, DeviceColorSpace); + graphicsContext->setFillColor(fillColor, ColorSpaceDeviceRGB); } CGContextSetTextPosition(cgContext, point.x() + translation.width(), point.y() + translation.height()); @@ -378,7 +378,7 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* fo } if (hasSimpleShadow) - graphicsContext->setShadow(shadowOffset, shadowBlur, shadowColor, DeviceColorSpace); + graphicsContext->setShadow(shadowOffset, shadowBlur, shadowColor, ColorSpaceDeviceRGB); wkRestoreFontSmoothingStyle(cgContext, oldFontSmoothingStyle); } diff --git a/WebCore/platform/graphics/win/GDIExtras.cpp b/WebCore/platform/graphics/win/GDIExtras.cpp new file mode 100644 index 0000000..4bd95da --- /dev/null +++ b/WebCore/platform/graphics/win/GDIExtras.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.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 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 "GDIExtras.h" + +#include "SoftLinking.h" + +namespace WebCore { + +#if OS(WINCE) +SOFT_LINK_LIBRARY(coredll) +SOFT_LINK_OPTIONAL(coredll, AlphaBlend, BOOL, APIENTRY, (HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, + int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction)) + +AlphaBlendPointerType AlphaBlendPointer() +{ + return AlphaBlendPtr(); +} +#endif + +} // namespace WebCore diff --git a/WebCore/platform/graphics/win/GDIExtras.h b/WebCore/platform/graphics/win/GDIExtras.h new file mode 100644 index 0000000..0166124 --- /dev/null +++ b/WebCore/platform/graphics/win/GDIExtras.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.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 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 GDIExtras_h +#define GDIExtras_h + +#include <windows.h> + +namespace WebCore { + +typedef BOOL (APIENTRY *AlphaBlendPointerType) (HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, + int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction); + +#if OS(WINCE) +AlphaBlendPointerType AlphaBlendPointer(); +#endif + +inline bool hasAlphaBlendSupport() +{ +#if OS(WINCE) + return AlphaBlendPointer(); +#else + return true; +#endif +} + +inline bool alphaBlendIfSupported(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, + int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction) +{ +#if OS(WINCE) + AlphaBlendPointerType alphaBlendPointer = AlphaBlendPointer(); + if (!alphaBlendPointer) + return false; + + alphaBlendPointer(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, blendFunction); +#else + AlphaBlend(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, blendFunction); +#endif + return true; +} + +} // namespace WebCore + +#endif // GDIExtras_h diff --git a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp index 0203d42..c9288e5 100644 --- a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp +++ b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 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 @@ -70,8 +70,8 @@ GraphicsContext::GraphicsContext(HDC hdc, bool hasAlpha) setPaintingDisabled(!m_data->m_cgContext); if (m_data->m_cgContext) { // Make sure the context starts in sync with our state. - setPlatformFillColor(fillColor(), DeviceColorSpace); - setPlatformStrokeColor(strokeColor(), DeviceColorSpace); + setPlatformFillColor(fillColor(), ColorSpaceDeviceRGB); + setPlatformStrokeColor(strokeColor(), ColorSpaceDeviceRGB); } } @@ -129,6 +129,8 @@ void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int of // FIXME: implement } +// FIXME: This is nearly identical to the GraphicsContext::drawFocusRing function in GraphicsContextMac.mm. +// The code could move to GraphicsContextCG.cpp and be shared. void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color) { if (paintingDisabled()) @@ -136,7 +138,7 @@ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int float radius = (width - 1) / 2.0f; offset += radius; - CGColorRef colorRef = color.isValid() ? createCGColor(color) : 0; + CGColorRef colorRef = color.isValid() ? cachedCGColor(color, ColorSpaceDeviceRGB) : 0; CGMutablePathRef focusRingPath = CGPathCreateMutable(); unsigned rectCount = rects.size(); @@ -151,8 +153,6 @@ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int wkDrawFocusRing(context, colorRef, radius); - CGColorRelease(colorRef); - CGPathRelease(focusRingPath); CGContextRestoreGState(context); diff --git a/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp b/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp index dad5da1..f7674db 100644 --- a/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp +++ b/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp @@ -99,9 +99,7 @@ TransformationMatrix CAToTransform3D(const CATransform3D& fromT3D) static void setLayerBorderColor(WKCACFLayer* layer, const Color& color) { - CGColorRef borderColor = createCGColor(color); - layer->setBorderColor(borderColor); - CGColorRelease(borderColor); + layer->setBorderColor(cachedCGColor(color, ColorSpaceDeviceRGB)); } static void clearBorderColor(WKCACFLayer* layer) @@ -111,9 +109,7 @@ static void clearBorderColor(WKCACFLayer* layer) static void setLayerBackgroundColor(WKCACFLayer* layer, const Color& color) { - CGColorRef bgColor = createCGColor(color); - layer->setBackgroundColor(bgColor); - CGColorRelease(bgColor); + layer->setBackgroundColor(cachedCGColor(color, ColorSpaceDeviceRGB)); } static void clearLayerBackgroundColor(WKCACFLayer* layer) diff --git a/WebCore/platform/graphics/win/ImageCGWin.cpp b/WebCore/platform/graphics/win/ImageCGWin.cpp index a0fbba7..e65b859 100644 --- a/WebCore/platform/graphics/win/ImageCGWin.cpp +++ b/WebCore/platform/graphics/win/ImageCGWin.cpp @@ -78,9 +78,9 @@ bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size) IntSize imageSize = BitmapImage::size(); if (size) - drawFrameMatchingSourceSize(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), DeviceColorSpace, CompositeCopy); + drawFrameMatchingSourceSize(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), ColorSpaceDeviceRGB, CompositeCopy); else - draw(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), DeviceColorSpace, CompositeCopy); + draw(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, CompositeCopy); // Do cleanup CGContextRelease(cgContext); diff --git a/WebCore/platform/graphics/win/ImageCairoWin.cpp b/WebCore/platform/graphics/win/ImageCairoWin.cpp index e3c5ea0..70b132e 100644 --- a/WebCore/platform/graphics/win/ImageCairoWin.cpp +++ b/WebCore/platform/graphics/win/ImageCairoWin.cpp @@ -82,9 +82,9 @@ bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size) IntSize imageSize = BitmapImage::size(); if (size) - drawFrameMatchingSourceSize(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), DeviceColorSpace, CompositeCopy); + drawFrameMatchingSourceSize(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), ColorSpaceDeviceRGB, CompositeCopy); else - draw(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), DeviceColorSpace, CompositeCopy); + draw(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, CompositeCopy); // Do cleanup cairo_destroy(targetRef); @@ -100,7 +100,7 @@ void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext* ctxt, const Float if (cairo_image_surface_get_height(image) == static_cast<size_t>(srcSize.height()) && cairo_image_surface_get_width(image) == static_cast<size_t>(srcSize.width())) { size_t currentFrame = m_currentFrame; m_currentFrame = i; - draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), DeviceColorSpace, compositeOp); + draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), ColorSpaceDeviceRGB, compositeOp); m_currentFrame = currentFrame; return; } @@ -108,7 +108,7 @@ void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext* ctxt, const Float // No image of the correct size was found, fallback to drawing the current frame IntSize imageSize = BitmapImage::size(); - draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), DeviceColorSpace, compositeOp); + draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, compositeOp); } } // namespace WebCore diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp index 4a7e45e..4a7e45e 100755..100644 --- a/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp +++ b/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp index 354e0bf..1b4f1d9 100644 --- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp +++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp @@ -42,7 +42,6 @@ #include "ScrollView.h" #include "Settings.h" #include "SoftLinking.h" -#include "StringBuilder.h" #include "TimeRanges.h" #include "Timer.h" #include <AssertMacros.h> @@ -53,6 +52,7 @@ #include <wtf/MainThread.h> #include <wtf/MathExtras.h> #include <wtf/StdLibExtras.h> +#include <wtf/text/StringBuilder.h> #include <wtf/text/StringHash.h> #if USE(ACCELERATED_COMPOSITING) @@ -174,6 +174,8 @@ MediaPlayerPrivateQuickTimeVisualContext::MediaPlayerPrivateQuickTimeVisualConte , m_movieTransform(CGAffineTransformIdentity) #endif , m_visualContextClient(new MediaPlayerPrivateQuickTimeVisualContext::VisualContextClient(this)) + , m_delayingLoad(false) + , m_preload(MediaPlayer::Auto) { } @@ -241,7 +243,7 @@ static void addCookieParam(StringBuilder& cookieBuilder, const String& name, con // Add parameter name, and value if there is one. cookieBuilder.append(name); if (!value.isEmpty()) { - cookieBuilder.append("="); + cookieBuilder.append('='); cookieBuilder.append(value); } } @@ -275,7 +277,7 @@ void MediaPlayerPrivateQuickTimeVisualContext::setUpCookiesForQuickTime(const St addCookieParam(cookieBuilder, "expires", rfc2616DateStringFromTime(cookie.expires)); if (cookie.httpOnly) addCookieParam(cookieBuilder, "httpOnly", String()); - cookieBuilder.append(";"); + cookieBuilder.append(';'); String cookieURL; if (!cookie.domain.isEmpty()) { @@ -316,8 +318,28 @@ static void disableComponentsOnce() QTMovie::disableComponent(componentsToDisable[i]); } +void MediaPlayerPrivateQuickTimeVisualContext::resumeLoad() +{ + m_delayingLoad = false; + + if (!m_movieURL.isEmpty()) + loadInternal(m_movieURL); +} + void MediaPlayerPrivateQuickTimeVisualContext::load(const String& url) { + m_movieURL = url; + + if (m_preload == MediaPlayer::None) { + m_delayingLoad = true; + return; + } + + loadInternal(url); +} + +void MediaPlayerPrivateQuickTimeVisualContext::loadInternal(const String& url) +{ if (!QTMovie::initializeQuickTime()) { // FIXME: is this the right error to return? m_networkState = MediaPlayer::DecodeError; @@ -347,6 +369,12 @@ void MediaPlayerPrivateQuickTimeVisualContext::load(const String& url) m_movie->setVolume(m_player->volume()); } +void MediaPlayerPrivateQuickTimeVisualContext::prepareToPlay() +{ + if (!m_movie || m_delayingLoad) + resumeLoad(); +} + void MediaPlayerPrivateQuickTimeVisualContext::play() { if (!m_movie) @@ -1005,6 +1033,13 @@ bool MediaPlayerPrivateQuickTimeVisualContext::hasSingleSecurityOrigin() const return true; } +void MediaPlayerPrivateQuickTimeVisualContext::setPreload(MediaPlayer::Preload preload) +{ + m_preload = preload; + if (m_delayingLoad && m_preload != MediaPlayer::None) + resumeLoad(); +} + MediaPlayerPrivateQuickTimeVisualContext::MediaRenderingMode MediaPlayerPrivateQuickTimeVisualContext::currentRenderingMode() const { if (!m_movie) diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h index 272b90f..4c62558 100644 --- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h +++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h @@ -74,9 +74,12 @@ private: void load(const String& url); void cancelLoad(); + void loadInternal(const String& url); + void resumeLoad(); void play(); void pause(); + void prepareToPlay(); bool paused() const; bool seeking() const; @@ -111,6 +114,8 @@ private: bool hasClosedCaptions() const; void setClosedCaptionsVisible(bool); + void setPreload(MediaPlayer::Preload); + void updateStates(); void doSeek(); void cancelSeek(); @@ -189,6 +194,9 @@ private: bool m_isStreaming; bool m_visible; bool m_newFrameAvailable; + bool m_delayingLoad; + String m_movieURL; + MediaPlayer::Preload m_preload; #if DRAW_FRAME_RATE double m_frameCountWhilePlaying; double m_timeStartedPlaying; diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp index c37f5d5..39e8a11 100644 --- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp +++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp @@ -38,7 +38,6 @@ #include "QTMovieTask.h" #include "ScrollView.h" #include "SoftLinking.h" -#include "StringBuilder.h" #include "TimeRanges.h" #include "Timer.h" #include <Wininet.h> @@ -46,6 +45,7 @@ #include <wtf/HashSet.h> #include <wtf/MathExtras.h> #include <wtf/StdLibExtras.h> +#include <wtf/text/StringBuilder.h> #include <wtf/text/StringHash.h> #if USE(ACCELERATED_COMPOSITING) @@ -159,7 +159,7 @@ static void addCookieParam(StringBuilder& cookieBuilder, const String& name, con // Add parameter name, and value if there is one. cookieBuilder.append(name); if (!value.isEmpty()) { - cookieBuilder.append("="); + cookieBuilder.append('='); cookieBuilder.append(value); } } @@ -194,7 +194,7 @@ void MediaPlayerPrivate::setUpCookiesForQuickTime(const String& url) addCookieParam(cookieBuilder, "expires", rfc2616DateStringFromTime(cookie.expires)); if (cookie.httpOnly) addCookieParam(cookieBuilder, "httpOnly", String()); - cookieBuilder.append(";"); + cookieBuilder.append(';'); String cookieURL; if (!cookie.domain.isEmpty()) { diff --git a/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp b/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp index 1685a30..d75c854 100644 --- a/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp +++ b/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp @@ -29,8 +29,8 @@ #include "WKCACFContextFlusher.h" +#include <WebKitSystemInterface/WebKitSystemInterface.h> #include <wtf/StdLibExtras.h> -#include <QuartzCore/CACFContext.h> namespace WebCore { @@ -48,24 +48,18 @@ WKCACFContextFlusher::~WKCACFContextFlusher() { } -void WKCACFContextFlusher::addContext(CACFContextRef context) +void WKCACFContextFlusher::addContext(WKCACFContext* context) { ASSERT(context); - if (m_contexts.add(context).second) - CFRetain(context); + m_contexts.add(context); } -void WKCACFContextFlusher::removeContext(CACFContextRef context) +void WKCACFContextFlusher::removeContext(WKCACFContext* context) { ASSERT(context); - ContextSet::iterator found = m_contexts.find(context); - if (found == m_contexts.end()) - return; - - CFRelease(*found); - m_contexts.remove(found); + m_contexts.remove(context); } void WKCACFContextFlusher::flushAllContexts() @@ -76,11 +70,8 @@ void WKCACFContextFlusher::flushAllContexts() contextsToFlush.swap(m_contexts); ContextSet::const_iterator end = contextsToFlush.end(); - for (ContextSet::const_iterator it = contextsToFlush.begin(); it != end; ++it) { - CACFContextRef context = *it; - CACFContextFlush(context); - CFRelease(context); - } + for (ContextSet::const_iterator it = contextsToFlush.begin(); it != end; ++it) + wkCACFContextFlush(*it); } } diff --git a/WebCore/platform/graphics/win/WKCACFContextFlusher.h b/WebCore/platform/graphics/win/WKCACFContextFlusher.h index 9ce76aa..17ec41d 100644 --- a/WebCore/platform/graphics/win/WKCACFContextFlusher.h +++ b/WebCore/platform/graphics/win/WKCACFContextFlusher.h @@ -32,7 +32,7 @@ #include <wtf/HashSet.h> -typedef struct _CACFContext* CACFContextRef; +struct WKCACFContext; namespace WebCore { @@ -40,8 +40,8 @@ class WKCACFContextFlusher : public Noncopyable { public: static WKCACFContextFlusher& shared(); - void addContext(CACFContextRef); - void removeContext(CACFContextRef); + void addContext(WKCACFContext*); + void removeContext(WKCACFContext*); void flushAllContexts(); @@ -49,7 +49,7 @@ private: WKCACFContextFlusher(); ~WKCACFContextFlusher(); - typedef HashSet<CACFContextRef> ContextSet; + typedef HashSet<WKCACFContext*> ContextSet; ContextSet m_contexts; }; diff --git a/WebCore/platform/graphics/win/WKCACFLayer.cpp b/WebCore/platform/graphics/win/WKCACFLayer.cpp index bf47925..a8714e3 100644 --- a/WebCore/platform/graphics/win/WKCACFLayer.cpp +++ b/WebCore/platform/graphics/win/WKCACFLayer.cpp @@ -30,15 +30,10 @@ #include "WKCACFLayer.h" #include "WKCACFLayerRenderer.h" -#include <wtf/text/CString.h> - +#include <WebKitSystemInterface/WebKitSystemInterface.h> #include <stdio.h> -#include <QuartzCore/CACFContext.h> -#include <QuartzCore/CARender.h> - -#ifndef NDEBUG #include <wtf/CurrentTime.h> -#endif +#include <wtf/text/CString.h> namespace WebCore { @@ -190,9 +185,9 @@ WKCACFLayer::~WKCACFLayer() CACFLayerSetDisplayCallback(layer(), 0); } -void WKCACFLayer::becomeRootLayerForContext(CACFContextRef context) +void WKCACFLayer::becomeRootLayerForContext(WKCACFContext* context) { - CACFContextSetLayer(context, layer()); + wkCACFContextSetLayer(context, layer()); setNeedsCommit(); } diff --git a/WebCore/platform/graphics/win/WKCACFLayer.h b/WebCore/platform/graphics/win/WKCACFLayer.h index 7243508..4c6639a 100644 --- a/WebCore/platform/graphics/win/WKCACFLayer.h +++ b/WebCore/platform/graphics/win/WKCACFLayer.h @@ -41,6 +41,8 @@ #include "PlatformString.h" #include "TransformationMatrix.h" +struct WKCACFContext; + namespace WebCore { class WKCACFLayer; @@ -83,7 +85,7 @@ public: } // Makes this layer the root when the passed context is rendered - void becomeRootLayerForContext(CACFContextRef); + void becomeRootLayerForContext(WKCACFContext*); static RetainPtr<CFTypeRef> cfValue(float value) { return RetainPtr<CFTypeRef>(AdoptCF, CFNumberCreate(0, kCFNumberFloat32Type, &value)); } static RetainPtr<CFTypeRef> cfValue(const TransformationMatrix& value) diff --git a/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp b/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp index 4f39b13..73cb794 100755..100644 --- a/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp +++ b/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp @@ -36,9 +36,7 @@ #include "WKCACFContextFlusher.h" #include "WKCACFLayer.h" #include "WebCoreInstanceHandle.h" -#include <CoreGraphics/CGSRegion.h> -#include <QuartzCore/CACFContext.h> -#include <QuartzCore/CARenderOGL.h> +#include <WebKitSystemInterface/WebKitSystemInterface.h> #include <wtf/HashMap.h> #include <wtf/OwnArrayPtr.h> #include <wtf/OwnPtr.h> @@ -108,7 +106,7 @@ private: WKCACFLayerRenderer* m_renderer; }; -typedef HashMap<CACFContextRef, WKCACFLayerRenderer*> ContextToWindowMap; +typedef HashMap<WKCACFContext*, WKCACFLayerRenderer*> ContextToWindowMap; static ContextToWindowMap& windowsForContexts() { @@ -206,7 +204,7 @@ bool WKCACFLayerRenderer::acceleratedCompositingAvailable() return available; } -void WKCACFLayerRenderer::didFlushContext(CACFContextRef context) +void WKCACFLayerRenderer::didFlushContext(WKCACFContext* context) { WKCACFLayerRenderer* window = windowsForContexts().get(context); if (!window) @@ -226,15 +224,13 @@ WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client) : m_client(client) , m_mightBeAbleToCreateDeviceLater(true) , m_rootLayer(WKCACFRootLayer::create(this)) - , m_context(AdoptCF, CACFContextCreate(0)) - , m_renderContext(static_cast<CARenderContext*>(CACFContextGetRenderContext(m_context.get()))) - , m_renderer(0) + , m_context(wkCACFContextCreate()) , m_hostWindow(0) , m_renderTimer(this, &WKCACFLayerRenderer::renderTimerFired) , m_backingStoreDirty(false) , m_mustResetLostDeviceBeforeRendering(false) { - windowsForContexts().set(m_context.get(), this); + windowsForContexts().set(m_context, this); // Under the root layer, we have a clipping layer to clip the content, // that contains a scroll layer that we use for scrolling the content. @@ -250,13 +246,13 @@ WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client) m_rootLayer->setGeometryFlipped(true); #ifndef NDEBUG - CGColorRef debugColor = createCGColor(Color(255, 0, 0, 204)); + CGColorRef debugColor = CGColorCreateGenericRGB(1, 0, 0, 0.8); m_rootLayer->setBackgroundColor(debugColor); CGColorRelease(debugColor); #endif if (m_context) - m_rootLayer->becomeRootLayerForContext(m_context.get()); + m_rootLayer->becomeRootLayerForContext(m_context); #ifndef NDEBUG char* printTreeFlag = getenv("CA_PRINT_TREE"); @@ -267,6 +263,7 @@ WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client) WKCACFLayerRenderer::~WKCACFLayerRenderer() { destroyRenderer(); + wkCACFContextDestroy(m_context); } WKCACFLayer* WKCACFLayerRenderer::rootLayer() const @@ -298,7 +295,7 @@ void WKCACFLayerRenderer::setRootChildLayer(WKCACFLayer* layer) void WKCACFLayerRenderer::layerTreeDidChange() { - WKCACFContextFlusher::shared().addContext(m_context.get()); + WKCACFContextFlusher::shared().addContext(m_context); renderSoon(); } @@ -373,7 +370,7 @@ bool WKCACFLayerRenderer::createRenderer() initD3DGeometry(); - m_renderer = CARenderOGLNew(&kCARenderDX9Callbacks, m_d3dDevice.get(), 0); + wkCACFContextInitializeD3DDevice(m_context, m_d3dDevice.get()); if (IsWindow(m_hostWindow)) m_rootLayer->setBounds(bounds()); @@ -384,14 +381,10 @@ bool WKCACFLayerRenderer::createRenderer() void WKCACFLayerRenderer::destroyRenderer() { if (m_context) { - CACFContextSetLayer(m_context.get(), 0); - windowsForContexts().remove(m_context.get()); - WKCACFContextFlusher::shared().removeContext(m_context.get()); + windowsForContexts().remove(m_context); + WKCACFContextFlusher::shared().removeContext(m_context); } - if (m_renderer) - CARenderOGLDestroy(m_renderer); - m_renderer = 0; m_d3dDevice = 0; if (s_d3d) s_d3d->Release(); @@ -476,7 +469,7 @@ void WKCACFLayerRenderer::paint() render(dirtyRects); } -void WKCACFLayerRenderer::render(const Vector<CGRect>& dirtyRects) +void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects) { ASSERT(m_d3dDevice); @@ -499,31 +492,21 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& dirtyRects) CFTimeInterval t = CACurrentMediaTime(); // Give the renderer some space to use. This needs to be valid until the - // CARenderUpdateFinish() call below. + // wkCACFContextFinishUpdate() call below. char space[4096]; - CARenderUpdate* u = CARenderUpdateBegin(space, sizeof(space), t, 0, 0, &bounds); - if (!u) + if (!wkCACFContextBeginUpdate(m_context, space, sizeof(space), t, bounds, windowDirtyRects.data(), windowDirtyRects.size())) return; - CARenderContextLock(m_renderContext); - CARenderUpdateAddContext(u, m_renderContext); - CARenderContextUnlock(m_renderContext); - - for (size_t i = 0; i < dirtyRects.size(); ++i) - CARenderUpdateAddRect(u, &dirtyRects[i]); - HRESULT err = S_OK; do { - CGSRegionObj rgn = CARenderUpdateCopyRegion(u); + // FIXME: don't need to clear dirty region if layer tree is opaque. - if (!rgn) + WKCACFUpdateRectEnumerator* e = wkCACFContextCopyUpdateRectEnumerator(m_context); + if (!e) break; - // FIXME: don't need to clear dirty region if layer tree is opaque. - Vector<D3DRECT, 64> rects; - CGSRegionEnumeratorObj e = CGSRegionEnumerator(rgn); - for (const CGRect* r = CGSNextRect(e); r; r = CGSNextRect(e)) { + for (const CGRect* r = wkCACFUpdateRectEnumeratorNextRect(e); r; r = wkCACFUpdateRectEnumeratorNextRect(e)) { D3DRECT rect; rect.x1 = r->origin.x; rect.x2 = rect.x1 + r->size.width; @@ -532,8 +515,7 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& dirtyRects) rects.append(rect); } - CGSReleaseRegionEnumerator(e); - CGSReleaseRegion(rgn); + wkCACFUpdateRectEnumeratorRelease(e); if (rects.isEmpty()) break; @@ -541,13 +523,13 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& dirtyRects) m_d3dDevice->Clear(rects.size(), rects.data(), D3DCLEAR_TARGET, 0, 1.0f, 0); m_d3dDevice->BeginScene(); - CARenderOGLRender(m_renderer, u); + wkCACFContextRenderUpdate(m_context); m_d3dDevice->EndScene(); err = m_d3dDevice->Present(0, 0, 0, 0); if (err == D3DERR_DEVICELOST) { - CARenderUpdateAddRect(u, &bounds); + wkCACFContextAddUpdateRect(m_context, bounds); if (!resetDevice(LostDevice)) { // We can't reset the device right now. Try again soon. renderSoon(); @@ -556,7 +538,7 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& dirtyRects) } } while (err == D3DERR_DEVICELOST); - CARenderUpdateFinish(u); + wkCACFContextFinishUpdate(m_context); #ifndef NDEBUG if (m_printTree) @@ -598,7 +580,7 @@ void WKCACFLayerRenderer::initD3DGeometry() bool WKCACFLayerRenderer::resetDevice(ResetReason reason) { ASSERT(m_d3dDevice); - ASSERT(m_renderContext); + ASSERT(m_context); HRESULT hr = m_d3dDevice->TestCooperativeLevel(); @@ -617,10 +599,10 @@ bool WKCACFLayerRenderer::resetDevice(ResetReason reason) // We can reset the device. - // We have to purge the CARenderOGLContext whenever we reset the IDirect3DDevice9 in order to + // We have to release the context's D3D resrouces whenever we reset the IDirect3DDevice9 in order to // destroy any D3DPOOL_DEFAULT resources that Core Animation has allocated (e.g., textures used // for mask layers). See <http://msdn.microsoft.com/en-us/library/bb174425(v=VS.85).aspx>. - CARenderOGLPurge(m_renderer); + wkCACFContextReleaseD3DResources(m_context); D3DPRESENT_PARAMETERS parameters = initialPresentationParameters(); hr = m_d3dDevice->Reset(¶meters); diff --git a/WebCore/platform/graphics/win/WKCACFLayerRenderer.h b/WebCore/platform/graphics/win/WKCACFLayerRenderer.h index 1d73b99..763fffa 100755..100644 --- a/WebCore/platform/graphics/win/WKCACFLayerRenderer.h +++ b/WebCore/platform/graphics/win/WKCACFLayerRenderer.h @@ -41,9 +41,7 @@ #include <CoreGraphics/CGGeometry.h> interface IDirect3DDevice9; -typedef struct _CACFContext* CACFContextRef; -typedef struct _CARenderContext CARenderContext; -typedef struct _CARenderOGLContext CARenderOGLContext; +struct WKCACFContext; namespace WebCore { @@ -64,7 +62,7 @@ public: ~WKCACFLayerRenderer(); static bool acceleratedCompositingAvailable(); - static void didFlushContext(CACFContextRef); + static void didFlushContext(WKCACFContext*); void setRootContents(CGImageRef); void setRootContentsAndDisplay(CGImageRef); @@ -104,9 +102,7 @@ private: COMPtr<IDirect3DDevice9> m_d3dDevice; RefPtr<WKCACFRootLayer> m_rootLayer; RefPtr<WKCACFLayer> m_rootChildLayer; - RetainPtr<CACFContextRef> m_context; - CARenderContext* m_renderContext; - CARenderOGLContext* m_renderer; + WKCACFContext* m_context; HWND m_hostWindow; Timer<WKCACFLayerRenderer> m_renderTimer; bool m_backingStoreDirty; diff --git a/WebCore/platform/graphics/win/WebLayer.cpp b/WebCore/platform/graphics/win/WebLayer.cpp index 70a522d..ecda294 100644 --- a/WebCore/platform/graphics/win/WebLayer.cpp +++ b/WebCore/platform/graphics/win/WebLayer.cpp @@ -94,7 +94,7 @@ void WebLayer::drawInContext(PlatformGraphicsContext* context) #endif if (m_owner->showRepaintCounter()) { - String text = String::format("%d", m_owner->incrementRepaintCount());; + String text = String::number(m_owner->incrementRepaintCount()); CGContextSaveGState(context); @@ -129,7 +129,7 @@ void WebLayer::drawInContext(PlatformGraphicsContext* context) font.update(0); GraphicsContext cg(context); - cg.setFillColor(Color::black, DeviceColorSpace); + cg.setFillColor(Color::black, ColorSpaceDeviceRGB); cg.drawText(font, TextRun(text), IntPoint(aBounds.origin.x + 5, aBounds.origin.y + 17)); CGContextRestoreGState(context); diff --git a/WebCore/platform/graphics/win/WebTiledLayer.cpp b/WebCore/platform/graphics/win/WebTiledLayer.cpp index 01dd6ae..4705033 100644 --- a/WebCore/platform/graphics/win/WebTiledLayer.cpp +++ b/WebCore/platform/graphics/win/WebTiledLayer.cpp @@ -201,7 +201,7 @@ void WebTiledLayer::addTile() CACFLayerInsertSublayer(m_tileParent.get(), newLayer.get(), sublayers ? CFArrayGetCount(sublayers) : 0); if (m_owner->showDebugBorders()) { - CGColorRef borderColor = createCGColor(Color(128, 0, 128, 180)); + CGColorRef borderColor = CGColorCreateGenericRGB(0.5, 0, 0.5, 0.7); CACFLayerSetBorderColor(newLayer.get(), borderColor); CGColorRelease(borderColor); CACFLayerSetBorderWidth(newLayer.get(), 2); |