diff options
author | Kristian Monsen <kristianm@google.com> | 2010-06-28 16:42:48 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-07-02 10:29:56 +0100 |
commit | 06ea8e899e48f1f2f396b70e63fae369f2f23232 (patch) | |
tree | 20c1428cd05c76f32394ab354ea35ed99acd86d8 /WebCore/platform/graphics/mac | |
parent | 72aad67af14193199e29cdd5c4ddc095a8b9a8a8 (diff) | |
download | external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.zip external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.gz external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.bz2 |
Merge WebKit at r61871: Initial merge by git.
Change-Id: I6cff43abca9cc4782e088a469ad4f03f166a65d5
Diffstat (limited to 'WebCore/platform/graphics/mac')
14 files changed, 97 insertions, 113 deletions
diff --git a/WebCore/platform/graphics/mac/ComplexTextController.cpp b/WebCore/platform/graphics/mac/ComplexTextController.cpp index 61d5518..61c9a59 100644 --- a/WebCore/platform/graphics/mac/ComplexTextController.cpp +++ b/WebCore/platform/graphics/mac/ComplexTextController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. + * 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 @@ -69,6 +69,7 @@ ComplexTextController::ComplexTextController(const Font* font, const TextRun& ru , m_glyphInCurrentRun(0) , m_characterInCurrentGlyph(0) , m_finalRoundingWidth(0) + , m_padding(run.padding()) , m_fallbackFonts(fallbackFonts) , m_minGlyphBoundingBoxX(numeric_limits<float>::max()) , m_maxGlyphBoundingBoxX(numeric_limits<float>::min()) @@ -76,26 +77,26 @@ ComplexTextController::ComplexTextController(const Font* font, const TextRun& ru , m_maxGlyphBoundingBoxY(numeric_limits<float>::min()) , m_lastRoundingGlyph(0) { - m_padding = m_run.padding(); if (!m_padding) m_padPerSpace = 0; else { - float numSpaces = 0; - for (int s = 0; s < m_run.length(); s++) + int numSpaces = 0; + for (int s = 0; s < m_run.length(); s++) { if (Font::treatAsSpace(m_run[s])) numSpaces++; + } - if (numSpaces == 0) + if (!numSpaces) m_padPerSpace = 0; else - m_padPerSpace = ceilf(m_run.padding() / numSpaces); + m_padPerSpace = m_padding / numSpaces; } collectComplexTextRuns(); adjustGlyphsAndAdvances(); } -int ComplexTextController::offsetForPosition(int h, bool includePartialGlyphs) +int ComplexTextController::offsetForPosition(float h, bool includePartialGlyphs) { if (h >= m_totalWidth) return m_run.ltr() ? m_end : 0; @@ -115,9 +116,9 @@ int ComplexTextController::offsetForPosition(int h, bool includePartialGlyphs) CFIndex hitGlyphStart = complexTextRun.indexAt(j); CFIndex hitGlyphEnd; if (m_run.ltr()) - hitGlyphEnd = max<CFIndex>(hitGlyphStart, j + 1 < complexTextRun.glyphCount() ? complexTextRun.indexAt(j + 1) : complexTextRun.stringLength()); + hitGlyphEnd = max<CFIndex>(hitGlyphStart, j + 1 < complexTextRun.glyphCount() ? complexTextRun.indexAt(j + 1) : static_cast<CFIndex>(complexTextRun.stringLength())); else - hitGlyphEnd = max<CFIndex>(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : complexTextRun.stringLength()); + hitGlyphEnd = max<CFIndex>(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : static_cast<CFIndex>(complexTextRun.stringLength())); // FIXME: Instead of dividing the glyph's advance equally between the characters, this // could use the glyph's "ligature carets". However, there is no Core Text API to get the @@ -259,7 +260,7 @@ void ComplexTextController::collectComplexTextRuns() } if (nextGlyphData.fontData != glyphData.fontData || nextIsSmallCaps != isSmallCaps || !nextGlyphData.glyph != !glyphData.glyph) { - int itemStart = m_run.rtl() ? index + 1 : indexOfFontTransition; + int itemStart = m_run.rtl() ? index + 1 : static_cast<int>(indexOfFontTransition); int itemLength = m_run.rtl() ? indexOfFontTransition - index : index - indexOfFontTransition; collectComplexTextRunsForCharacters((isSmallCaps ? m_smallCapsBuffer.data() : cp) + itemStart, itemLength, itemStart, glyphData.glyph ? glyphData.fontData : 0); indexOfFontTransition = index; @@ -508,8 +509,9 @@ void ComplexTextController::adjustGlyphsAndAdvances() advance.width += m_padding; m_padding = 0; } else { - advance.width += m_padPerSpace; + float previousPadding = m_padding; m_padding -= m_padPerSpace; + advance.width += roundf(previousPadding) - roundf(m_padding); } } diff --git a/WebCore/platform/graphics/mac/ComplexTextController.h b/WebCore/platform/graphics/mac/ComplexTextController.h index 55cde29..b520d33 100644 --- a/WebCore/platform/graphics/mac/ComplexTextController.h +++ b/WebCore/platform/graphics/mac/ComplexTextController.h @@ -53,7 +53,7 @@ public: void advance(unsigned to, GlyphBuffer* = 0); // Compute the character offset for a given x coordinate. - int offsetForPosition(int x, bool includePartialGlyphs); + int offsetForPosition(float x, bool includePartialGlyphs); // Returns the width of everything we've consumed so far. float runWidthSoFar() const { return m_runWidthSoFar; } diff --git a/WebCore/platform/graphics/mac/FontComplexTextMac.cpp b/WebCore/platform/graphics/mac/FontComplexTextMac.cpp index b7ed0e9..05eae03 100644 --- a/WebCore/platform/graphics/mac/FontComplexTextMac.cpp +++ b/WebCore/platform/graphics/mac/FontComplexTextMac.cpp @@ -37,7 +37,7 @@ using namespace std; namespace WebCore { -FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, +FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& point, int h, int from, int to) const { ComplexTextController controller(this, run); @@ -97,7 +97,7 @@ float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon return controller.totalWidth(); } -int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const +int Font::offsetForPositionForComplexText(const TextRun& run, float x, bool includePartialGlyphs) const { ComplexTextController controller(this, run); return controller.offsetForPosition(x, includePartialGlyphs); diff --git a/WebCore/platform/graphics/mac/FontMac.mm b/WebCore/platform/graphics/mac/FontMac.mm index 100200a..aeb0ab2 100644 --- a/WebCore/platform/graphics/mac/FontMac.mm +++ b/WebCore/platform/graphics/mac/FontMac.mm @@ -135,7 +135,7 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons CGContextSetFontSize(cgContext, platformData.m_size); - IntSize shadowSize; + FloatSize shadowSize; float shadowBlur; Color shadowColor; ColorSpace fillColorSpace = context->fillColorSpace(); diff --git a/WebCore/platform/graphics/mac/FontPlatformData.h b/WebCore/platform/graphics/mac/FontPlatformData.h index 23016e7..f4c92be 100644 --- a/WebCore/platform/graphics/mac/FontPlatformData.h +++ b/WebCore/platform/graphics/mac/FontPlatformData.h @@ -51,7 +51,8 @@ class String; inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef>(nsFont); } #endif -struct FontPlatformData { +class FontPlatformData { + public: FontPlatformData(float size, bool syntheticBold, bool syntheticOblique) : m_syntheticBold(syntheticBold) , m_syntheticOblique(syntheticOblique) diff --git a/WebCore/platform/graphics/mac/FontPlatformDataMac.mm b/WebCore/platform/graphics/mac/FontPlatformDataMac.mm index 53b0282..e2ab405 100644 --- a/WebCore/platform/graphics/mac/FontPlatformDataMac.mm +++ b/WebCore/platform/graphics/mac/FontPlatformDataMac.mm @@ -53,7 +53,8 @@ FontPlatformData::FontPlatformData(NSFont *nsFont, bool syntheticBold, bool synt FontPlatformData::FontPlatformData(const FontPlatformData& f) { - m_font = f.m_font && f.m_font != reinterpret_cast<NSFont *>(-1) ? static_cast<const NSFont *>(CFRetain(f.m_font)) : f.m_font; + m_font = f.m_font && f.m_font != reinterpret_cast<NSFont *>(-1) ? const_cast<NSFont *>(static_cast<const NSFont *>(CFRetain(f.m_font))) : f.m_font; + m_syntheticBold = f.m_syntheticBold; m_syntheticOblique = f.m_syntheticOblique; m_size = f.m_size; diff --git a/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp b/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm index 90678b2..6457e4f 100644 --- a/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp +++ b/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm @@ -29,6 +29,7 @@ #include "GraphicsContext3D.h" +#import "BlockExceptions.h" #include "CanvasObject.h" #include "ImageBuffer.h" #include "NotImplemented.h" @@ -38,6 +39,7 @@ #include "Float32Array.h" #include "WebGLFramebuffer.h" #include "Int32Array.h" +#include "WebGLLayer.h" #include "WebGLProgram.h" #include "WebGLRenderbuffer.h" #include "WebGLShader.h" @@ -146,6 +148,14 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi validateAttributes(); + // Create the WebGLLayer + BEGIN_BLOCK_OBJC_EXCEPTIONS + m_webGLLayer.adoptNS([[WebGLLayer alloc] initWithGraphicsContext3D:this]); +#ifndef NDEBUG + [m_webGLLayer.get() setName:@"WebGL Layer"]; +#endif + END_BLOCK_OBJC_EXCEPTIONS + // create a texture to render into ::glGenTextures(1, &m_texture); ::glBindTexture(GL_TEXTURE_2D, m_texture); @@ -383,8 +393,8 @@ static inline void ensureContext(CGLContextObj context) void GraphicsContext3D::prepareTexture() { + ensureContext(m_contextObj); if (m_attrs.antialias) { - ensureContext(m_contextObj); ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO); ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo); ::glBlitFramebufferEXT(0, 0, m_currentWidth, m_currentHeight, 0, 0, m_currentWidth, m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.h b/WebCore/platform/graphics/mac/GraphicsLayerCA.h index 26a5de6..c17204f 100644 --- a/WebCore/platform/graphics/mac/GraphicsLayerCA.h +++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.h @@ -89,10 +89,7 @@ public: virtual void setNeedsDisplay(); virtual void setNeedsDisplayInRect(const FloatRect&); - -#if ENABLE(3D_CANVAS) - virtual void setGraphicsContext3DNeedsDisplay(); -#endif + virtual void setContentsNeedsDisplay(); virtual void setContentsRect(const IntRect&); @@ -107,7 +104,7 @@ public: virtual void setContentsToImage(Image*); virtual void setContentsToMedia(PlatformLayer*); #if ENABLE(3D_CANVAS) - virtual void setContentsToGraphicsContext3D(const GraphicsContext3D*); + virtual void setContentsToWebGL(PlatformLayer*); #endif virtual PlatformLayer* platformLayer() const; @@ -260,7 +257,7 @@ private: void updateContentsImage(); void updateContentsMediaLayer(); #if ENABLE(3D_CANVAS) - void updateContentsGraphicsContext3D(); + void updateContentsWebGLLayer(); #endif void updateContentsRect(); void updateGeometryOrientation(); @@ -268,6 +265,7 @@ private: void updateReplicatedLayers(); void updateLayerAnimations(); + void updateContentsNeedsDisplay(); enum StructuralLayerPurpose { NoStructuralLayer = 0, @@ -306,12 +304,13 @@ private: ContentsImageChanged = 1 << 17, ContentsMediaLayerChanged = 1 << 18, #if ENABLE(3D_CANVAS) - ContentsGraphicsContext3DChanged = 1 << 19, + ContentsWebGLLayerChanged = 1 << 19, #endif ContentsRectChanged = 1 << 20, GeometryOrientationChanged = 1 << 21, MaskLayerChanged = 1 << 22, - ReplicatedLayerChanged = 1 << 23 + ReplicatedLayerChanged = 1 << 23, + ContentsNeedsDisplay = 1 << 24 }; typedef unsigned LayerChangeFlags; void noteLayerPropertyChanged(LayerChangeFlags flags); @@ -333,7 +332,7 @@ private: ContentsLayerForImage, ContentsLayerForMedia #if ENABLE(3D_CANVAS) - ,ContentsLayerForGraphicsLayer3D + , ContentsLayerForWebGL #endif }; @@ -389,11 +388,6 @@ private: Vector<FloatRect> m_dirtyRects; LayerChangeFlags m_uncommittedChanges; - -#if ENABLE(3D_CANVAS) - PlatformGraphicsContext3D m_platformGraphicsContext3D; - Platform3DObject m_platformTexture; -#endif }; } // namespace WebCore diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm index bd01353..355c023 100644 --- a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm +++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm @@ -31,9 +31,6 @@ #import "Animation.h" #import "BlockExceptions.h" -#if ENABLE(3D_CANVAS) -#import "Canvas3DLayer.h" -#endif #import "FloatConversion.h" #import "FloatRect.h" #import "Image.h" @@ -369,10 +366,6 @@ GraphicsLayerCA::GraphicsLayerCA(GraphicsLayerClient* client) , m_contentsLayerPurpose(NoContentsLayer) , m_contentsLayerHasBackgroundColor(false) , m_uncommittedChanges(NoChange) -#if ENABLE(3D_CANVAS) - , m_platformGraphicsContext3D(NullPlatformGraphicsContext3D) - , m_platformTexture(NullPlatform3DObject) -#endif { BEGIN_BLOCK_OBJC_EXCEPTIONS m_layer.adoptNS([[WebLayer alloc] init]); @@ -697,6 +690,11 @@ void GraphicsLayerCA::setNeedsDisplayInRect(const FloatRect& rect) noteLayerPropertyChanged(DirtyRectsChanged); } +void GraphicsLayerCA::setContentsNeedsDisplay() +{ + noteLayerPropertyChanged(ContentsNeedsDisplay); +} + void GraphicsLayerCA::setContentsRect(const IntRect& rect) { if (rect == m_contentsRect) @@ -914,8 +912,8 @@ void GraphicsLayerCA::commitLayerChangesBeforeSublayers() updateContentsMediaLayer(); #if ENABLE(3D_CANVAS) - if (m_uncommittedChanges & ContentsGraphicsContext3DChanged) // Needs to happen before ChildrenChanged - updateContentsGraphicsContext3D(); + if (m_uncommittedChanges & ContentsWebGLLayerChanged) // Needs to happen before ChildrenChanged + updateContentsWebGLLayer(); #endif if (m_uncommittedChanges & BackgroundColorChanged) // Needs to happen before ChildrenChanged, and after updating image or video @@ -969,6 +967,9 @@ void GraphicsLayerCA::commitLayerChangesBeforeSublayers() if (m_uncommittedChanges & MaskLayerChanged) updateMaskLayer(); + if (m_uncommittedChanges & ContentsNeedsDisplay) + updateContentsNeedsDisplay(); + END_BLOCK_OBJC_EXCEPTIONS } @@ -1390,9 +1391,9 @@ void GraphicsLayerCA::updateContentsMediaLayer() } #if ENABLE(3D_CANVAS) -void GraphicsLayerCA::updateContentsGraphicsContext3D() +void GraphicsLayerCA::updateContentsWebGLLayer() { - // Canvas3D layer was set as m_contentsLayer, and will get parented in updateSublayerList(). + // WebGLLayer was set as m_contentsLayer, and will get parented in updateSublayerList(). if (m_contentsLayer) { setupContentsLayer(m_contentsLayer.get()); [m_contentsLayer.get() setNeedsDisplay]; @@ -1716,38 +1717,19 @@ void GraphicsLayerCA::pauseAnimationOnLayer(AnimatedPropertyID property, const S } #if ENABLE(3D_CANVAS) -void GraphicsLayerCA::setContentsToGraphicsContext3D(const GraphicsContext3D* graphicsContext3D) +void GraphicsLayerCA::setContentsToWebGL(PlatformLayer* webglLayer) { - PlatformGraphicsContext3D context = graphicsContext3D->platformGraphicsContext3D(); - Platform3DObject texture = graphicsContext3D->platformTexture(); - - if (context == m_platformGraphicsContext3D && texture == m_platformTexture) + if (webglLayer == m_contentsLayer) return; - m_platformGraphicsContext3D = context; - m_platformTexture = texture; - - noteSublayersChanged(); + m_contentsLayer = webglLayer; + if (m_contentsLayer && [m_contentsLayer.get() respondsToSelector:@selector(setLayerOwner:)]) + [(id)m_contentsLayer.get() setLayerOwner:this]; - BEGIN_BLOCK_OBJC_EXCEPTIONS + m_contentsLayerPurpose = webglLayer ? ContentsLayerForWebGL : NoContentsLayer; - if (m_platformGraphicsContext3D != NullPlatformGraphicsContext3D && m_platformTexture != NullPlatform3DObject) { - // create the inner 3d layer - m_contentsLayer.adoptNS([[Canvas3DLayer alloc] initWithContext:const_cast<GraphicsContext3D*>(graphicsContext3D)]); -#ifndef NDEBUG - [m_contentsLayer.get() setName:@"3D Layer"]; -#endif - [m_contentsLayer.get() setLayerOwner:this]; - } else { - // remove the inner layer - [m_contentsLayer.get() setLayerOwner:0]; - m_contentsLayer = 0; - } - - END_BLOCK_OBJC_EXCEPTIONS - - noteLayerPropertyChanged(ContentsGraphicsContext3DChanged); - m_contentsLayerPurpose = m_contentsLayer ? ContentsLayerForGraphicsLayer3D : NoContentsLayer; + noteSublayersChanged(); + noteLayerPropertyChanged(ContentsWebGLLayerChanged); } #endif @@ -1762,6 +1744,12 @@ void GraphicsLayerCA::repaintLayerDirtyRects() m_dirtyRects.clear(); } +void GraphicsLayerCA::updateContentsNeedsDisplay() +{ + if (m_contentsLayer) + [m_contentsLayer.get() setNeedsDisplay]; +} + bool GraphicsLayerCA::createAnimationFromKeyframes(const KeyframeValueList& valueList, const Animation* animation, const String& keyframesName, double timeOffset) { ASSERT(valueList.property() != AnimatedPropertyWebkitTransform); @@ -2566,14 +2554,6 @@ void GraphicsLayerCA::noteLayerPropertyChanged(LayerChangeFlags flags) m_uncommittedChanges |= flags; } -#if ENABLE(3D_CANVAS) -void GraphicsLayerCA::setGraphicsContext3DNeedsDisplay() -{ - if (m_contentsLayerPurpose == ContentsLayerForGraphicsLayer3D) - [m_contentsLayer.get() setNeedsDisplay]; -} -#endif - } // namespace WebCore #endif // USE(ACCELERATED_COMPOSITING) diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm index b49c52f..c73eeea 100644 --- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm +++ b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm @@ -1252,22 +1252,22 @@ static void addFileTypesToCache(NSArray * fileTypes, HashSet<String> &cache) if (!uti) continue; RetainPtr<CFStringRef> mime(AdoptCF, UTTypeCopyPreferredTagWithClass(uti.get(), kUTTagClassMIMEType)); - - // UTI types are missing many media related MIME types supported by QTKit, see rdar://6434168, - // and not all third party movie importers register their types, so if we didn't find a type for - // this extension look it up in the hard coded table in the MIME type regsitry. - if (!mime) { - // -movieFileTypes: returns both file extensions and OSTypes. The later are surrounded by single - // quotes, eg. 'MooV', so don't bother looking at those. - if (CFStringGetCharacterAtIndex(ext, 0) != '\'') { - String mediaType = MIMETypeRegistry::getMediaMIMETypeForExtension(String(ext)); - if (!mediaType.isEmpty()) - mime.adoptCF(mediaType.createCFString()); + if (mime) + cache.add(mime.get()); + + // -movieFileTypes: returns both file extensions and OSTypes. The later are surrounded by single + // quotes, eg. 'MooV', so don't bother looking at those. + if (CFStringGetCharacterAtIndex(ext, 0) != '\'') { + // UTI is missing many media related MIME types supported by QTKit (see rdar://6434168), and not all + // web servers use the MIME type UTI returns for an extension (see rdar://7875393), so even if UTI + // has a type for this extension add any types in hard coded table in the MIME type regsitry. + Vector<String> typesForExtension = MIMETypeRegistry::getMediaMIMETypesForExtension(ext); + unsigned count = typesForExtension.size(); + for (unsigned ndx = 0; ndx < count; ++ndx) { + if (!cache.contains(typesForExtension[ndx])) + cache.add(typesForExtension[ndx]); } } - if (!mime) - continue; - cache.add(mime.get()); } } diff --git a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm index 04badbe..bddb2ad 100644 --- a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm +++ b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm @@ -270,7 +270,7 @@ void SimpleFontData::platformInit() // and web pages that foolishly use this metric for width will be laid out // poorly if we return an accurate height. Classic case is Times 13 point, // which has an "x" that is 7x6 pixels. - m_xHeight = static_cast<float>(max(CGRectGetMaxX(xBox), CGRectGetMaxY(xBox))); + m_xHeight = static_cast<float>(max(CGRectGetMaxX(xBox), -CGRectGetMinY(xBox))); } else { #ifndef BUILDING_ON_TIGER m_xHeight = static_cast<float>(CGFontGetXHeight(m_platformData.cgFont())) / m_unitsPerEm; @@ -427,6 +427,7 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const if (!m_platformData.font()) return boundingBox; boundingBox = [m_platformData.font() boundingRectForGlyph:glyph]; + boundingBox.setY(-boundingBox.bottom()); #endif if (m_syntheticBoldOffset) boundingBox.setWidth(boundingBox.width() + m_syntheticBoldOffset); diff --git a/WebCore/platform/graphics/mac/Canvas3DLayer.h b/WebCore/platform/graphics/mac/WebGLLayer.h index 4609010..6440b71 100644 --- a/WebCore/platform/graphics/mac/Canvas3DLayer.h +++ b/WebCore/platform/graphics/mac/WebGLLayer.h @@ -23,27 +23,25 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef Canvas3DLayer_h -#define Canvas3DLayer_h +#ifndef WebGLLayer_h +#define WebGLLayer_h #if USE(ACCELERATED_COMPOSITING) -#import "WebLayer.h" +#import <QuartzCore/QuartzCore.h> namespace WebCore { class GraphicsLayer; class GraphicsContext3D; } -@interface Canvas3DLayer : CAOpenGLLayer +@interface WebGLLayer : CAOpenGLLayer { WebCore::GraphicsLayer* m_layerOwner; WebCore::GraphicsContext3D* m_context; - CGLContextObj m_contextObj; - GLuint m_texture; } -- (id)initWithContext:(WebCore::GraphicsContext3D*)context; +- (id)initWithGraphicsContext3D:(WebCore::GraphicsContext3D*)context; - (CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace; @@ -51,4 +49,4 @@ namespace WebCore { #endif // USE(ACCELERATED_COMPOSITING) -#endif // Canvas3DLayer_h +#endif // WebGLLayer_h diff --git a/WebCore/platform/graphics/mac/Canvas3DLayer.mm b/WebCore/platform/graphics/mac/WebGLLayer.mm index 22a0a10..12c6f0d 100644 --- a/WebCore/platform/graphics/mac/Canvas3DLayer.mm +++ b/WebCore/platform/graphics/mac/WebGLLayer.mm @@ -28,10 +28,10 @@ #if USE(ACCELERATED_COMPOSITING) #if ENABLE(3D_CANVAS) -#import "Canvas3DLayer.h" +#import "WebGLLayer.h" +#import "GraphicsContext3D.h" #import "GraphicsLayer.h" -#import <QuartzCore/QuartzCore.h> #import <OpenGL/OpenGL.h> #import <wtf/FastMalloc.h> #import <wtf/RetainPtr.h> @@ -39,13 +39,11 @@ using namespace WebCore; -@implementation Canvas3DLayer +@implementation WebGLLayer --(id)initWithContext:(GraphicsContext3D*)context +-(id)initWithGraphicsContext3D:(GraphicsContext3D*)context { m_context = context; - m_contextObj = static_cast<CGLContextObj>(context->platformGraphicsContext3D()); - m_texture = static_cast<GLuint>(context->platformTexture()); self = [super init]; return self; } @@ -59,13 +57,13 @@ using namespace WebCore; // If needed we will have to set the display mask in the Canvas CGLContext and // make sure it matches. UNUSED_PARAM(mask); - return CGLRetainPixelFormat(CGLGetPixelFormat(m_contextObj)); + return CGLRetainPixelFormat(CGLGetPixelFormat(m_context->platformGraphicsContext3D())); } -(CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat { CGLContextObj contextObj; - CGLCreateContext(pixelFormat, m_contextObj, &contextObj); + CGLCreateContext(pixelFormat, m_context->platformGraphicsContext3D(), &contextObj); return contextObj; } @@ -86,7 +84,7 @@ using namespace WebCore; glLoadIdentity(); glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, m_texture); + glBindTexture(GL_TEXTURE_2D, m_context->platformTexture()); glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); @@ -113,7 +111,7 @@ static void freeData(void *, const void *data, size_t /* size */) -(CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace { - CGLSetCurrentContext(m_contextObj); + CGLSetCurrentContext(m_context->platformGraphicsContext3D()); RetainPtr<CGColorSpaceRef> imageColorSpace = colorSpace; if (!imageColorSpace) @@ -151,7 +149,7 @@ static void freeData(void *, const void *data, size_t /* size */) @end -@implementation Canvas3DLayer(WebLayerAdditions) +@implementation WebGLLayer(WebGLLayerAdditions) -(void)setLayerOwner:(GraphicsLayer*)aLayer { diff --git a/WebCore/platform/graphics/mac/WebLayer.mm b/WebCore/platform/graphics/mac/WebLayer.mm index 641d421..0c9925e 100644 --- a/WebCore/platform/graphics/mac/WebLayer.mm +++ b/WebCore/platform/graphics/mac/WebLayer.mm @@ -193,7 +193,6 @@ using namespace WebCore; { CGRect aBounds = [self bounds]; CGPoint aPos = [self position]; - CATransform3D t = [self transform]; NSString* selfString = [NSString stringWithFormat:@"%@<%@ 0x%08x> \"%@\" bounds(%.1f, %.1f, %.1f, %.1f) pos(%.1f, %.1f), sublayers=%d masking=%d", inPrefix, |