diff options
Diffstat (limited to 'WebCore/platform/graphics/mac')
12 files changed, 173 insertions, 159 deletions
diff --git a/WebCore/platform/graphics/mac/ComplexTextController.h b/WebCore/platform/graphics/mac/ComplexTextController.h index b520d33..85407c7 100644 --- a/WebCore/platform/graphics/mac/ComplexTextController.h +++ b/WebCore/platform/graphics/mac/ComplexTextController.h @@ -127,7 +127,7 @@ private: unsigned m_stringLocation; size_t m_stringLength; #if USE(CORE_TEXT) - RetainPtr<CFMutableDataRef> m_coreTextIndicesData; + Vector<CFIndex, 64> m_coreTextIndicesVector; const CFIndex* m_coreTextIndices; #endif #if USE(ATSUI) diff --git a/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp b/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp index fba3d4b..744e6d4 100644 --- a/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp +++ b/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp @@ -51,10 +51,9 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Simp m_glyphCount = CTRunGetGlyphCount(m_coreTextRun.get()); m_coreTextIndices = CTRunGetStringIndicesPtr(m_coreTextRun.get()); if (!m_coreTextIndices) { - m_coreTextIndicesData.adoptCF(CFDataCreateMutable(kCFAllocatorDefault, m_glyphCount * sizeof(CFIndex))); - CFDataIncreaseLength(m_coreTextIndicesData.get(), m_glyphCount * sizeof(CFIndex)); - m_coreTextIndices = reinterpret_cast<const CFIndex*>(CFDataGetMutableBytePtr(m_coreTextIndicesData.get())); - CTRunGetStringIndices(m_coreTextRun.get(), CFRangeMake(0, 0), const_cast<CFIndex*>(m_coreTextIndices)); + m_coreTextIndicesVector.grow(m_glyphCount); + CTRunGetStringIndices(m_coreTextRun.get(), CFRangeMake(0, 0), m_coreTextIndicesVector.data()); + m_coreTextIndices = m_coreTextIndicesVector.data(); } m_glyphs = CTRunGetGlyphsPtr(m_coreTextRun.get()); @@ -70,17 +69,16 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Simp CTRunGetAdvances(m_coreTextRun.get(), CFRangeMake(0, 0), m_advancesVector.data()); m_advances = m_advancesVector.data(); } - } // Missing glyphs run constructor. Core Text will not generate a run of missing glyphs, instead falling back on // glyphs from LastResort. We want to use the primary font's missing glyph in order to match the fast text code path. void ComplexTextController::ComplexTextRun::createTextRunFromFontDataCoreText(bool ltr) { - Vector<CFIndex, 16> indices; + m_coreTextIndicesVector.reserveInitialCapacity(m_stringLength); unsigned r = 0; while (r < m_stringLength) { - indices.append(r); + m_coreTextIndicesVector.uncheckedAppend(r); if (U_IS_SURROGATE(m_characters[r])) { ASSERT(r + 1 < m_stringLength); ASSERT(U_IS_SURROGATE_LEAD(m_characters[r])); @@ -89,14 +87,12 @@ void ComplexTextController::ComplexTextRun::createTextRunFromFontDataCoreText(bo } else r++; } - m_glyphCount = indices.size(); + m_glyphCount = m_coreTextIndicesVector.size(); if (!ltr) { for (unsigned r = 0, end = m_glyphCount - 1; r < m_glyphCount / 2; ++r, --end) - std::swap(indices[r], indices[end]); + std::swap(m_coreTextIndicesVector[r], m_coreTextIndicesVector[end]); } - m_coreTextIndicesData.adoptCF(CFDataCreateMutable(kCFAllocatorDefault, m_glyphCount * sizeof(CFIndex))); - CFDataAppendBytes(m_coreTextIndicesData.get(), reinterpret_cast<const UInt8*>(indices.data()), m_glyphCount * sizeof(CFIndex)); - m_coreTextIndices = reinterpret_cast<const CFIndex*>(CFDataGetBytePtr(m_coreTextIndicesData.get())); + m_coreTextIndices = m_coreTextIndicesVector.data(); // Synthesize a run of missing glyphs. m_glyphsVector.fill(0, m_glyphCount); @@ -120,7 +116,7 @@ void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UC RetainPtr<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedStringCreate(NULL, string.get(), fontData->getCFStringAttributes(m_font.typesettingFeatures()))); - RetainPtr<CTTypesetterRef> typesetter; + RetainPtr<CTLineRef> line; if (!m_mayUseNaturalWritingDirection || m_run.directionalOverride()) { static const void* optionKeys[] = { kCTTypesetterOptionForcedEmbeddingLevel }; @@ -130,11 +126,11 @@ void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UC static const void* rtlOptionValues[] = { CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &rtlForcedEmbeddingLevelValue) }; static CFDictionaryRef ltrTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); static CFDictionaryRef rtlTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - typesetter.adoptCF(CTTypesetterCreateWithAttributedStringAndOptions(attributedString.get(), m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions)); - } else - typesetter.adoptCF(CTTypesetterCreateWithAttributedString(attributedString.get())); + RetainPtr<CTTypesetterRef> typesetter(AdoptCF, CTTypesetterCreateWithAttributedStringAndOptions(attributedString.get(), m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions)); - RetainPtr<CTLineRef> line(AdoptCF, CTTypesetterCreateLine(typesetter.get(), CFRangeMake(0, 0))); + line.adoptCF(CTTypesetterCreateLine(typesetter.get(), CFRangeMake(0, 0))); + } else + line.adoptCF(CTLineCreateWithAttributedString(attributedString.get())); CFArrayRef runArray = CTLineGetGlyphRuns(line.get()); diff --git a/WebCore/platform/graphics/mac/FontCustomPlatformData.h b/WebCore/platform/graphics/mac/FontCustomPlatformData.h index f2cd2cc..90440d5 100644 --- a/WebCore/platform/graphics/mac/FontCustomPlatformData.h +++ b/WebCore/platform/graphics/mac/FontCustomPlatformData.h @@ -23,6 +23,7 @@ #include "FontRenderingMode.h" #include <CoreFoundation/CFBase.h> +#include <wtf/Forward.h> #include <wtf/Noncopyable.h> typedef struct CGFont* CGFontRef; @@ -33,7 +34,6 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -class String; struct FontCustomPlatformData : Noncopyable { FontCustomPlatformData(ATSFontContainerRef container, ATSFontRef atsFont, CGFontRef cgFont) diff --git a/WebCore/platform/graphics/mac/FontMac.mm b/WebCore/platform/graphics/mac/FontMac.mm index aeb0ab2..db77402 100644 --- a/WebCore/platform/graphics/mac/FontMac.mm +++ b/WebCore/platform/graphics/mac/FontMac.mm @@ -64,7 +64,7 @@ static void showGlyphsWithAdvances(const FontPlatformData& font, CGContextRef co positions[i].x = positions[i - 1].x + advance.width; positions[i].y = positions[i - 1].y + advance.height; } - CTFontDrawGlyphs(toCTFontRef(font.font()), glyphs, positions.data(), count, context); + CTFontDrawGlyphs(font.ctFont(), glyphs, positions.data(), count, context); } #endif } diff --git a/WebCore/platform/graphics/mac/FontPlatformData.h b/WebCore/platform/graphics/mac/FontPlatformData.h index f4c92be..07ae4f8 100644 --- a/WebCore/platform/graphics/mac/FontPlatformData.h +++ b/WebCore/platform/graphics/mac/FontPlatformData.h @@ -2,7 +2,7 @@ * This file is part of the internal font implementation. * It should not be included by source files outside of it. * - * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple 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 @@ -39,14 +39,13 @@ typedef const struct __CTFont* CTFontRef; #include <CoreFoundation/CFBase.h> #include <objc/objc-auto.h> +#include <wtf/Forward.h> #include <wtf/RetainPtr.h> typedef UInt32 ATSUFontID; namespace WebCore { -class String; - #ifndef BUILDING_ON_TIGER inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef>(nsFont); } #endif @@ -114,6 +113,10 @@ class FontPlatformData { NSFont *font() const { return m_font; } void setFont(NSFont *font); +#if USE(CORE_TEXT) + CTFontRef ctFont() const; +#endif + bool roundsGlyphAdvances() const; bool allowsLigatures() const; bool isColorBitmapFont() const { return m_isColorBitmapFont; } @@ -132,12 +135,17 @@ private: static NSFont *hashTableDeletedFontValue() { return reinterpret_cast<NSFont *>(-1); } NSFont *m_font; + #ifndef BUILDING_ON_TIGER RetainPtr<CGFontRef> m_cgFont; #else CGFontRef m_cgFont; // It is not necessary to refcount this, since either an NSFont owns it or some CachedFont has it referenced. #endif +#if USE(CORE_TEXT) + mutable RetainPtr<CTFontRef> m_CTFont; +#endif + bool m_isColorBitmapFont; }; diff --git a/WebCore/platform/graphics/mac/FontPlatformDataMac.mm b/WebCore/platform/graphics/mac/FontPlatformDataMac.mm index aebd9f7..33de3c3 100644 --- a/WebCore/platform/graphics/mac/FontPlatformDataMac.mm +++ b/WebCore/platform/graphics/mac/FontPlatformDataMac.mm @@ -61,6 +61,9 @@ FontPlatformData::FontPlatformData(const FontPlatformData& f) m_cgFont = f.m_cgFont; m_atsuFontID = f.m_atsuFontID; m_isColorBitmapFont = f.m_isColorBitmapFont; +#if USE(CORE_TEXT) + m_CTFont = f.m_CTFont; +#endif } FontPlatformData:: ~FontPlatformData() @@ -84,6 +87,9 @@ const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& f) CFRelease(m_font); m_font = f.m_font; m_isColorBitmapFont = f.m_isColorBitmapFont; +#if USE(CORE_TEXT) + m_CTFont = f.m_CTFont; +#endif return *this; } @@ -107,6 +113,9 @@ void FontPlatformData::setFont(NSFont *font) #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) m_isColorBitmapFont = CTFontGetSymbolicTraits(toCTFontRef(font)) & kCTFontColorGlyphsTrait; #endif +#if USE(CORE_TEXT) + m_CTFont = 0; +#endif } bool FontPlatformData::roundsGlyphAdvances() const @@ -119,6 +128,17 @@ bool FontPlatformData::allowsLigatures() const return ![[m_font coveredCharacterSet] characterIsMember:'a']; } +#if USE(CORE_TEXT) +CTFontRef FontPlatformData::ctFont() const +{ + if (m_font) + return toCTFontRef(m_font); + if (!m_CTFont) + m_CTFont.adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), m_size, 0, 0)); + return m_CTFont.get(); +} +#endif // USE(CORE_TEXT) + #ifndef NDEBUG String FontPlatformData::description() const { diff --git a/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm b/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm index 30c3b8e..fd503fc 100644 --- a/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm +++ b/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm @@ -30,25 +30,19 @@ #include "GraphicsContext3D.h" #import "BlockExceptions.h" -#include "CanvasObject.h" -#include "ImageBuffer.h" -#include "NotImplemented.h" -#include "WebGLActiveInfo.h" + #include "ArrayBuffer.h" #include "ArrayBufferView.h" -#include "WebGLBuffer.h" +#include "WebGLObject.h" +#include "CanvasRenderingContext.h" #include "Float32Array.h" -#include "WebGLFramebuffer.h" #include "GraphicsContext.h" #include "HTMLCanvasElement.h" +#include "ImageBuffer.h" #include "Int32Array.h" -#include "WebGLLayer.h" -#include "WebGLProgram.h" -#include "WebGLRenderbuffer.h" -#include "WebGLRenderingContext.h" -#include "WebGLShader.h" -#include "WebGLTexture.h" +#include "NotImplemented.h" #include "Uint8Array.h" +#include "WebGLLayer.h" #include <CoreGraphics/CGBitmapContext.h> #include <OpenGL/CGLRenderers.h> #include <OpenGL/gl.h> @@ -240,7 +234,7 @@ void GraphicsContext3D::makeContextCurrent() CGLSetCurrentContext(m_contextObj); } -void GraphicsContext3D::paintRenderingResultsToCanvas(WebGLRenderingContext* context) +void GraphicsContext3D::paintRenderingResultsToCanvas(CanvasRenderingContext* context) { HTMLCanvasElement* canvas = context->canvas(); ImageBuffer* imageBuffer = canvas->buffer(); @@ -288,7 +282,7 @@ void GraphicsContext3D::paintRenderingResultsToCanvas(WebGLRenderingContext* con canvas->width(), canvas->height(), imageBuffer->context()->platformContext()); } -void GraphicsContext3D::beginPaint(WebGLRenderingContext* context) +void GraphicsContext3D::beginPaint(CanvasRenderingContext* context) { UNUSED_PARAM(context); } @@ -461,34 +455,34 @@ void GraphicsContext3D::activeTexture(unsigned long texture) ::glActiveTexture(texture); } -void GraphicsContext3D::attachShader(WebGLProgram* program, WebGLShader* shader) +void GraphicsContext3D::attachShader(Platform3DObject program, Platform3DObject shader) { ASSERT(program); ASSERT(shader); ensureContext(m_contextObj); - ::glAttachShader((GLuint) program->object(), (GLuint) shader->object()); + ::glAttachShader((GLuint) program, (GLuint) shader); } -void GraphicsContext3D::bindAttribLocation(WebGLProgram* program, unsigned long index, const String& name) +void GraphicsContext3D::bindAttribLocation(Platform3DObject program, unsigned long index, const String& name) { ASSERT(program); ensureContext(m_contextObj); - ::glBindAttribLocation((GLuint) program->object(), index, name.utf8().data()); + ::glBindAttribLocation((GLuint) program, index, name.utf8().data()); } -void GraphicsContext3D::bindBuffer(unsigned long target, WebGLBuffer* buffer) +void GraphicsContext3D::bindBuffer(unsigned long target, Platform3DObject buffer) { ensureContext(m_contextObj); - ::glBindBuffer(target, buffer ? (GLuint) buffer->object() : 0); + ::glBindBuffer(target, (GLuint) buffer); } -void GraphicsContext3D::bindFramebuffer(unsigned long target, WebGLFramebuffer* buffer) +void GraphicsContext3D::bindFramebuffer(unsigned long target, Platform3DObject buffer) { ensureContext(m_contextObj); GLuint fbo; - if (buffer && buffer->object()) - fbo = (GLuint)buffer->object(); + if (buffer) + fbo = (GLuint)buffer; else fbo = (m_attrs.antialias ? m_multisampleFBO : m_fbo); if (fbo != m_boundFBO) { @@ -497,17 +491,17 @@ void GraphicsContext3D::bindFramebuffer(unsigned long target, WebGLFramebuffer* } } -void GraphicsContext3D::bindRenderbuffer(unsigned long target, WebGLRenderbuffer* renderbuffer) +void GraphicsContext3D::bindRenderbuffer(unsigned long target, Platform3DObject renderbuffer) { ensureContext(m_contextObj); - ::glBindRenderbufferEXT(target, renderbuffer ? (GLuint) renderbuffer->object() : 0); + ::glBindRenderbufferEXT(target, (GLuint) renderbuffer); } -void GraphicsContext3D::bindTexture(unsigned long target, WebGLTexture* texture) +void GraphicsContext3D::bindTexture(unsigned long target, Platform3DObject texture) { ensureContext(m_contextObj); - ::glBindTexture(target, texture ? (GLuint) texture->object() : 0); + ::glBindTexture(target, (GLuint) texture); } void GraphicsContext3D::blendColor(double red, double green, double blue, double alpha) @@ -619,11 +613,11 @@ void GraphicsContext3D::colorMask(bool red, bool green, bool blue, bool alpha) ::glColorMask(red, green, blue, alpha); } -void GraphicsContext3D::compileShader(WebGLShader* shader) +void GraphicsContext3D::compileShader(Platform3DObject shader) { ASSERT(shader); ensureContext(m_contextObj); - ::glCompileShader((GLuint) shader->object()); + ::glCompileShader((GLuint) shader); } void GraphicsContext3D::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border) @@ -678,12 +672,12 @@ void GraphicsContext3D::depthRange(double zNear, double zFar) ::glDepthRange(zNear, zFar); } -void GraphicsContext3D::detachShader(WebGLProgram* program, WebGLShader* shader) +void GraphicsContext3D::detachShader(Platform3DObject program, Platform3DObject shader) { ASSERT(program); ASSERT(shader); ensureContext(m_contextObj); - ::glDetachShader((GLuint) program->object(), (GLuint) shader->object()); + ::glDetachShader((GLuint) program, (GLuint) shader); } void GraphicsContext3D::disable(unsigned long cap) @@ -734,10 +728,10 @@ void GraphicsContext3D::flush() ::glFlush(); } -void GraphicsContext3D::framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, WebGLRenderbuffer* buffer) +void GraphicsContext3D::framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, Platform3DObject buffer) { ensureContext(m_contextObj); - GLuint renderbuffer = (buffer ? (GLuint) buffer->object() : 0); + GLuint renderbuffer = (GLuint) buffer; if (attachment == DEPTH_STENCIL_ATTACHMENT) { ::glFramebufferRenderbufferEXT(target, DEPTH_ATTACHMENT, renderbuffertarget, renderbuffer); ::glFramebufferRenderbufferEXT(target, STENCIL_ATTACHMENT, renderbuffertarget, renderbuffer); @@ -745,10 +739,10 @@ void GraphicsContext3D::framebufferRenderbuffer(unsigned long target, unsigned l ::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); } -void GraphicsContext3D::framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, WebGLTexture* texture, long level) +void GraphicsContext3D::framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, Platform3DObject texture, long level) { ensureContext(m_contextObj); - ::glFramebufferTexture2DEXT(target, attachment, textarget, texture ? (GLuint) texture->object() : 0, level); + ::glFramebufferTexture2DEXT(target, attachment, textarget, (GLuint) texture, level); } void GraphicsContext3D::frontFace(unsigned long mode) @@ -763,20 +757,20 @@ void GraphicsContext3D::generateMipmap(unsigned long target) ::glGenerateMipmapEXT(target); } -bool GraphicsContext3D::getActiveAttrib(WebGLProgram* program, unsigned long index, ActiveInfo& info) +bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, unsigned long index, ActiveInfo& info) { - if (!program->object()) { + if (!program) { synthesizeGLError(INVALID_VALUE); return false; } ensureContext(m_contextObj); GLint maxAttributeSize = 0; - ::glGetProgramiv(static_cast<GLuint>(program->object()), GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize); + ::glGetProgramiv(static_cast<GLuint>(program), GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize); GLchar name[maxAttributeSize]; // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination GLsizei nameLength = 0; GLint size = 0; GLenum type = 0; - ::glGetActiveAttrib(static_cast<GLuint>(program->object()), index, maxAttributeSize, &nameLength, &size, &type, name); + ::glGetActiveAttrib(static_cast<GLuint>(program), index, maxAttributeSize, &nameLength, &size, &type, name); if (!nameLength) return false; info.name = String(name, nameLength); @@ -785,20 +779,20 @@ bool GraphicsContext3D::getActiveAttrib(WebGLProgram* program, unsigned long ind return true; } -bool GraphicsContext3D::getActiveUniform(WebGLProgram* program, unsigned long index, ActiveInfo& info) +bool GraphicsContext3D::getActiveUniform(Platform3DObject program, unsigned long index, ActiveInfo& info) { - if (!program->object()) { + if (!program) { synthesizeGLError(INVALID_VALUE); return false; } ensureContext(m_contextObj); GLint maxUniformSize = 0; - ::glGetProgramiv(static_cast<GLuint>(program->object()), GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize); + ::glGetProgramiv(static_cast<GLuint>(program), GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize); GLchar name[maxUniformSize]; // GL_ACTIVE_UNIFORM_MAX_LENGTH includes null termination GLsizei nameLength = 0; GLint size = 0; GLenum type = 0; - ::glGetActiveUniform(static_cast<GLuint>(program->object()), index, maxUniformSize, &nameLength, &size, &type, name); + ::glGetActiveUniform(static_cast<GLuint>(program), index, maxUniformSize, &nameLength, &size, &type, name); if (!nameLength) return false; info.name = String(name, nameLength); @@ -807,23 +801,23 @@ bool GraphicsContext3D::getActiveUniform(WebGLProgram* program, unsigned long in return true; } -void GraphicsContext3D::getAttachedShaders(WebGLProgram* program, int maxCount, int* count, unsigned int* shaders) +void GraphicsContext3D::getAttachedShaders(Platform3DObject program, int maxCount, int* count, unsigned int* shaders) { - if (!program || !program->object()) { + if (!program) { synthesizeGLError(INVALID_VALUE); return; } ensureContext(m_contextObj); - ::glGetAttachedShaders(static_cast<GLuint>(program->object()), maxCount, count, shaders); + ::glGetAttachedShaders(static_cast<GLuint>(program), maxCount, count, shaders); } -int GraphicsContext3D::getAttribLocation(WebGLProgram* program, const String& name) +int GraphicsContext3D::getAttribLocation(Platform3DObject program, const String& name) { if (!program) return -1; ensureContext(m_contextObj); - return ::glGetAttribLocation((GLuint) program->object(), name.utf8().data()); + return ::glGetAttribLocation((GLuint) program, name.utf8().data()); } GraphicsContext3D::Attributes GraphicsContext3D::getContextAttributes() @@ -856,13 +850,13 @@ void GraphicsContext3D::hint(unsigned long target, unsigned long mode) ::glHint(target, mode); } -bool GraphicsContext3D::isBuffer(WebGLBuffer* buffer) +bool GraphicsContext3D::isBuffer(Platform3DObject buffer) { if (!buffer) return false; ensureContext(m_contextObj); - return ::glIsBuffer((GLuint) buffer->object()); + return ::glIsBuffer((GLuint) buffer); } bool GraphicsContext3D::isEnabled(unsigned long cap) @@ -871,49 +865,49 @@ bool GraphicsContext3D::isEnabled(unsigned long cap) return ::glIsEnabled(cap); } -bool GraphicsContext3D::isFramebuffer(WebGLFramebuffer* framebuffer) +bool GraphicsContext3D::isFramebuffer(Platform3DObject framebuffer) { if (!framebuffer) return false; ensureContext(m_contextObj); - return ::glIsFramebufferEXT((GLuint) framebuffer->object()); + return ::glIsFramebufferEXT((GLuint) framebuffer); } -bool GraphicsContext3D::isProgram(WebGLProgram* program) +bool GraphicsContext3D::isProgram(Platform3DObject program) { if (!program) return false; ensureContext(m_contextObj); - return ::glIsProgram((GLuint) program->object()); + return ::glIsProgram((GLuint) program); } -bool GraphicsContext3D::isRenderbuffer(WebGLRenderbuffer* renderbuffer) +bool GraphicsContext3D::isRenderbuffer(Platform3DObject renderbuffer) { if (!renderbuffer) return false; ensureContext(m_contextObj); - return ::glIsRenderbufferEXT((GLuint) renderbuffer->object()); + return ::glIsRenderbufferEXT((GLuint) renderbuffer); } -bool GraphicsContext3D::isShader(WebGLShader* shader) +bool GraphicsContext3D::isShader(Platform3DObject shader) { if (!shader) return false; ensureContext(m_contextObj); - return ::glIsShader((GLuint) shader->object()); + return ::glIsShader((GLuint) shader); } -bool GraphicsContext3D::isTexture(WebGLTexture* texture) +bool GraphicsContext3D::isTexture(Platform3DObject texture) { if (!texture) return false; ensureContext(m_contextObj); - return ::glIsTexture((GLuint) texture->object()); + return ::glIsTexture((GLuint) texture); } void GraphicsContext3D::lineWidth(double width) @@ -922,11 +916,11 @@ void GraphicsContext3D::lineWidth(double width) ::glLineWidth(static_cast<float>(width)); } -void GraphicsContext3D::linkProgram(WebGLProgram* program) +void GraphicsContext3D::linkProgram(Platform3DObject program) { ASSERT(program); ensureContext(m_contextObj); - ::glLinkProgram((GLuint) program->object()); + ::glLinkProgram((GLuint) program); } void GraphicsContext3D::pixelStorei(unsigned long pname, long param) @@ -999,7 +993,7 @@ void GraphicsContext3D::scissor(long x, long y, unsigned long width, unsigned lo ::glScissor(x, y, width, height); } -void GraphicsContext3D::shaderSource(WebGLShader* shader, const String& string) +void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& string) { ASSERT(shader); @@ -1008,7 +1002,7 @@ void GraphicsContext3D::shaderSource(WebGLShader* shader, const String& string) const char* s = cs.data(); int length = string.length(); - ::glShaderSource((GLuint) shader->object(), 1, &s, &length); + ::glShaderSource((GLuint) shader, 1, &s, &length); } void GraphicsContext3D::stencilFunc(unsigned long func, long ref, unsigned long mask) @@ -1182,18 +1176,18 @@ void GraphicsContext3D::uniformMatrix4fv(long location, bool transpose, float* a ::glUniformMatrix4fv(location, size, transpose, array); } -void GraphicsContext3D::useProgram(WebGLProgram* program) +void GraphicsContext3D::useProgram(Platform3DObject program) { ensureContext(m_contextObj); - ::glUseProgram(program ? ((GLuint) program->object()) : 0); + ::glUseProgram((GLuint) program); } -void GraphicsContext3D::validateProgram(WebGLProgram* program) +void GraphicsContext3D::validateProgram(Platform3DObject program) { ASSERT(program); ensureContext(m_contextObj); - ::glValidateProgram((GLuint) program->object()); + ::glValidateProgram((GLuint) program); } void GraphicsContext3D::vertexAttrib1f(unsigned long indx, float v0) @@ -1316,26 +1310,26 @@ void GraphicsContext3D::getIntegerv(unsigned long pname, int* value) } } -void GraphicsContext3D::getProgramiv(WebGLProgram* program, unsigned long pname, int* value) +void GraphicsContext3D::getProgramiv(Platform3DObject program, unsigned long pname, int* value) { ensureContext(m_contextObj); - ::glGetProgramiv((GLuint) program->object(), pname, value); + ::glGetProgramiv((GLuint) program, pname, value); } -String GraphicsContext3D::getProgramInfoLog(WebGLProgram* program) +String GraphicsContext3D::getProgramInfoLog(Platform3DObject program) { ASSERT(program); ensureContext(m_contextObj); GLint length; - ::glGetProgramiv((GLuint) program->object(), GL_INFO_LOG_LENGTH, &length); + ::glGetProgramiv((GLuint) program, GL_INFO_LOG_LENGTH, &length); GLsizei size; GLchar* info = (GLchar*) fastMalloc(length); if (!info) return ""; - ::glGetProgramInfoLog((GLuint) program->object(), length, &size, info); + ::glGetProgramInfoLog((GLuint) program, length, &size, info); String s(info); fastFree(info); return s; @@ -1347,47 +1341,47 @@ void GraphicsContext3D::getRenderbufferParameteriv(unsigned long target, unsigne ::glGetRenderbufferParameterivEXT(target, pname, value); } -void GraphicsContext3D::getShaderiv(WebGLShader* shader, unsigned long pname, int* value) +void GraphicsContext3D::getShaderiv(Platform3DObject shader, unsigned long pname, int* value) { ASSERT(shader); ensureContext(m_contextObj); - ::glGetShaderiv((GLuint) shader->object(), pname, value); + ::glGetShaderiv((GLuint) shader, pname, value); } -String GraphicsContext3D::getShaderInfoLog(WebGLShader* shader) +String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader) { ASSERT(shader); ensureContext(m_contextObj); GLint length; - ::glGetShaderiv((GLuint) shader->object(), GL_INFO_LOG_LENGTH, &length); + ::glGetShaderiv((GLuint) shader, GL_INFO_LOG_LENGTH, &length); GLsizei size; GLchar* info = (GLchar*) fastMalloc(length); if (!info) return ""; - ::glGetShaderInfoLog((GLuint) shader->object(), length, &size, info); + ::glGetShaderInfoLog((GLuint) shader, length, &size, info); String s(info); fastFree(info); return s; } -String GraphicsContext3D::getShaderSource(WebGLShader* shader) +String GraphicsContext3D::getShaderSource(Platform3DObject shader) { ASSERT(shader); ensureContext(m_contextObj); GLint length; - ::glGetShaderiv((GLuint) shader->object(), GL_SHADER_SOURCE_LENGTH, &length); + ::glGetShaderiv((GLuint) shader, GL_SHADER_SOURCE_LENGTH, &length); GLsizei size; GLchar* info = (GLchar*) fastMalloc(length); if (!info) return ""; - ::glGetShaderSource((GLuint) shader->object(), length, &size, info); + ::glGetShaderSource((GLuint) shader, length, &size, info); String s(info); fastFree(info); return s; @@ -1406,24 +1400,24 @@ void GraphicsContext3D::getTexParameteriv(unsigned long target, unsigned long pn ::glGetTexParameteriv(target, pname, value); } -void GraphicsContext3D::getUniformfv(WebGLProgram* program, long location, float* value) +void GraphicsContext3D::getUniformfv(Platform3DObject program, long location, float* value) { ensureContext(m_contextObj); - ::glGetUniformfv((GLuint) program->object(), location, value); + ::glGetUniformfv((GLuint) program, location, value); } -void GraphicsContext3D::getUniformiv(WebGLProgram* program, long location, int* value) +void GraphicsContext3D::getUniformiv(Platform3DObject program, long location, int* value) { ensureContext(m_contextObj); - ::glGetUniformiv((GLuint) program->object(), location, value); + ::glGetUniformiv((GLuint) program, location, value); } -long GraphicsContext3D::getUniformLocation(WebGLProgram* program, const String& name) +long GraphicsContext3D::getUniformLocation(Platform3DObject program, const String& name) { ASSERT(program); ensureContext(m_contextObj); - return ::glGetUniformLocation((GLuint) program->object(), name.utf8().data()); + return ::glGetUniformLocation((GLuint) program, name.utf8().data()); } void GraphicsContext3D::getVertexAttribfv(unsigned long index, unsigned long pname, float* value) diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.h b/WebCore/platform/graphics/mac/GraphicsLayerCA.h index 80c822c..ee70338 100644 --- a/WebCore/platform/graphics/mac/GraphicsLayerCA.h +++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.h @@ -103,9 +103,8 @@ public: virtual void setContentsToImage(Image*); virtual void setContentsToMedia(PlatformLayer*); -#if ENABLE(3D_CANVAS) - virtual void setContentsToWebGL(PlatformLayer*); -#endif + virtual void setContentsToCanvas(PlatformLayer*); + virtual bool hasContentsLayer() const { return m_contentsLayer; } virtual PlatformLayer* platformLayer() const; @@ -258,9 +257,7 @@ private: void updateContentsImage(); void updateContentsMediaLayer(); -#if ENABLE(3D_CANVAS) - void updateContentsWebGLLayer(); -#endif + void updateContentsCanvasLayer(); void updateContentsRect(); void updateGeometryOrientation(); void updateMaskLayer(); @@ -305,9 +302,7 @@ private: DirtyRectsChanged = 1 << 16, ContentsImageChanged = 1 << 17, ContentsMediaLayerChanged = 1 << 18, -#if ENABLE(3D_CANVAS) - ContentsWebGLLayerChanged = 1 << 19, -#endif + ContentsCanvasLayerChanged = 1 << 19, ContentsRectChanged = 1 << 20, GeometryOrientationChanged = 1 << 21, MaskLayerChanged = 1 << 22, @@ -332,10 +327,8 @@ private: enum ContentsLayerPurpose { NoContentsLayer = 0, ContentsLayerForImage, - ContentsLayerForMedia -#if ENABLE(3D_CANVAS) - , ContentsLayerForWebGL -#endif + ContentsLayerForMedia, + ContentsLayerForCanvas }; ContentsLayerPurpose m_contentsLayerPurpose; diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm index 9f1ac83..cb4ca58 100644 --- a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm +++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm @@ -917,10 +917,8 @@ void GraphicsLayerCA::commitLayerChangesBeforeSublayers() if (m_uncommittedChanges & ContentsMediaLayerChanged) // Needs to happen before ChildrenChanged updateContentsMediaLayer(); -#if ENABLE(3D_CANVAS) - if (m_uncommittedChanges & ContentsWebGLLayerChanged) // Needs to happen before ChildrenChanged - updateContentsWebGLLayer(); -#endif + if (m_uncommittedChanges & ContentsCanvasLayerChanged) // Needs to happen before ChildrenChanged + updateContentsCanvasLayer(); if (m_uncommittedChanges & BackgroundColorChanged) // Needs to happen before ChildrenChanged, and after updating image or video updateLayerBackgroundColor(); @@ -1396,18 +1394,16 @@ void GraphicsLayerCA::updateContentsMediaLayer() } } -#if ENABLE(3D_CANVAS) -void GraphicsLayerCA::updateContentsWebGLLayer() +void GraphicsLayerCA::updateContentsCanvasLayer() { - // WebGLLayer was set as m_contentsLayer, and will get parented in updateSublayerList(). + // CanvasLayer was set as m_contentsLayer, and will get parented in updateSublayerList(). if (m_contentsLayer) { setupContentsLayer(m_contentsLayer.get()); [m_contentsLayer.get() setNeedsDisplay]; updateContentsRect(); } } -#endif - + void GraphicsLayerCA::updateContentsRect() { if (!m_contentsLayer) @@ -1722,22 +1718,20 @@ void GraphicsLayerCA::pauseAnimationOnLayer(AnimatedPropertyID property, const S } } -#if ENABLE(3D_CANVAS) -void GraphicsLayerCA::setContentsToWebGL(PlatformLayer* webglLayer) +void GraphicsLayerCA::setContentsToCanvas(PlatformLayer* canvasLayer) { - if (webglLayer == m_contentsLayer) + if (canvasLayer == m_contentsLayer) return; - m_contentsLayer = webglLayer; + m_contentsLayer = canvasLayer; if (m_contentsLayer && [m_contentsLayer.get() respondsToSelector:@selector(setLayerOwner:)]) [(id)m_contentsLayer.get() setLayerOwner:this]; - m_contentsLayerPurpose = webglLayer ? ContentsLayerForWebGL : NoContentsLayer; + m_contentsLayerPurpose = canvasLayer ? ContentsLayerForCanvas : NoContentsLayer; noteSublayersChanged(); - noteLayerPropertyChanged(ContentsWebGLLayerChanged); + noteLayerPropertyChanged(ContentsCanvasLayerChanged); } -#endif void GraphicsLayerCA::repaintLayerDirtyRects() { diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h index 2636aeb..3895a00 100644 --- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h +++ b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h @@ -59,7 +59,6 @@ class MediaPlayerPrivate : public MediaPlayerPrivateInterface { public: static void registerMediaEngine(MediaEngineRegistrar); - void repaint(); void loadStateChanged(); void rateChanged(); @@ -127,6 +126,8 @@ private: void paint(GraphicsContext*, const IntRect&); void paintCurrentFrameInContext(GraphicsContext*, const IntRect&); + virtual void prepareForRendering(); + #if USE(ACCELERATED_COMPOSITING) bool supportsAcceleratedRendering() const; @@ -170,7 +171,7 @@ private: void cacheMovieScale(); bool metaDataAvailable() const { return m_qtMovie && m_readyState >= MediaPlayer::HaveMetadata; } - bool isReadyForRendering() const; + bool isReadyForVideoSetup() const; MediaPlayer* m_player; RetainPtr<QTMovie> m_qtMovie; @@ -197,6 +198,7 @@ private: bool m_hasUnsupportedTracks; bool m_videoFrameHasDrawn; bool m_delayingLoad; + bool m_isAllowedToRender; #if DRAW_FRAME_RATE int m_frameCountWhilePlaying; double m_timeStartedPlaying; diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm index 5c327f9..435e56e 100644 --- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm +++ b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm @@ -217,6 +217,7 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player) , m_visible(false) , m_hasUnsupportedTracks(false) , m_videoFrameHasDrawn(false) + , m_isAllowedToRender(false) #if DRAW_FRAME_RATE , m_frameCountWhilePlaying(0) , m_timeStartedPlaying(0) @@ -495,7 +496,7 @@ MediaPlayerPrivate::MediaRenderingMode MediaPlayerPrivate::preferredRenderingMod void MediaPlayerPrivate::setUpVideoRendering() { - if (!isReadyForRendering()) + if (!isReadyForVideoSetup()) return; MediaRenderingMode currentMode = currentRenderingMode(); @@ -519,10 +520,9 @@ void MediaPlayerPrivate::setUpVideoRendering() break; } -#if USE(ACCELERATED_COMPOSITING) + // If using a movie layer, inform the client so the compositing tree is updated. if (currentMode == MediaRenderingMovieLayer || preferredMode == MediaRenderingMovieLayer) m_player->mediaPlayerClient()->mediaPlayerRenderingModeChanged(m_player); -#endif } void MediaPlayerPrivate::tearDownVideoRendering() @@ -915,11 +915,26 @@ void MediaPlayerPrivate::cacheMovieScale() m_scaleFactor.setHeight(initialSize.height / naturalSize.height); } -bool MediaPlayerPrivate::isReadyForRendering() const +bool MediaPlayerPrivate::isReadyForVideoSetup() const { return m_readyState >= MediaPlayer::HaveMetadata && m_player->visible(); } +void MediaPlayerPrivate::prepareForRendering() +{ + if (m_isAllowedToRender) + return; + m_isAllowedToRender = true; + + if (!hasSetUpVideoRendering()) + setUpVideoRendering(); + + // If using a movie layer, inform the client so the compositing tree is updated. This is crucial if the movie + // has a poster, as it will most likely not have a layer and we will now be rendering frames to the movie layer. + if (currentRenderingMode() == MediaRenderingMovieLayer || preferredRenderingMode() == MediaRenderingMovieLayer) + m_player->mediaPlayerClient()->mediaPlayerRenderingModeChanged(m_player); +} + void MediaPlayerPrivate::updateStates() { MediaPlayer::NetworkState oldNetworkState = m_networkState; @@ -1009,7 +1024,7 @@ void MediaPlayerPrivate::updateStates() } } - if (!hasSetUpVideoRendering()) + if (isReadyForVideoSetup() && !hasSetUpVideoRendering()) setUpVideoRendering(); if (seeking()) @@ -1443,8 +1458,9 @@ void MediaPlayerPrivate::sawUnsupportedTracks() #if USE(ACCELERATED_COMPOSITING) bool MediaPlayerPrivate::supportsAcceleratedRendering() const { - // When in the media document we render via QTMovieView, which is already accelerated. - return isReadyForRendering() && getQTMovieLayerClass() != Nil && !m_player->inMediaDocument(); + // Also don't claim to support accelerated rendering when in the media document, as we will then render + // via QTMovieView which is already accelerated. + return isReadyForVideoSetup() && getQTMovieLayerClass() != Nil && !m_player->inMediaDocument(); } void MediaPlayerPrivate::acceleratedRenderingStateChanged() diff --git a/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp b/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp index fc67a19..4fb525f 100644 --- a/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp +++ b/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp @@ -41,15 +41,6 @@ using namespace std; namespace WebCore { -CTFontRef SimpleFontData::getCTFont() const -{ - if (getNSFont()) - return toCTFontRef(getNSFont()); - if (!m_CTFont) - m_CTFont.adoptCF(CTFontCreateWithGraphicsFont(m_platformData.cgFont(), m_platformData.size(), 0, 0)); - return m_CTFont.get(); -} - CFDictionaryRef SimpleFontData::getCFStringAttributes(TypesettingFeatures typesettingFeatures) const { unsigned key = typesettingFeatures + 1; @@ -70,7 +61,7 @@ CFDictionaryRef SimpleFontData::getCFStringAttributes(TypesettingFeatures typese static const float kerningAdjustmentValue = 0; static CFNumberRef kerningAdjustment = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &kerningAdjustmentValue); static const void* keysWithKerningDisabled[] = { kCTFontAttributeName, kCTKernAttributeName, kCTLigatureAttributeName }; - const void* valuesWithKerningDisabled[] = { getCTFont(), kerningAdjustment, allowLigatures + const void* valuesWithKerningDisabled[] = { platformData().ctFont(), kerningAdjustment, allowLigatures ? ligaturesAllowed : ligaturesNotAllowed }; attributesDictionary.adoptCF(CFDictionaryCreate(0, keysWithKerningDisabled, valuesWithKerningDisabled, sizeof(keysWithKerningDisabled) / sizeof(*keysWithKerningDisabled), @@ -78,7 +69,7 @@ CFDictionaryRef SimpleFontData::getCFStringAttributes(TypesettingFeatures typese } else { // By omitting the kCTKernAttributeName attribute, we get Core Text's standard kerning. static const void* keysWithKerningEnabled[] = { kCTFontAttributeName, kCTLigatureAttributeName }; - const void* valuesWithKerningEnabled[] = { getCTFont(), allowLigatures ? ligaturesAllowed : ligaturesNotAllowed }; + const void* valuesWithKerningEnabled[] = { platformData().ctFont(), allowLigatures ? ligaturesAllowed : ligaturesNotAllowed }; attributesDictionary.adoptCF(CFDictionaryCreate(0, keysWithKerningEnabled, valuesWithKerningEnabled, sizeof(keysWithKerningEnabled) / sizeof(*keysWithKerningEnabled), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); |