diff options
| author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-10-09 18:10:02 +0200 |
|---|---|---|
| committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-10-09 18:10:03 +0200 |
| commit | ee21e513f3ed68af68e529b43c8fda94dfcc49ff (patch) | |
| tree | 37eff93fb4b1d5de70c99ec290c3a193bf44f9ca /Source | |
| parent | 880257678ae831d9b79937e8d8533a88a8f8325d (diff) | |
| parent | ea46a149dc42a48c103833742a7a0d575576c14a (diff) | |
| download | qtwebkit-ee21e513f3ed68af68e529b43c8fda94dfcc49ff.tar.gz | |
Merge remote-tracking branch 'origin/5.4' into dev
Change-Id: Ie2225337cb5eef39035146827484496a6b3690b3
Diffstat (limited to 'Source')
38 files changed, 757 insertions, 525 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGAbstractState.cpp b/Source/JavaScriptCore/dfg/DFGAbstractState.cpp index ab2a5af98..19bad5c09 100644 --- a/Source/JavaScriptCore/dfg/DFGAbstractState.cpp +++ b/Source/JavaScriptCore/dfg/DFGAbstractState.cpp @@ -1255,7 +1255,7 @@ bool AbstractState::executeEffects(unsigned indexInBlock, Node* node) case GetScope: // FIXME: We could get rid of these if we know that the JSFunction is a constant. https://bugs.webkit.org/show_bug.cgi?id=106202 case GetMyScope: case SkipTopScope: - forNode(node).set(SpecCellOther); + forNode(node).set(SpecObjectOther); break; case SkipScope: { @@ -1264,7 +1264,7 @@ bool AbstractState::executeEffects(unsigned indexInBlock, Node* node) m_foundConstants = true; break; } - forNode(node).set(SpecCellOther); + forNode(node).set(SpecObjectOther); break; } diff --git a/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp b/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp index 47af696a0..0eb29fcaf 100644 --- a/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp +++ b/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp @@ -254,9 +254,11 @@ private: break; } case PutScopedVar: { - if (node->child2() == registers && node->varNumber() == varNumber) + if (node->varNumber() != varNumber) + break; + if (node->child2() == registers) return node->child3().node(); - break; + return 0; } case SetLocal: { VariableAccessData* variableAccessData = node->variableAccessData(); @@ -327,9 +329,11 @@ private: Node* node = m_currentBlock->at(i); switch (node->op()) { case PutScopedVar: { - if (node->child1() == scope && node->child2() == registers && node->varNumber() == varNumber) + if (node->varNumber() != varNumber) + break; + if (node->child1() == scope && node->child2() == registers) return node; - break; + return 0; } case GetScopedVar: { diff --git a/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp b/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp index 01a9e4e42..ddcc313d6 100644 --- a/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp +++ b/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp @@ -396,7 +396,7 @@ private: case GetMyScope: case SkipTopScope: case SkipScope: { - changed |= setPrediction(SpecCellOther); + changed |= setPrediction(SpecObjectOther); break; } @@ -497,7 +497,7 @@ private: break; case GetScope: - changed |= setPrediction(SpecCellOther); + changed |= setPrediction(SpecObjectOther); break; case Identity: diff --git a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp index 0957f0eab..6502aa574 100644 --- a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp +++ b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp @@ -1104,6 +1104,10 @@ GPRReg SpeculativeJIT::fillSpeculateCell(Edge edge) switch (info.registerFormat()) { case DataFormatNone: { + if (info.spillFormat() == DataFormatInteger || info.spillFormat() == DataFormatDouble) { + terminateSpeculativeExecution(Uncountable, JSValueRegs(), 0); + return allocate(); + } if (edge->hasConstant()) { JSValue jsValue = valueOfJSConstant(edge.node()); diff --git a/Source/JavaScriptCore/heap/SlotVisitorInlines.h b/Source/JavaScriptCore/heap/SlotVisitorInlines.h index 4273a28d6..da338ce11 100644 --- a/Source/JavaScriptCore/heap/SlotVisitorInlines.h +++ b/Source/JavaScriptCore/heap/SlotVisitorInlines.h @@ -174,6 +174,7 @@ inline void SlotVisitor::donateAndDrain() inline void SlotVisitor::copyLater(JSCell* owner, void* ptr, size_t bytes) { + ASSERT(bytes); CopiedBlock* block = CopiedSpace::blockFor(ptr); if (block->isOversize()) { m_shared.m_copiedSpace->pin(block); diff --git a/Source/JavaScriptCore/parser/NodeConstructors.h b/Source/JavaScriptCore/parser/NodeConstructors.h index b31c01432..4bc670f81 100644 --- a/Source/JavaScriptCore/parser/NodeConstructors.h +++ b/Source/JavaScriptCore/parser/NodeConstructors.h @@ -517,7 +517,7 @@ inline ResolveNode::ResolveNode(const JSTokenLocation& location, const Identifie } inline LogicalOpNode::LogicalOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, LogicalOperator oper) - : ExpressionNode(location, ResultType::booleanType()) + : ExpressionNode(location, ResultType::forLogicalOp(expr1->resultDescriptor(), expr2->resultDescriptor())) , m_expr1(expr1) , m_expr2(expr2) , m_operator(oper) diff --git a/Source/JavaScriptCore/parser/ResultType.h b/Source/JavaScriptCore/parser/ResultType.h index de4bde66b..ad86c98c7 100644 --- a/Source/JavaScriptCore/parser/ResultType.h +++ b/Source/JavaScriptCore/parser/ResultType.h @@ -120,7 +120,20 @@ namespace JSC { return stringType(); return stringOrNumberType(); } - + + // Unlike in C, a logical op produces the value of the + // last expression evaluated (and not true or false). + static ResultType forLogicalOp(ResultType op1, ResultType op2) + { + if (op1.definitelyIsBoolean() && op2.definitelyIsBoolean()) + return booleanType(); + if (op1.definitelyIsNumber() && op2.definitelyIsNumber()) + return numberType(); + if (op1.definitelyIsString() && op2.definitelyIsString()) + return stringType(); + return unknownType(); + } + static ResultType forBitOp() { return numberTypeIsInt32(); diff --git a/Source/JavaScriptCore/runtime/JSArray.cpp b/Source/JavaScriptCore/runtime/JSArray.cpp index f97ccedcd..bc6f73672 100644 --- a/Source/JavaScriptCore/runtime/JSArray.cpp +++ b/Source/JavaScriptCore/runtime/JSArray.cpp @@ -755,21 +755,21 @@ bool JSArray::shiftCountWithAnyIndexingType(ExecState* exec, unsigned startIndex // so only if it's not horribly slow. if (oldLength - (startIndex + count) >= MIN_SPARSE_ARRAY_INDEX) return shiftCountWithArrayStorage(startIndex, count, ensureArrayStorage(exec->vm())); - + + // Storing to a hole is fine since we're still having a good time. But reading from a hole + // is totally not fine, since we might have to read from the proto chain. + // We have to check for holes before we start moving things around so that we don't get halfway + // through shifting and then realize we should have been in ArrayStorage mode. unsigned end = oldLength - count; for (unsigned i = startIndex; i < end; ++i) { - // Storing to a hole is fine since we're still having a good time. But reading - // from a hole is totally not fine, since we might have to read from the proto - // chain. JSValue v = m_butterfly->contiguous()[i + count].get(); - if (UNLIKELY(!v)) { - // The purpose of this path is to ensure that we don't make the same - // mistake in the future: shiftCountWithArrayStorage() can't do anything - // about holes (at least for now), but it can detect them quickly. So - // we convert to array storage and then allow the array storage path to - // figure it out. + if (UNLIKELY(!v)) return shiftCountWithArrayStorage(startIndex, count, ensureArrayStorage(exec->vm())); - } + } + + for (unsigned i = startIndex; i < end; ++i) { + JSValue v = m_butterfly->contiguous()[i + count].get(); + ASSERT(v); // No need for a barrier since we're just moving data around in the same vector. // This is in line with our standing assumption that we won't have a deletion // barrier. @@ -790,21 +790,21 @@ bool JSArray::shiftCountWithAnyIndexingType(ExecState* exec, unsigned startIndex // so only if it's not horribly slow. if (oldLength - (startIndex + count) >= MIN_SPARSE_ARRAY_INDEX) return shiftCountWithArrayStorage(startIndex, count, ensureArrayStorage(exec->vm())); - + + // Storing to a hole is fine since we're still having a good time. But reading from a hole + // is totally not fine, since we might have to read from the proto chain. + // We have to check for holes before we start moving things around so that we don't get halfway + // through shifting and then realize we should have been in ArrayStorage mode. unsigned end = oldLength - count; for (unsigned i = startIndex; i < end; ++i) { - // Storing to a hole is fine since we're still having a good time. But reading - // from a hole is totally not fine, since we might have to read from the proto - // chain. double v = m_butterfly->contiguousDouble()[i + count]; - if (UNLIKELY(v != v)) { - // The purpose of this path is to ensure that we don't make the same - // mistake in the future: shiftCountWithArrayStorage() can't do anything - // about holes (at least for now), but it can detect them quickly. So - // we convert to array storage and then allow the array storage path to - // figure it out. + if (UNLIKELY(v != v)) return shiftCountWithArrayStorage(startIndex, count, ensureArrayStorage(exec->vm())); - } + } + + for (unsigned i = startIndex; i < end; ++i) { + double v = m_butterfly->contiguousDouble()[i + count]; + ASSERT(v == v); // No need for a barrier since we're just moving data around in the same vector. // This is in line with our standing assumption that we won't have a deletion // barrier. @@ -889,11 +889,18 @@ bool JSArray::unshiftCountWithAnyIndexingType(ExecState* exec, unsigned startInd return unshiftCountWithArrayStorage(exec, startIndex, count, ensureArrayStorage(exec->vm())); ensureLength(exec->vm(), oldLength + count); - + + // We have to check for holes before we start moving things around so that we don't get halfway + // through shifting and then realize we should have been in ArrayStorage mode. for (unsigned i = oldLength; i-- > startIndex;) { JSValue v = m_butterfly->contiguous()[i].get(); if (UNLIKELY(!v)) return unshiftCountWithArrayStorage(exec, startIndex, count, ensureArrayStorage(exec->vm())); + } + + for (unsigned i = oldLength; i-- > startIndex;) { + JSValue v = m_butterfly->contiguous()[i].get(); + ASSERT(v); m_butterfly->contiguous()[i + count].setWithoutWriteBarrier(v); } @@ -915,10 +922,17 @@ bool JSArray::unshiftCountWithAnyIndexingType(ExecState* exec, unsigned startInd ensureLength(exec->vm(), oldLength + count); + // We have to check for holes before we start moving things around so that we don't get halfway + // through shifting and then realize we should have been in ArrayStorage mode. for (unsigned i = oldLength; i-- > startIndex;) { double v = m_butterfly->contiguousDouble()[i]; if (UNLIKELY(v != v)) return unshiftCountWithArrayStorage(exec, startIndex, count, ensureArrayStorage(exec->vm())); + } + + for (unsigned i = oldLength; i-- > startIndex;) { + double v = m_butterfly->contiguousDouble()[i]; + ASSERT(v == v); m_butterfly->contiguousDouble()[i + count] = v; } diff --git a/Source/JavaScriptCore/runtime/JSObject.cpp b/Source/JavaScriptCore/runtime/JSObject.cpp index 01dc96333..5637e2090 100644 --- a/Source/JavaScriptCore/runtime/JSObject.cpp +++ b/Source/JavaScriptCore/runtime/JSObject.cpp @@ -595,7 +595,7 @@ void JSObject::notifyPresenceOfIndexedAccessors(VM& vm) if (mayInterceptIndexedAccesses()) return; - setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AddIndexedAccessors)); + setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AddIndexedAccessors), m_butterfly); if (!vm.prototypeMap.isPrototype(this)) return; @@ -681,7 +681,7 @@ ArrayStorage* JSObject::createInitialArrayStorage(VM& vm) ContiguousJSValues JSObject::convertUndecidedToInt32(VM& vm) { ASSERT(hasUndecided(structure()->indexingType())); - setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateInt32)); + setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateInt32), m_butterfly); return m_butterfly->contiguousInt32(); } @@ -692,14 +692,14 @@ ContiguousDoubles JSObject::convertUndecidedToDouble(VM& vm) for (unsigned i = m_butterfly->vectorLength(); i--;) m_butterfly->contiguousDouble()[i] = QNaN; - setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateDouble)); + setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateDouble), m_butterfly); return m_butterfly->contiguousDouble(); } ContiguousJSValues JSObject::convertUndecidedToContiguous(VM& vm) { ASSERT(hasUndecided(structure()->indexingType())); - setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateContiguous)); + setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateContiguous), m_butterfly); return m_butterfly->contiguous(); } @@ -765,7 +765,7 @@ ContiguousDoubles JSObject::convertInt32ToDouble(VM& vm) *currentAsDouble = v.asInt32(); } - setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateDouble)); + setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateDouble), m_butterfly); return m_butterfly->contiguousDouble(); } @@ -773,7 +773,7 @@ ContiguousJSValues JSObject::convertInt32ToContiguous(VM& vm) { ASSERT(hasInt32(structure()->indexingType())); - setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateContiguous)); + setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateContiguous), m_butterfly); return m_butterfly->contiguous(); } @@ -831,7 +831,7 @@ ContiguousJSValues JSObject::genericConvertDoubleToContiguous(VM& vm) currentAsValue->setWithoutWriteBarrier(v); } - setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateContiguous)); + setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateContiguous), m_butterfly); return m_butterfly->contiguous(); } @@ -1129,7 +1129,7 @@ void JSObject::switchToSlowPutArrayStorage(VM& vm) case NonArrayWithArrayStorage: case ArrayWithArrayStorage: { Structure* newStructure = Structure::nonPropertyTransition(vm, structure(), SwitchToSlowPutArrayStorage); - setStructure(vm, newStructure); + setStructure(vm, newStructure, m_butterfly); break; } @@ -1153,7 +1153,7 @@ void JSObject::setPrototype(VM& vm, JSValue prototype) vm.prototypeMap.addPrototype(asObject(prototype)); Structure* newStructure = Structure::changePrototypeTransition(vm, structure(), prototype); - setStructure(vm, newStructure); + setStructure(vm, newStructure, m_butterfly); if (!newStructure->anyObjectInChainMayInterceptIndexedAccesses()) return; @@ -1213,7 +1213,7 @@ void JSObject::putDirectAccessor(ExecState* exec, PropertyName propertyName, JSV // getters and setters, though, we also need to change our Structure // if we override an existing non-getter or non-setter. if (slot.type() != PutPropertySlot::NewProperty) - setStructure(vm, Structure::attributeChangeTransition(vm, structure(), propertyName, attributes)); + setStructure(vm, Structure::attributeChangeTransition(vm, structure(), propertyName, attributes), m_butterfly); if (attributes & ReadOnly) structure()->setContainsReadOnlyProperties(); @@ -1570,7 +1570,7 @@ void JSObject::seal(VM& vm) if (isSealed(vm)) return; preventExtensions(vm); - setStructure(vm, Structure::sealTransition(vm, structure())); + setStructure(vm, Structure::sealTransition(vm, structure()), m_butterfly); } void JSObject::freeze(VM& vm) @@ -1578,14 +1578,14 @@ void JSObject::freeze(VM& vm) if (isFrozen(vm)) return; preventExtensions(vm); - setStructure(vm, Structure::freezeTransition(vm, structure())); + setStructure(vm, Structure::freezeTransition(vm, structure()), m_butterfly); } void JSObject::preventExtensions(VM& vm) { enterDictionaryIndexingMode(vm); if (isExtensible()) - setStructure(vm, Structure::preventExtensionsTransition(vm, structure())); + setStructure(vm, Structure::preventExtensionsTransition(vm, structure()), m_butterfly); } // This presently will flatten to an uncachable dictionary; this is suitable @@ -1603,7 +1603,7 @@ void JSObject::reifyStaticFunctionsForDelete(ExecState* exec) } if (!structure()->isUncacheableDictionary()) - setStructure(vm, Structure::toUncacheableDictionaryTransition(vm, structure())); + setStructure(vm, Structure::toUncacheableDictionaryTransition(vm, structure()), m_butterfly); for (const ClassInfo* info = classInfo(); info; info = info->parentClass) { const HashTable* hashTable = info->propHashTable(globalObject()->globalExec()); @@ -1633,7 +1633,7 @@ bool JSObject::removeDirect(VM& vm, PropertyName propertyName) return true; } - setStructure(vm, Structure::removePropertyTransition(vm, structure(), propertyName, offset)); + setStructure(vm, Structure::removePropertyTransition(vm, structure(), propertyName, offset), m_butterfly); if (offset == invalidOffset) return false; putDirectUndefined(offset); diff --git a/Source/JavaScriptCore/runtime/JSObject.h b/Source/JavaScriptCore/runtime/JSObject.h index c62dc2aec..7a78a46a6 100644 --- a/Source/JavaScriptCore/runtime/JSObject.h +++ b/Source/JavaScriptCore/runtime/JSObject.h @@ -595,6 +595,7 @@ public: void setButterfly(VM&, Butterfly*, Structure*); void setButterflyWithoutChangingStructure(Butterfly*); // You probably don't want to call this. + void setStructure(VM&, Structure*, Butterfly* = 0); void setStructureAndReallocateStorageIfNecessary(VM&, unsigned oldCapacity, Structure*); void setStructureAndReallocateStorageIfNecessary(VM&, Structure*); @@ -1109,7 +1110,7 @@ inline void JSObject::setButterfly(VM& vm, Butterfly* butterfly, Structure* stru { ASSERT(structure); ASSERT(!butterfly == (!structure->outOfLineCapacity() && !hasIndexingHeader(structure->indexingType()))); - setStructure(vm, structure); + setStructure(vm, structure, butterfly); m_butterfly = butterfly; } @@ -1316,7 +1317,7 @@ inline bool JSObject::putDirectInternal(VM& vm, PropertyName propertyName, JSVal return true; } // case (2) Despecify, fall through to (3). - setStructure(vm, Structure::despecifyFunctionTransition(vm, structure(), propertyName)); + setStructure(vm, Structure::despecifyFunctionTransition(vm, structure(), propertyName), m_butterfly); } // case (3) set the slot, do the put, return. @@ -1344,12 +1345,18 @@ inline bool JSObject::putDirectInternal(VM& vm, PropertyName propertyName, JSVal return true; } +inline void JSObject::setStructure(VM& vm, Structure* structure, Butterfly* butterfly) +{ + JSCell::setStructure(vm, structure); + ASSERT_UNUSED(butterfly, !butterfly == !(structure->outOfLineCapacity() || hasIndexingHeader(structure->indexingType()))); +} + inline void JSObject::setStructureAndReallocateStorageIfNecessary(VM& vm, unsigned oldCapacity, Structure* newStructure) { ASSERT(oldCapacity <= newStructure->outOfLineCapacity()); if (oldCapacity == newStructure->outOfLineCapacity()) { - setStructure(vm, newStructure); + setStructure(vm, newStructure, m_butterfly); return; } diff --git a/Source/JavaScriptCore/runtime/NumericStrings.h b/Source/JavaScriptCore/runtime/NumericStrings.h index 4cd92fc1f..68bfbd06a 100644 --- a/Source/JavaScriptCore/runtime/NumericStrings.h +++ b/Source/JavaScriptCore/runtime/NumericStrings.h @@ -37,7 +37,7 @@ namespace JSC { ALWAYS_INLINE String add(double d) { CacheEntry<double>& entry = lookup(d); - if (d == entry.key && !entry.value.isNull()) + if (!entry.value.isNull() && d == entry.key) return entry.value; entry.key = d; entry.value = String::numberToStringECMAScript(d); @@ -49,7 +49,7 @@ namespace JSC { if (static_cast<unsigned>(i) < cacheSize) return lookupSmallString(static_cast<unsigned>(i)); CacheEntry<int>& entry = lookup(i); - if (i == entry.key && !entry.value.isNull()) + if (!entry.value.isNull() && i == entry.key) return entry.value; entry.key = i; entry.value = String::number(i); @@ -61,7 +61,7 @@ namespace JSC { if (i < cacheSize) return lookupSmallString(static_cast<unsigned>(i)); CacheEntry<unsigned>& entry = lookup(i); - if (i == entry.key && !entry.value.isNull()) + if (!entry.value.isNull() && i == entry.key) return entry.value; entry.key = i; entry.value = String::number(i); diff --git a/Source/JavaScriptCore/runtime/Structure.cpp b/Source/JavaScriptCore/runtime/Structure.cpp index f551eaecc..950728cca 100644 --- a/Source/JavaScriptCore/runtime/Structure.cpp +++ b/Source/JavaScriptCore/runtime/Structure.cpp @@ -649,6 +649,12 @@ Structure* Structure::flattenDictionaryStructure(VM& vm, JSObject* object) } m_dictionaryKind = NoneDictionaryKind; + + // If the object had a Butterfly but after flattening/compacting we no longer have need of it, + // we need to zero it out because the collector depends on the Structure to know the size for copying. + if (object->butterfly() && !this->outOfLineCapacity() && !hasIndexingHeader(this->indexingType())) + object->setButterfly(vm, 0, this); + return this; } diff --git a/Source/WTF/WTF.pri b/Source/WTF/WTF.pri index a2f6aaa1b..4c0d1908e 100644 --- a/Source/WTF/WTF.pri +++ b/Source/WTF/WTF.pri @@ -14,12 +14,10 @@ mac { INCLUDEPATH = $${ROOT_WEBKIT_DIR}/Source/WTF/icu $$INCLUDEPATH LIBS += -licucore } else { - contains(QT_CONFIG,icu) { - win32: LIBS += -licuin -licuuc -licudt - else:!contains(QT_CONFIG,no-pkg-config):packagesExist("icu-i18n"): PKGCONFIG *= icu-i18n - else:android: LIBS += -licui18n -licuuc - else: LIBS += -licui18n -licuuc -licudata - } + win32: LIBS += -licuin -licuuc -licudt + else:!contains(QT_CONFIG,no-pkg-config):packagesExist("icu-i18n"): PKGCONFIG *= icu-i18n + else:android: LIBS += -licui18n -licuuc + else: LIBS += -licui18n -licuuc -licudata } use?(GLIB) { diff --git a/Source/WTF/wtf/CurrentTime.cpp b/Source/WTF/wtf/CurrentTime.cpp index e7326df04..0a4dea454 100644 --- a/Source/WTF/wtf/CurrentTime.cpp +++ b/Source/WTF/wtf/CurrentTime.cpp @@ -296,6 +296,8 @@ double monotonicallyIncreasingTime() { ASSERT(QElapsedTimer::isMonotonic()); static QElapsedTimer timer; + if (!timer.isValid()) + timer.start(); return timer.nsecsElapsed() / 1.0e9; } diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h index 1339642b4..688fdf494 100644 --- a/Source/WTF/wtf/Platform.h +++ b/Source/WTF/wtf/Platform.h @@ -115,15 +115,19 @@ || defined(_M_PPC) \ || defined(__PPC) #define WTF_CPU_PPC 1 +#ifndef __LITTLE_ENDIAN__ #define WTF_CPU_BIG_ENDIAN 1 #endif +#endif /* CPU(PPC64) - PowerPC 64-bit */ #if defined(__ppc64__) \ || defined(__PPC64__) #define WTF_CPU_PPC64 1 +#ifndef __LITTLE_ENDIAN__ #define WTF_CPU_BIG_ENDIAN 1 #endif +#endif /* CPU(SH4) - SuperH SH-4 */ #if defined(__SH4__) diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri index b6da87496..c16ac36ab 100644 --- a/Source/WebCore/Target.pri +++ b/Source/WebCore/Target.pri @@ -4190,15 +4190,15 @@ use?(3D_GRAPHICS) { INCLUDEPATH += $$PWD/platform/graphics/gpu - contains(QT_CONFIG, opengl) | contains(QT_CONFIG, opengles2) { - !contains(QT_CONFIG, opengles2) { - SOURCES += \ - platform/graphics/opengl/GraphicsContext3DOpenGL.cpp \ - platform/graphics/opengl/Extensions3DOpenGL.cpp - } else { + contains(QT_CONFIG, opengl) { + contains(QT_CONFIG, opengles2) { SOURCES += \ platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp \ platform/graphics/opengl/Extensions3DOpenGLES.cpp + } else { + SOURCES += \ + platform/graphics/opengl/GraphicsContext3DOpenGL.cpp \ + platform/graphics/opengl/Extensions3DOpenGL.cpp } HEADERS += platform/graphics/opengl/Extensions3DOpenGL.h @@ -4210,7 +4210,6 @@ use?(3D_GRAPHICS) { WEBKIT += angle - CONFIG += opengl-shims INCLUDEPATH += platform/graphics/gpu } diff --git a/Source/WebCore/dom/make_names.pl b/Source/WebCore/dom/make_names.pl index 049763ab7..0eb05491e 100755 --- a/Source/WebCore/dom/make_names.pl +++ b/Source/WebCore/dom/make_names.pl @@ -390,6 +390,10 @@ sub printConstructorInterior my ($F, $tagName, $interfaceName, $constructorTagName) = @_; # Handle media elements. + # Note that wrapperOnlyIfMediaIsAvailable is a misnomer, because media availability + # does not just control the wrapper; it controls the element object that is created. + # FIXME: Could we instead do this entirely in the wrapper, and use custom wrappers + # instead of having all the support for this here in this script? if ($enabledTags{$tagName}{wrapperOnlyIfMediaIsAvailable}) { print F <<END Settings* settings = document->settings(); @@ -1042,14 +1046,11 @@ sub printWrapperFunctions print F "#if ${conditionalString}\n\n"; } - # Hack for the media tags - # FIXME: This should have been done via a CustomWrapper attribute and a separate *Custom file. if ($enabledTags{$tagName}{wrapperOnlyIfMediaIsAvailable}) { print F <<END static JSDOMWrapper* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<$parameters{namespace}Element> element) { - Settings* settings = element->document()->settings(); - if (!MediaPlayer::isAvailable() || (settings && !settings->mediaEnabled())) + if (element->isHTMLUnknownElement()) return CREATE_DOM_WRAPPER(exec, globalObject, $parameters{namespace}Element, element.get()); return CREATE_DOM_WRAPPER(exec, globalObject, ${JSInterfaceName}, element.get()); } diff --git a/Source/WebCore/html/HTMLAudioElement.h b/Source/WebCore/html/HTMLAudioElement.h index 07ca48dd4..0d2483668 100644 --- a/Source/WebCore/html/HTMLAudioElement.h +++ b/Source/WebCore/html/HTMLAudioElement.h @@ -43,14 +43,19 @@ private: HTMLAudioElement(const QualifiedName&, Document*, bool); }; -inline bool isHTMLAudioElement(Node* node) +inline bool isHTMLAudioElement(HTMLElement* element) { - return node->hasTagName(HTMLNames::audioTag); + return !element->isHTMLUnknownElement() && element->hasTagName(HTMLNames::audioTag); } inline bool isHTMLAudioElement(Element* element) { - return element->hasTagName(HTMLNames::audioTag); + return element->isHTMLElement() && isHTMLAudioElement(toHTMLElement(element)); +} + +inline bool isHTMLAudioElement(Node* node) +{ + return node->isHTMLElement() && isHTMLAudioElement(toHTMLElement(node)); } inline HTMLAudioElement* toHTMLAudioElement(Node* node) diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp index 8ef0348ab..fc8578e57 100644 --- a/Source/WebCore/html/HTMLMediaElement.cpp +++ b/Source/WebCore/html/HTMLMediaElement.cpp @@ -2379,6 +2379,13 @@ double HTMLMediaElement::duration() const bool HTMLMediaElement::paused() const { + // As of this writing, JavaScript garbage collection calls this function directly. In the past + // we had problems where this was called on an object after a bad cast. The assertion below + // made our regression test detect the problem, so we should keep it because of that. But note + // that the value of the assertion relies on the compiler not being smart enough to know that + // isHTMLUnknownElement is guaranteed to return false for an HTMLMediaElement. + ASSERT(!isHTMLUnknownElement()); + return m_paused; } diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h index d6f57baf6..f65608eb3 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext3D.h +++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h @@ -59,6 +59,7 @@ QT_BEGIN_NAMESPACE class QPainter; class QRect; class QOpenGLContext; +class QOpenGLExtensions; class QSurface; QT_END_NAMESPACE #elif PLATFORM(GTK) || PLATFORM(EFL) @@ -84,14 +85,9 @@ const Platform3DObject NullPlatform3DObject = 0; namespace WebCore { class DrawingBuffer; class Extensions3D; -#if USE(OPENGL_ES_2) +class Extensions3DOpenGLCommon; class Extensions3DOpenGLES; -#else class Extensions3DOpenGL; -#endif -#if PLATFORM(QT) -class Extensions3DQt; -#endif class HostWindow; class Image; class ImageBuffer; @@ -1013,16 +1009,11 @@ private: String mappedSymbolName(Platform3DObject program, ANGLEShaderSymbolType, const String& name); String originalSymbolName(Platform3DObject program, ANGLEShaderSymbolType, const String& name); - ANGLEWebKitBridge m_compiler; #endif -#if PLATFORM(BLACKBERRY) || (PLATFORM(QT) && defined(QT_OPENGL_ES_2)) || ((PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)) && USE(OPENGL_ES_2)) - friend class Extensions3DOpenGLES; - OwnPtr<Extensions3DOpenGLES> m_extensions; -#else + OwnPtr<Extensions3DOpenGLCommon> m_extensions; friend class Extensions3DOpenGL; - OwnPtr<Extensions3DOpenGL> m_extensions; -#endif + friend class Extensions3DOpenGLES; friend class Extensions3DOpenGLCommon; Attributes m_attrs; @@ -1066,6 +1057,10 @@ private: // Errors raised by synthesizeGLError(). ListHashSet<GC3Denum> m_syntheticErrors; +#if PLATFORM(QT) + QOpenGLExtensions* m_functions; +#endif + #if PLATFORM(BLACKBERRY) bool m_isImaginationHardware; #endif @@ -1074,6 +1069,7 @@ private: friend class GraphicsContext3DPrivate; OwnPtr<GraphicsContext3DPrivate> m_private; #endif + ANGLEWebKitBridge m_compiler; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp index 2a02afbab..8f6077de1 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp @@ -51,7 +51,7 @@ #include <gst/interfaces/streamvolume.h> #endif -#if GST_CHECK_VERSION(1, 1, 0) && USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) +#if GST_CHECK_VERSION(1, 1, 0) && USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS) #include "TextureMapperGL.h" #endif diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp index 0905c9213..7c326f593 100644 --- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp +++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp @@ -30,44 +30,68 @@ #include "Extensions3DOpenGL.h" #include "GraphicsContext3D.h" +#include "NotImplemented.h" #include <wtf/Vector.h> #if PLATFORM(MAC) #include "ANGLE/ShaderLang.h" #include <OpenGL/gl.h> +#elif PLATFORM(QT) +#include <private/qopenglextensions_p.h> +#include <private/qopenglvertexarrayobject_p.h> #elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) || PLATFORM(WIN) #include "OpenGLShims.h" #endif +// Note this implementation serves a double role for Qt where it also handles OpenGLES. + namespace WebCore { Extensions3DOpenGL::Extensions3DOpenGL(GraphicsContext3D* context) : Extensions3DOpenGLCommon(context) { +#if PLATFORM(QT) + context->makeContextCurrent(); + m_vaoFunctions = new QOpenGLVertexArrayObjectHelper(context->platformGraphicsContext3D()); +#endif } Extensions3DOpenGL::~Extensions3DOpenGL() { +#if PLATFORM(QT) + delete m_vaoFunctions; + m_vaoFunctions = 0; +#endif } - void Extensions3DOpenGL::blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter) { +#if PLATFORM(QT) + m_context->m_functions->glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); +#else ::glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); +#endif } void Extensions3DOpenGL::renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) { +#if PLATFORM(QT) + m_context->m_functions->glRenderbufferStorageMultisample(target, samples, internalformat, width, height); +#else ::glRenderbufferStorageMultisampleEXT(target, samples, internalformat, width, height); +#endif } Platform3DObject Extensions3DOpenGL::createVertexArrayOES() { m_context->makeContextCurrent(); GLuint array = 0; -#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL)) || PLATFORM(WIN) +#if (PLATFORM(GTK) || PLATFORM(EFL)) || PLATFORM(WIN) if (isVertexArrayObjectSupported()) glGenVertexArrays(1, &array); +#elif PLATFORM(QT) + if (isVertexArrayObjectSupported()) + m_vaoFunctions->glGenVertexArrays(1, &array); #elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object glGenVertexArraysAPPLE(1, &array); #endif @@ -80,9 +104,12 @@ void Extensions3DOpenGL::deleteVertexArrayOES(Platform3DObject array) return; m_context->makeContextCurrent(); -#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(WIN)) +#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)) if (isVertexArrayObjectSupported()) glDeleteVertexArrays(1, &array); +#elif PLATFORM(QT) + if (isVertexArrayObjectSupported()) + m_vaoFunctions->glDeleteVertexArrays(1, &array); #elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object glDeleteVertexArraysAPPLE(1, &array); #endif @@ -94,21 +121,29 @@ GC3Dboolean Extensions3DOpenGL::isVertexArrayOES(Platform3DObject array) return GL_FALSE; m_context->makeContextCurrent(); -#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(WIN)) +#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)) if (isVertexArrayObjectSupported()) return glIsVertexArray(array); +#elif PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) + if (isVertexArrayObjectSupported()) + return m_vaoFunctions->glIsVertexArray(array); #elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object return glIsVertexArrayAPPLE(array); #endif + + m_context->synthesizeGLError(GL_INVALID_OPERATION); return GL_FALSE; } void Extensions3DOpenGL::bindVertexArrayOES(Platform3DObject array) { m_context->makeContextCurrent(); -#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(WIN)) +#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)) if (isVertexArrayObjectSupported()) glBindVertexArray(array); +#elif PLATFORM(QT) + if (isVertexArrayObjectSupported()) + m_vaoFunctions->glBindVertexArray(array); #elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object glBindVertexArrayAPPLE(array); #else @@ -144,39 +179,56 @@ bool Extensions3DOpenGL::supportsExtension(const String& name) { // GL_ANGLE_framebuffer_blit and GL_ANGLE_framebuffer_multisample are "fake". They are implemented using other // extensions. In particular GL_EXT_framebuffer_blit and GL_EXT_framebuffer_multisample +#if PLATFORM(QT) + if (name == "GL_ANGLE_framebuffer_blit" || name == "GL_EXT_framebuffer_blit") + return m_context->m_functions->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit); + if (name == "GL_ANGLE_framebuffer_multisample" || name == "GL_EXT_framebuffer_multisample") + return m_context->m_functions->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample); + + if (name == "GL_OES_texture_npot" || name == "GL_ARB_texture_non_power_of_two") + return m_context->m_functions->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures); + if (name == "GL_OES_packed_depth_stencil" || name == "GL_EXT_packed_depth_stencil") + return m_context->m_functions->hasOpenGLExtension(QOpenGLExtensions::PackedDepthStencil); + + // FIXME: We don't have the robustness methods from Extensions3DOpenGLES. + if (name == "GL_EXT_robustness") + return false; +#else if (name == "GL_ANGLE_framebuffer_blit") return m_availableExtensions.contains("GL_EXT_framebuffer_blit"); if (name == "GL_ANGLE_framebuffer_multisample") return m_availableExtensions.contains("GL_EXT_framebuffer_multisample"); - - // Desktop GL always supports GL_OES_rgb8_rgba8. - if (name == "GL_OES_rgb8_rgba8") - return true; - - // If GL_ARB_texture_float is available then we report GL_OES_texture_float and - // GL_OES_texture_half_float as available. - if (name == "GL_OES_texture_float" || name == "GL_OES_texture_half_float") - return m_availableExtensions.contains("GL_ARB_texture_float"); +#endif // GL_OES_vertex_array_object if (name == "GL_OES_vertex_array_object") { -#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL)) +#if (PLATFORM(GTK) || PLATFORM(EFL)) return m_availableExtensions.contains("GL_ARB_vertex_array_object"); +#elif PLATFORM(QT) + return isVertexArrayObjectSupported(); #else return m_availableExtensions.contains("GL_APPLE_vertex_array_object"); #endif } - // Desktop GL always supports the standard derivative functions - if (name == "GL_OES_standard_derivatives") - return true; + if (!m_context->isGLES2Compliant()) { + // Desktop GL always supports GL_OES_rgb8_rgba8. + if (name == "GL_OES_rgb8_rgba8") + return true; + + // If GL_ARB_texture_float is available then we report GL_OES_texture_float and + // GL_OES_texture_half_float as available. + if (name == "GL_OES_texture_float" || name == "GL_OES_texture_half_float") + return m_availableExtensions.contains("GL_ARB_texture_float"); - // Desktop GL always supports UNSIGNED_INT indices - if (name == "GL_OES_element_index_uint") - return true; + // Desktop GL always supports the standard derivative functions + if (name == "GL_OES_standard_derivatives") + return true; - if (name == "GL_EXT_texture_filter_anisotropic") - return m_availableExtensions.contains("GL_EXT_texture_filter_anisotropic"); + // Desktop GL always supports UNSIGNED_INT indices + if (name == "GL_OES_element_index_uint") + return true; + } if (name == "GL_EXT_draw_buffers") { #if PLATFORM(MAC) @@ -202,15 +254,24 @@ void Extensions3DOpenGL::drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs) String Extensions3DOpenGL::getExtensions() { +#if PLATFORM(QT) + return String(reinterpret_cast<const char*>(m_context->m_functions->glGetString(GL_EXTENSIONS))); +#else return String(reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS))); +#endif } -#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(WIN)) +#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)) bool Extensions3DOpenGL::isVertexArrayObjectSupported() { static const bool supportsVertexArrayObject = supports("GL_OES_vertex_array_object"); return supportsVertexArrayObject; } +#elif PLATFORM(QT) +bool Extensions3DOpenGL::isVertexArrayObjectSupported() +{ + return m_vaoFunctions && m_vaoFunctions->isValid(); +} #endif } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h index f9d69e9f4..45eacea6a 100644 --- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h +++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h @@ -32,6 +32,12 @@ #include <wtf/HashSet.h> #include <wtf/text/StringHash.h> +#if PLATFORM(QT) +QT_BEGIN_NAMESPACE +class QOpenGLVertexArrayObjectHelper; +QT_END_NAMESPACE +#endif + namespace WebCore { class Extensions3DOpenGL : public Extensions3DOpenGLCommon { @@ -64,6 +70,10 @@ protected: private: bool isVertexArrayObjectSupported(); #endif + +#if PLATFORM(QT) + QOpenGLVertexArrayObjectHelper *m_vaoFunctions; +#endif }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp index f413a675a..29a13c842 100644 --- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp +++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp @@ -36,7 +36,9 @@ #include <BlackBerryPlatformLog.h> #endif -#if USE(OPENGL_ES_2) +#if PLATFORM(QT) +#include <private/qopenglextensions_p.h> +#elif USE(OPENGL_ES_2) #include "OpenGLESShims.h" #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> @@ -60,7 +62,7 @@ Extensions3DOpenGLCommon::Extensions3DOpenGLCommon(GraphicsContext3D* context) , m_maySupportMultisampling(true) , m_requiresBuiltInFunctionEmulation(false) { - m_vendor = String(reinterpret_cast<const char*>(::glGetString(GL_VENDOR))); + m_vendor = String(reinterpret_cast<const char*>(m_context->m_functions->glGetString(GL_VENDOR))); Vector<String> vendorComponents; m_vendor.lower().split(' ', vendorComponents); diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp index 662bb02f6..32e0e4cbf 100644 --- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp +++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp @@ -201,10 +201,9 @@ void Extensions3DOpenGLES::setEXTContextLostCallback(PassOwnPtr<GraphicsContext3 void Extensions3DOpenGLES::readnPixelsEXT(int x, int y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, GC3Dsizei bufSize, void *data) { if (m_glReadnPixelsEXT) { - m_context->makeContextCurrent(); // FIXME: remove the two glFlush calls when the driver bug is fixed, i.e., // all previous rendering calls should be done before reading pixels. - ::glFlush(); + m_context->flush(); // FIXME: If non-BlackBerry platforms use this, they will need to implement // their anti-aliasing code here. diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp index fbdca0e07..a6b7c8578 100644 --- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp +++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp @@ -1,6 +1,9 @@ /* * Copyright (C) 2010 Apple Inc. All rights reserved. * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 ChangSeok Oh <shivamidow@gmail.com> + * Copyright (C) 2012 Research In Motion Limited. All rights reserved. + * Copyright (C) 2014 Digia Plc. and/or its subsidiary(-ies). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -21,11 +24,13 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" +// Note this implementation serves a double role for Qt where it also handles OpenGLES. + #if USE(3D_GRAPHICS) #include "GraphicsContext3D.h" @@ -35,85 +40,128 @@ #include "IntSize.h" #include "NotImplemented.h" -#include <algorithm> -#include <cstring> -#include <wtf/MainThread.h> -#include <wtf/text/CString.h> +#include <QOpenGLContext> +#include <private/qopenglextensions_p.h> + +#ifndef GL_BGRA +#define GL_BGRA 0x80E1 +#endif + +#ifndef GL_READ_FRAMEBUFFER +#define GL_READ_FRAMEBUFFER 0x8CA8 +#endif + +#ifndef GL_DRAW_FRAMEBUFFER +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#endif -#if PLATFORM(MAC) -#include <OpenGL/gl.h> -#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) || PLATFORM(WIN) -#include "OpenGLShims.h" +#ifndef GL_MAX_VARYING_FLOATS +#define GL_MAX_VARYING_FLOATS 0x8B4B +#endif + +#ifndef GL_ALPHA16F_ARB +#define GL_ALPHA16F_ARB 0x881C +#endif + +#ifndef GL_LUMINANCE16F_ARB +#define GL_LUMINANCE16F_ARB 0x881E +#endif + +#ifndef GL_LUMINANCE_ALPHA16F_ARB +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_HALF_FLOAT_OES +#define GL_HALF_FLOAT_OES 0x8D61 #endif namespace WebCore { void GraphicsContext3D::releaseShaderCompiler() { + ASSERT(m_private); makeContextCurrent(); - notImplemented(); + m_functions->glReleaseShaderCompiler(); } void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels) { - ::glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels); + ASSERT(m_private); + bool readBGRA = !isGLES2Compliant() || platformGraphicsContext3D()->hasExtension("GL_EXT_read_format_bgra"); + + if (readBGRA) + m_functions->glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, pixels); + else + m_functions->glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + int totalBytes = width * height * 4; + if (!readBGRA) { + for (int i = 0; i < totalBytes; i += 4) + std::swap(pixels[i], pixels[i + 2]); // Convert to BGRA. + } } void GraphicsContext3D::validateAttributes() { - validateDepthStencil("GL_EXT_packed_depth_stencil"); + if (isGLES2Compliant()) + validateDepthStencil("GL_OES_packed_depth_stencil"); + else + validateDepthStencil("GL_EXT_packed_depth_stencil"); + + if (m_attrs.antialias && isGLES2Compliant()) { + if (!m_functions->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample) || !m_functions->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit)) + m_attrs.antialias = false; + } } bool GraphicsContext3D::reshapeFBOs(const IntSize& size) { const int width = size.width(); const int height = size.height(); - GLuint colorFormat, internalDepthStencilFormat = 0; + GLuint colorFormat = 0, pixelDataType = 0; if (m_attrs.alpha) { - m_internalColorFormat = GL_RGBA8; + m_internalColorFormat = isGLES2Compliant() ? GL_RGBA : GL_RGBA8; colorFormat = GL_RGBA; + pixelDataType = GL_UNSIGNED_BYTE; } else { - m_internalColorFormat = GL_RGB8; + m_internalColorFormat = isGLES2Compliant() ? GL_RGB : GL_RGB8; colorFormat = GL_RGB; + pixelDataType = isGLES2Compliant() ? GL_UNSIGNED_SHORT_5_6_5 : GL_UNSIGNED_BYTE; } - if (m_attrs.stencil || m_attrs.depth) { - // We don't allow the logic where stencil is required and depth is not. - // See GraphicsContext3D::validateAttributes. - Extensions3D* extensions = getExtensions(); - // Use a 24 bit depth buffer where we know we have it. - if (extensions->supports("GL_EXT_packed_depth_stencil")) - internalDepthStencilFormat = GL_DEPTH24_STENCIL8_EXT; - else - internalDepthStencilFormat = GL_DEPTH_COMPONENT; - } + // We don't allow the logic where stencil is required and depth is not. + bool supportPackedDepthStencilBuffer = false; + if (m_attrs.stencil || m_attrs.depth) + supportPackedDepthStencilBuffer = m_functions->hasOpenGLExtension(QOpenGLExtensions::PackedDepthStencil); bool mustRestoreFBO = false; // Resize multisample FBO. - if (m_attrs.antialias) { + if (m_attrs.antialias && !isGLES2Compliant()) { GLint maxSampleCount; - ::glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSampleCount); + m_functions->glGetIntegerv(GL_MAX_SAMPLES, &maxSampleCount); GLint sampleCount = std::min(8, maxSampleCount); if (sampleCount > maxSampleCount) sampleCount = maxSampleCount; if (m_state.boundFBO != m_multisampleFBO) { - ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO); + m_functions->glBindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); mustRestoreFBO = true; } - ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleColorBuffer); - ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, m_internalColorFormat, width, height); - ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, m_multisampleColorBuffer); + m_functions->glBindRenderbuffer(GL_RENDERBUFFER, m_multisampleColorBuffer); + m_functions->glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, m_internalColorFormat, width, height); + m_functions->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_multisampleColorBuffer); if (m_attrs.stencil || m_attrs.depth) { - ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer); - ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, internalDepthStencilFormat, width, height); + m_functions->glBindRenderbuffer(GL_RENDERBUFFER, m_multisampleDepthStencilBuffer); + if (supportPackedDepthStencilBuffer) + m_functions->glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_DEPTH24_STENCIL8, width, height); + else + m_functions->glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_DEPTH_COMPONENT, width, height); if (m_attrs.stencil) - ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer); + m_functions->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer); if (m_attrs.depth) - ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer); + m_functions->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer); } - ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); - if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) { + m_functions->glBindRenderbuffer(GL_RENDERBUFFER, 0); + if (m_functions->glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { // FIXME: cleanup. notImplemented(); } @@ -122,30 +170,52 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size) // resize regular FBO if (m_state.boundFBO != m_fbo) { mustRestoreFBO = true; - ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); + m_functions->glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); } - ::glBindTexture(GL_TEXTURE_2D, m_texture); - ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); - ::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0); - ::glBindTexture(GL_TEXTURE_2D, m_compositorTexture); - ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); - ::glBindTexture(GL_TEXTURE_2D, 0); + + m_functions->glBindTexture(GL_TEXTURE_2D, m_texture); + m_functions->glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, pixelDataType, 0); + m_functions->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0); + + m_functions->glBindTexture(GL_TEXTURE_2D, m_compositorTexture); + m_functions->glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, pixelDataType, 0); + m_functions->glBindTexture(GL_TEXTURE_2D, 0); + if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) { - ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthStencilBuffer); - ::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, internalDepthStencilFormat, width, height); - if (m_attrs.stencil) - ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer); - if (m_attrs.depth) - ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer); - ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); + // Use a 24 bit depth buffer where we know we have it. + if (supportPackedDepthStencilBuffer || !isGLES2Compliant()) { + m_functions->glBindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); + if (supportPackedDepthStencilBuffer) + m_functions->glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); + else + m_functions->glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height); + if (m_attrs.stencil) + m_functions->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); + if (m_attrs.depth) + m_functions->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); + m_functions->glBindRenderbuffer(GL_RENDERBUFFER, 0); + } else { + if (m_attrs.stencil) { + m_functions->glBindRenderbuffer(GL_RENDERBUFFER, m_stencilBuffer); + m_functions->glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height); + m_functions->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_stencilBuffer); + } + if (m_attrs.depth) { + m_functions->glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer); + m_functions->glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); + m_functions->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer); + } + m_functions->glBindRenderbuffer(GL_RENDERBUFFER, 0); + } } - if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) { + + if (m_functions->glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { // FIXME: cleanup notImplemented(); } - if (m_attrs.antialias) { - ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO); + if (m_attrs.antialias && !isGLES2Compliant()) { + m_functions->glBindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); if (m_state.boundFBO == m_multisampleFBO) mustRestoreFBO = false; } @@ -155,91 +225,83 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size) void GraphicsContext3D::resolveMultisamplingIfNecessary(const IntRect& rect) { - ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO); - ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo); + Q_ASSERT(m_private); + if (!m_attrs.antialias) + return; + + if (!isGLES2Compliant()) { + m_functions->glBindFramebuffer(GL_READ_FRAMEBUFFER, m_multisampleFBO); + m_functions->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo); - IntRect resolveRect = rect; - if (rect.isEmpty()) - resolveRect = IntRect(0, 0, m_currentWidth, m_currentHeight); + IntRect resolveRect = rect; + if (rect.isEmpty()) + resolveRect = IntRect(0, 0, m_currentWidth, m_currentHeight); - ::glBlitFramebufferEXT(resolveRect.x(), resolveRect.y(), resolveRect.maxX(), resolveRect.maxY(), resolveRect.x(), resolveRect.y(), resolveRect.maxX(), resolveRect.maxY(), GL_COLOR_BUFFER_BIT, GL_LINEAR); + m_functions->glBlitFramebuffer(resolveRect.x(), resolveRect.y(), resolveRect.maxX(), resolveRect.maxY(), resolveRect.x(), resolveRect.y(), resolveRect.maxX(), resolveRect.maxY(), GL_COLOR_BUFFER_BIT, GL_LINEAR); + } else { + notImplemented(); + } } void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) { makeContextCurrent(); - switch (internalformat) { - case DEPTH_STENCIL: - internalformat = GL_DEPTH24_STENCIL8_EXT; - break; - case DEPTH_COMPONENT16: - internalformat = GL_DEPTH_COMPONENT; - break; - case RGBA4: - case RGB5_A1: - internalformat = GL_RGBA; - break; - case RGB565: - internalformat = GL_RGB; - break; + if (!isGLES2Compliant()) { + switch (internalformat) { + case DEPTH_STENCIL: + internalformat = GL_DEPTH24_STENCIL8; + break; + case DEPTH_COMPONENT16: + internalformat = GL_DEPTH_COMPONENT; + break; + case RGBA4: + case RGB5_A1: + internalformat = GL_RGBA; + break; + case RGB565: + internalformat = GL_RGB; + break; + } } - ::glRenderbufferStorageEXT(target, internalformat, width, height); + m_functions->glRenderbufferStorage(target, internalformat, width, height); } void GraphicsContext3D::getIntegerv(GC3Denum pname, GC3Dint* value) { - // Need to emulate MAX_FRAGMENT/VERTEX_UNIFORM_VECTORS and MAX_VARYING_VECTORS - // because desktop GL's corresponding queries return the number of components - // whereas GLES2 return the number of vectors (each vector has 4 components). - // Therefore, the value returned by desktop GL needs to be divided by 4. makeContextCurrent(); - switch (pname) { - case MAX_FRAGMENT_UNIFORM_VECTORS: - ::glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, value); - *value /= 4; - break; - case MAX_VERTEX_UNIFORM_VECTORS: - ::glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, value); - *value /= 4; - break; - case MAX_VARYING_VECTORS: - ::glGetIntegerv(GL_MAX_VARYING_FLOATS, value); - *value /= 4; - break; - default: - ::glGetIntegerv(pname, value); + if (!isGLES2Compliant()) { + // Need to emulate MAX_FRAGMENT/VERTEX_UNIFORM_VECTORS and MAX_VARYING_VECTORS + // because desktop GL's corresponding queries return the number of components + // whereas GLES2 return the number of vectors (each vector has 4 components). + // Therefore, the value returned by desktop GL needs to be divided by 4. + switch (pname) { + case MAX_FRAGMENT_UNIFORM_VECTORS: + m_functions->glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, value); + *value /= 4; + break; + case MAX_VERTEX_UNIFORM_VECTORS: + m_functions->glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, value); + *value /= 4; + break; + case MAX_VARYING_VECTORS: + m_functions->glGetIntegerv(GL_MAX_VARYING_FLOATS, value); + *value /= 4; + break; + default: + m_functions->glGetIntegerv(pname, value); + } + } else { + m_functions->glGetIntegerv(pname, value); } } void GraphicsContext3D::getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision) { - UNUSED_PARAM(shaderType); ASSERT(range); ASSERT(precision); makeContextCurrent(); - - switch (precisionType) { - case GraphicsContext3D::LOW_INT: - case GraphicsContext3D::MEDIUM_INT: - case GraphicsContext3D::HIGH_INT: - // These values are for a 32-bit twos-complement integer format. - range[0] = 31; - range[1] = 30; - precision[0] = 0; - break; - case GraphicsContext3D::LOW_FLOAT: - case GraphicsContext3D::MEDIUM_FLOAT: - case GraphicsContext3D::HIGH_FLOAT: - // These values are for an IEEE single-precision floating-point format. - range[0] = 127; - range[1] = 127; - precision[0] = 23; - break; - default: - ASSERT_NOT_REACHED(); - break; - } + m_functions->glGetShaderPrecisionFormat(shaderType, precisionType, range, precision); } bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels) @@ -250,23 +312,25 @@ bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum inte } GC3Denum openGLInternalFormat = internalformat; - if (type == GL_FLOAT) { - if (format == GL_RGBA) - openGLInternalFormat = GL_RGBA32F_ARB; - else if (format == GL_RGB) - openGLInternalFormat = GL_RGB32F_ARB; - } else if (type == HALF_FLOAT_OES) { - if (format == GL_RGBA) - openGLInternalFormat = GL_RGBA16F_ARB; - else if (format == GL_RGB) - openGLInternalFormat = GL_RGB16F_ARB; - else if (format == GL_LUMINANCE) - openGLInternalFormat = GL_LUMINANCE16F_ARB; - else if (format == GL_ALPHA) - openGLInternalFormat = GL_ALPHA16F_ARB; - else if (format == GL_LUMINANCE_ALPHA) - openGLInternalFormat = GL_LUMINANCE_ALPHA16F_ARB; - type = GL_HALF_FLOAT_ARB; + if (!isGLES2Compliant()) { + if (type == GL_FLOAT) { + if (format == GL_RGBA) + openGLInternalFormat = GL_RGBA32F; + else if (format == GL_RGB) + openGLInternalFormat = GL_RGB32F; + } else if (type == GL_HALF_FLOAT_OES) { + if (format == GL_RGBA) + openGLInternalFormat = GL_RGBA16F; + else if (format == GL_RGB) + openGLInternalFormat = GL_RGB16F; + else if (format == GL_LUMINANCE) + openGLInternalFormat = GL_LUMINANCE16F_ARB; + else if (format == GL_ALPHA) + openGLInternalFormat = GL_ALPHA16F_ARB; + else if (format == GL_LUMINANCE_ALPHA) + openGLInternalFormat = GL_LUMINANCE_ALPHA16F_ARB; + type = GL_HALF_FLOAT; + } } texImage2DDirect(target, level, openGLInternalFormat, width, height, border, format, type, pixels); return true; @@ -275,13 +339,13 @@ bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum inte void GraphicsContext3D::depthRange(GC3Dclampf zNear, GC3Dclampf zFar) { makeContextCurrent(); - ::glDepthRange(zNear, zFar); + m_functions->glDepthRangef(zNear, zFar); } void GraphicsContext3D::clearDepth(GC3Dclampf depth) { makeContextCurrent(); - ::glClearDepth(depth); + m_functions->glClearDepthf(depth); } Extensions3D* GraphicsContext3D::getExtensions() @@ -293,18 +357,19 @@ Extensions3D* GraphicsContext3D::getExtensions() void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data) { + ASSERT(m_private); // FIXME: remove the two glFlush calls when the driver bug is fixed, i.e., // all previous rendering calls should be done before reading pixels. makeContextCurrent(); - ::glFlush(); + m_functions->glFlush(); if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) { resolveMultisamplingIfNecessary(IntRect(x, y, width, height)); - ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo); - ::glFlush(); + m_functions->glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); + m_functions->glFlush(); } - ::glReadPixels(x, y, width, height, format, type, data); + m_functions->glReadPixels(x, y, width, height, format, type, data); if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) - ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); + m_functions->glBindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); } } diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp index 9d46a4c3d..d4ace361f 100644 --- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp +++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp @@ -53,11 +53,13 @@ #include <wtf/Uint8Array.h> #include <wtf/text/CString.h> -#if USE(OPENGL_ES_2) +#if PLATFORM(QT) +#include <private/qopenglextensions_p.h> +#elif USE(OPENGL_ES_2) #include "OpenGLESShims.h" #elif PLATFORM(MAC) #include <OpenGL/gl.h> -#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) || PLATFORM(WIN) +#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) #include "OpenGLShims.h" #endif @@ -162,15 +164,15 @@ void GraphicsContext3D::prepareTexture() if (m_attrs.antialias) resolveMultisamplingIfNecessary(); - ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo); - ::glActiveTexture(GL_TEXTURE0); - ::glBindTexture(GL_TEXTURE_2D, m_compositorTexture); - ::glCopyTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, 0, 0, m_currentWidth, m_currentHeight, 0); - ::glBindTexture(GL_TEXTURE_2D, m_state.boundTexture0); - ::glActiveTexture(m_state.activeTexture); + m_functions->glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); + m_functions->glActiveTexture(GL_TEXTURE0); + m_functions->glBindTexture(GL_TEXTURE_2D, m_compositorTexture); + m_functions->glCopyTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, 0, 0, m_currentWidth, m_currentHeight, 0); + m_functions->glBindTexture(GL_TEXTURE_2D, m_state.boundTexture0); + m_functions->glActiveTexture(m_state.activeTexture); if (m_state.boundFBO != m_fbo) - ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO); - ::glFinish(); + m_functions->glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO); + m_functions->glFinish(); m_layerComposited = true; } #endif @@ -185,30 +187,30 @@ void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSi bool mustRestoreFBO = false; if (m_attrs.antialias) { resolveMultisamplingIfNecessary(); - ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo); + m_functions->glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); mustRestoreFBO = true; } else { if (m_state.boundFBO != m_fbo) { mustRestoreFBO = true; - ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo); + m_functions->glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); } } GLint packAlignment = 4; bool mustRestorePackAlignment = false; - ::glGetIntegerv(GL_PACK_ALIGNMENT, &packAlignment); + m_functions->glGetIntegerv(GL_PACK_ALIGNMENT, &packAlignment); if (packAlignment > 4) { - ::glPixelStorei(GL_PACK_ALIGNMENT, 4); + m_functions->glPixelStorei(GL_PACK_ALIGNMENT, 4); mustRestorePackAlignment = true; } readPixelsAndConvertToBGRAIfNecessary(0, 0, m_currentWidth, m_currentHeight, pixels); if (mustRestorePackAlignment) - ::glPixelStorei(GL_PACK_ALIGNMENT, packAlignment); + m_functions->glPixelStorei(GL_PACK_ALIGNMENT, packAlignment); if (mustRestoreFBO) - ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO); + m_functions->glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO); } void GraphicsContext3D::reshape(int width, int height) @@ -220,7 +222,7 @@ void GraphicsContext3D::reshape(int width, int height) return; #if (PLATFORM(QT) || PLATFORM(EFL)) && USE(GRAPHICS_SURFACE) - ::glFlush(); // Make sure all GL calls have been committed before resizing. + m_functions->glFlush(); // Make sure all GL calls have been committed before resizing. createGraphicsSurfaces(IntSize(width, height)); #endif @@ -240,54 +242,54 @@ void GraphicsContext3D::reshape(int width, int height) GLboolean isScissorEnabled = GL_FALSE; GLboolean isDitherEnabled = GL_FALSE; GLbitfield clearMask = GL_COLOR_BUFFER_BIT; - ::glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor); - ::glClearColor(0, 0, 0, 0); - ::glGetBooleanv(GL_COLOR_WRITEMASK, colorMask); - ::glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + m_functions->glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor); + m_functions->glClearColor(0, 0, 0, 0); + m_functions->glGetBooleanv(GL_COLOR_WRITEMASK, colorMask); + m_functions->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); if (m_attrs.depth) { - ::glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth); + m_functions->glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth); GraphicsContext3D::clearDepth(1); - ::glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask); - ::glDepthMask(GL_TRUE); + m_functions->glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask); + m_functions->glDepthMask(GL_TRUE); clearMask |= GL_DEPTH_BUFFER_BIT; } if (m_attrs.stencil) { - ::glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil); - ::glClearStencil(0); - ::glGetIntegerv(GL_STENCIL_WRITEMASK, reinterpret_cast<GLint*>(&stencilMask)); - ::glStencilMaskSeparate(GL_FRONT, 0xffffffff); + m_functions->glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil); + m_functions->glClearStencil(0); + m_functions->glGetIntegerv(GL_STENCIL_WRITEMASK, reinterpret_cast<GLint*>(&stencilMask)); + m_functions->glStencilMaskSeparate(GL_FRONT, 0xffffffff); clearMask |= GL_STENCIL_BUFFER_BIT; } - isScissorEnabled = ::glIsEnabled(GL_SCISSOR_TEST); - ::glDisable(GL_SCISSOR_TEST); - isDitherEnabled = ::glIsEnabled(GL_DITHER); - ::glDisable(GL_DITHER); + isScissorEnabled = m_functions->glIsEnabled(GL_SCISSOR_TEST); + m_functions->glDisable(GL_SCISSOR_TEST); + isDitherEnabled = m_functions->glIsEnabled(GL_DITHER); + m_functions->glDisable(GL_DITHER); - ::glClear(clearMask); + m_functions->glClear(clearMask); - ::glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); - ::glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]); + m_functions->glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); + m_functions->glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]); if (m_attrs.depth) { GraphicsContext3D::clearDepth(clearDepth); - ::glDepthMask(depthMask); + m_functions->glDepthMask(depthMask); } if (m_attrs.stencil) { - ::glClearStencil(clearStencil); - ::glStencilMaskSeparate(GL_FRONT, stencilMask); + m_functions->glClearStencil(clearStencil); + m_functions->glStencilMaskSeparate(GL_FRONT, stencilMask); } if (isScissorEnabled) - ::glEnable(GL_SCISSOR_TEST); + m_functions->glEnable(GL_SCISSOR_TEST); else - ::glDisable(GL_SCISSOR_TEST); + m_functions->glDisable(GL_SCISSOR_TEST); if (isDitherEnabled) - ::glEnable(GL_DITHER); + m_functions->glEnable(GL_DITHER); else - ::glDisable(GL_DITHER); + m_functions->glDisable(GL_DITHER); if (mustRestoreFBO) - ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO); + m_functions->glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO); - ::glFlush(); + m_functions->glFlush(); } IntSize GraphicsContext3D::getInternalFramebufferSize() const @@ -299,7 +301,7 @@ void GraphicsContext3D::activeTexture(GC3Denum texture) { makeContextCurrent(); m_state.activeTexture = texture; - ::glActiveTexture(texture); + m_functions->glActiveTexture(texture); } void GraphicsContext3D::attachShader(Platform3DObject program, Platform3DObject shader) @@ -307,20 +309,20 @@ void GraphicsContext3D::attachShader(Platform3DObject program, Platform3DObject ASSERT(program); ASSERT(shader); makeContextCurrent(); - ::glAttachShader(program, shader); + m_functions->glAttachShader(program, shader); } void GraphicsContext3D::bindAttribLocation(Platform3DObject program, GC3Duint index, const String& name) { ASSERT(program); makeContextCurrent(); - ::glBindAttribLocation(program, index, name.utf8().data()); + m_functions->glBindAttribLocation(program, index, name.utf8().data()); } void GraphicsContext3D::bindBuffer(GC3Denum target, Platform3DObject buffer) { makeContextCurrent(); - ::glBindBuffer(target, buffer); + m_functions->glBindBuffer(target, buffer); } void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer) @@ -336,7 +338,7 @@ void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer fbo = (m_attrs.antialias ? m_multisampleFBO : m_fbo); #endif if (fbo != m_state.boundFBO) { - ::glBindFramebufferEXT(target, fbo); + m_functions->glBindFramebuffer(target, fbo); m_state.boundFBO = fbo; } } @@ -344,7 +346,7 @@ void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer void GraphicsContext3D::bindRenderbuffer(GC3Denum target, Platform3DObject renderbuffer) { makeContextCurrent(); - ::glBindRenderbufferEXT(target, renderbuffer); + m_functions->glBindRenderbuffer(target, renderbuffer); } @@ -353,86 +355,86 @@ void GraphicsContext3D::bindTexture(GC3Denum target, Platform3DObject texture) makeContextCurrent(); if (m_state.activeTexture == GL_TEXTURE0 && target == GL_TEXTURE_2D) m_state.boundTexture0 = texture; - ::glBindTexture(target, texture); + m_functions->glBindTexture(target, texture); } void GraphicsContext3D::blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha) { makeContextCurrent(); - ::glBlendColor(red, green, blue, alpha); + m_functions->glBlendColor(red, green, blue, alpha); } void GraphicsContext3D::blendEquation(GC3Denum mode) { makeContextCurrent(); - ::glBlendEquation(mode); + m_functions->glBlendEquation(mode); } void GraphicsContext3D::blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha) { makeContextCurrent(); - ::glBlendEquationSeparate(modeRGB, modeAlpha); + m_functions->glBlendEquationSeparate(modeRGB, modeAlpha); } void GraphicsContext3D::blendFunc(GC3Denum sfactor, GC3Denum dfactor) { makeContextCurrent(); - ::glBlendFunc(sfactor, dfactor); + m_functions->glBlendFunc(sfactor, dfactor); } void GraphicsContext3D::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha) { makeContextCurrent(); - ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); + m_functions->glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); } void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage) { makeContextCurrent(); - ::glBufferData(target, size, 0, usage); + m_functions->glBufferData(target, size, 0, usage); } void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage) { makeContextCurrent(); - ::glBufferData(target, size, data, usage); + m_functions->glBufferData(target, size, data, usage); } void GraphicsContext3D::bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data) { makeContextCurrent(); - ::glBufferSubData(target, offset, size, data); + m_functions->glBufferSubData(target, offset, size, data); } GC3Denum GraphicsContext3D::checkFramebufferStatus(GC3Denum target) { makeContextCurrent(); - return ::glCheckFramebufferStatusEXT(target); + return m_functions->glCheckFramebufferStatus(target); } void GraphicsContext3D::clearColor(GC3Dclampf r, GC3Dclampf g, GC3Dclampf b, GC3Dclampf a) { makeContextCurrent(); - ::glClearColor(r, g, b, a); + m_functions->glClearColor(r, g, b, a); } void GraphicsContext3D::clear(GC3Dbitfield mask) { makeContextCurrent(); - ::glClear(mask); + m_functions->glClear(mask); } void GraphicsContext3D::clearStencil(GC3Dint s) { makeContextCurrent(); - ::glClearStencil(s); + m_functions->glClearStencil(s); } void GraphicsContext3D::colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha) { makeContextCurrent(); - ::glColorMask(red, green, blue, alpha); + m_functions->glColorMask(red, green, blue, alpha); } void GraphicsContext3D::compileShader(Platform3DObject shader) @@ -449,17 +451,17 @@ void GraphicsContext3D::compileShader(Platform3DObject shader) const char* translatedShaderPtr = translatedShaderCString.data(); int translatedShaderLength = translatedShaderCString.length(); - ::glShaderSource(shader, 1, &translatedShaderPtr, &translatedShaderLength); - - ::glCompileShader(shader); + m_functions->glShaderSource(shader, 1, &translatedShaderPtr, &translatedShaderLength); + + m_functions->glCompileShader(shader); int GLCompileSuccess; - ::glGetShaderiv(shader, COMPILE_STATUS, &GLCompileSuccess); + m_functions->glGetShaderiv(shader, COMPILE_STATUS, &GLCompileSuccess); // Populate the shader log GLint length = 0; - ::glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); + m_functions->glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); if (length) { ShaderSourceMap::iterator result = m_shaderSourceMap.find(shader); @@ -467,7 +469,7 @@ void GraphicsContext3D::compileShader(Platform3DObject shader) GLsizei size = 0; OwnArrayPtr<GLchar> info = adoptArrayPtr(new GLchar[length]); - ::glGetShaderInfoLog(shader, length, &size, info.get()); + m_functions->glGetShaderInfoLog(shader, length, &size, info.get()); entry.log = info.get(); } @@ -486,13 +488,13 @@ void GraphicsContext3D::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum #if !PLATFORM(BLACKBERRY) if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) { resolveMultisamplingIfNecessary(IntRect(x, y, width, height)); - ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo); + m_functions->glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); } #endif - ::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); + m_functions->glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); #if !PLATFORM(BLACKBERRY) if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) - ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); + m_functions->glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); #endif } @@ -502,32 +504,32 @@ void GraphicsContext3D::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Din #if !PLATFORM(BLACKBERRY) if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) { resolveMultisamplingIfNecessary(IntRect(x, y, width, height)); - ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo); + m_functions->glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); } #endif - ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); + m_functions->glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); #if !PLATFORM(BLACKBERRY) if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) - ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); + m_functions->glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); #endif } void GraphicsContext3D::cullFace(GC3Denum mode) { makeContextCurrent(); - ::glCullFace(mode); + m_functions->glCullFace(mode); } void GraphicsContext3D::depthFunc(GC3Denum func) { makeContextCurrent(); - ::glDepthFunc(func); + m_functions->glDepthFunc(func); } void GraphicsContext3D::depthMask(GC3Dboolean flag) { makeContextCurrent(); - ::glDepthMask(flag); + m_functions->glDepthMask(flag); } void GraphicsContext3D::detachShader(Platform3DObject program, Platform3DObject shader) @@ -535,79 +537,79 @@ void GraphicsContext3D::detachShader(Platform3DObject program, Platform3DObject ASSERT(program); ASSERT(shader); makeContextCurrent(); - ::glDetachShader(program, shader); + m_functions->glDetachShader(program, shader); } void GraphicsContext3D::disable(GC3Denum cap) { makeContextCurrent(); - ::glDisable(cap); + m_functions->glDisable(cap); } void GraphicsContext3D::disableVertexAttribArray(GC3Duint index) { makeContextCurrent(); - ::glDisableVertexAttribArray(index); + m_functions->glDisableVertexAttribArray(index); } void GraphicsContext3D::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count) { makeContextCurrent(); - ::glDrawArrays(mode, first, count); + m_functions->glDrawArrays(mode, first, count); } void GraphicsContext3D::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset) { makeContextCurrent(); - ::glDrawElements(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset))); + m_functions->glDrawElements(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset))); } void GraphicsContext3D::enable(GC3Denum cap) { makeContextCurrent(); - ::glEnable(cap); + m_functions->glEnable(cap); } void GraphicsContext3D::enableVertexAttribArray(GC3Duint index) { makeContextCurrent(); - ::glEnableVertexAttribArray(index); + m_functions->glEnableVertexAttribArray(index); } void GraphicsContext3D::finish() { makeContextCurrent(); - ::glFinish(); + m_functions->glFinish(); } void GraphicsContext3D::flush() { makeContextCurrent(); - ::glFlush(); + m_functions->glFlush(); } void GraphicsContext3D::framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, Platform3DObject buffer) { makeContextCurrent(); - ::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, buffer); + m_functions->glFramebufferRenderbuffer(target, attachment, renderbuffertarget, buffer); } void GraphicsContext3D::framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, Platform3DObject texture, GC3Dint level) { makeContextCurrent(); - ::glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); + m_functions->glFramebufferTexture2D(target, attachment, textarget, texture, level); } void GraphicsContext3D::frontFace(GC3Denum mode) { makeContextCurrent(); - ::glFrontFace(mode); + m_functions->glFrontFace(mode); } void GraphicsContext3D::generateMipmap(GC3Denum target) { makeContextCurrent(); - ::glGenerateMipmapEXT(target); + m_functions->glGenerateMipmap(target); } bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo& info) @@ -618,12 +620,12 @@ bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index } makeContextCurrent(); GLint maxAttributeSize = 0; - ::glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize); + m_functions->glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize); OwnArrayPtr<GLchar> name = adoptArrayPtr(new GLchar[maxAttributeSize]); // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination. GLsizei nameLength = 0; GLint size = 0; GLenum type = 0; - ::glGetActiveAttrib(program, index, maxAttributeSize, &nameLength, &size, &type, name.get()); + m_functions->glGetActiveAttrib(program, index, maxAttributeSize, &nameLength, &size, &type, name.get()); if (!nameLength) return false; @@ -644,13 +646,13 @@ bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint inde makeContextCurrent(); GLint maxUniformSize = 0; - ::glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize); + m_functions->glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize); OwnArrayPtr<GLchar> name = adoptArrayPtr(new GLchar[maxUniformSize]); // GL_ACTIVE_UNIFORM_MAX_LENGTH includes null termination. GLsizei nameLength = 0; GLint size = 0; GLenum type = 0; - ::glGetActiveUniform(program, index, maxUniformSize, &nameLength, &size, &type, name.get()); + m_functions->glGetActiveUniform(program, index, maxUniformSize, &nameLength, &size, &type, name.get()); if (!nameLength) return false; @@ -669,7 +671,7 @@ void GraphicsContext3D::getAttachedShaders(Platform3DObject program, GC3Dsizei m return; } makeContextCurrent(); - ::glGetAttachedShaders(program, maxCount, count, shaders); + m_functions->glGetAttachedShaders(program, maxCount, count, shaders); } String GraphicsContext3D::mappedSymbolName(Platform3DObject program, ANGLEShaderSymbolType symbolType, const String& name) @@ -724,7 +726,7 @@ int GraphicsContext3D::getAttribLocation(Platform3DObject program, const String& // reference the mapped name rather than the external name. String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, name); - return ::glGetAttribLocation(program, mappedName.utf8().data()); + return m_functions->glGetAttribLocation(program, mappedName.utf8().data()); } GraphicsContext3D::Attributes GraphicsContext3D::getContextAttributes() @@ -742,19 +744,19 @@ GC3Denum GraphicsContext3D::getError() } makeContextCurrent(); - return ::glGetError(); + return m_functions->glGetError(); } String GraphicsContext3D::getString(GC3Denum name) { makeContextCurrent(); - return String(reinterpret_cast<const char*>(::glGetString(name))); + return String(reinterpret_cast<const char*>(m_functions->glGetString(name))); } void GraphicsContext3D::hint(GC3Denum target, GC3Denum mode) { makeContextCurrent(); - ::glHint(target, mode); + m_functions->glHint(target, mode); } GC3Dboolean GraphicsContext3D::isBuffer(Platform3DObject buffer) @@ -763,13 +765,13 @@ GC3Dboolean GraphicsContext3D::isBuffer(Platform3DObject buffer) return GL_FALSE; makeContextCurrent(); - return ::glIsBuffer(buffer); + return m_functions->glIsBuffer(buffer); } GC3Dboolean GraphicsContext3D::isEnabled(GC3Denum cap) { makeContextCurrent(); - return ::glIsEnabled(cap); + return m_functions->glIsEnabled(cap); } GC3Dboolean GraphicsContext3D::isFramebuffer(Platform3DObject framebuffer) @@ -778,7 +780,7 @@ GC3Dboolean GraphicsContext3D::isFramebuffer(Platform3DObject framebuffer) return GL_FALSE; makeContextCurrent(); - return ::glIsFramebufferEXT(framebuffer); + return m_functions->glIsFramebuffer(framebuffer); } GC3Dboolean GraphicsContext3D::isProgram(Platform3DObject program) @@ -787,7 +789,7 @@ GC3Dboolean GraphicsContext3D::isProgram(Platform3DObject program) return GL_FALSE; makeContextCurrent(); - return ::glIsProgram(program); + return m_functions->glIsProgram(program); } GC3Dboolean GraphicsContext3D::isRenderbuffer(Platform3DObject renderbuffer) @@ -796,7 +798,7 @@ GC3Dboolean GraphicsContext3D::isRenderbuffer(Platform3DObject renderbuffer) return GL_FALSE; makeContextCurrent(); - return ::glIsRenderbufferEXT(renderbuffer); + return m_functions->glIsRenderbuffer(renderbuffer); } GC3Dboolean GraphicsContext3D::isShader(Platform3DObject shader) @@ -805,7 +807,7 @@ GC3Dboolean GraphicsContext3D::isShader(Platform3DObject shader) return GL_FALSE; makeContextCurrent(); - return ::glIsShader(shader); + return m_functions->glIsShader(shader); } GC3Dboolean GraphicsContext3D::isTexture(Platform3DObject texture) @@ -814,44 +816,44 @@ GC3Dboolean GraphicsContext3D::isTexture(Platform3DObject texture) return GL_FALSE; makeContextCurrent(); - return ::glIsTexture(texture); + return m_functions->glIsTexture(texture); } void GraphicsContext3D::lineWidth(GC3Dfloat width) { makeContextCurrent(); - ::glLineWidth(width); + m_functions->glLineWidth(width); } void GraphicsContext3D::linkProgram(Platform3DObject program) { ASSERT(program); makeContextCurrent(); - ::glLinkProgram(program); + m_functions->glLinkProgram(program); } void GraphicsContext3D::pixelStorei(GC3Denum pname, GC3Dint param) { makeContextCurrent(); - ::glPixelStorei(pname, param); + m_functions->glPixelStorei(pname, param); } void GraphicsContext3D::polygonOffset(GC3Dfloat factor, GC3Dfloat units) { makeContextCurrent(); - ::glPolygonOffset(factor, units); + m_functions->glPolygonOffset(factor, units); } void GraphicsContext3D::sampleCoverage(GC3Dclampf value, GC3Dboolean invert) { makeContextCurrent(); - ::glSampleCoverage(value, invert); + m_functions->glSampleCoverage(value, invert); } void GraphicsContext3D::scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) { makeContextCurrent(); - ::glScissor(x, y, width, height); + m_functions->glScissor(x, y, width, height); } void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& string) @@ -870,178 +872,178 @@ void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& stri void GraphicsContext3D::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask) { makeContextCurrent(); - ::glStencilFunc(func, ref, mask); + m_functions->glStencilFunc(func, ref, mask); } void GraphicsContext3D::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask) { makeContextCurrent(); - ::glStencilFuncSeparate(face, func, ref, mask); + m_functions->glStencilFuncSeparate(face, func, ref, mask); } void GraphicsContext3D::stencilMask(GC3Duint mask) { makeContextCurrent(); - ::glStencilMask(mask); + m_functions->glStencilMask(mask); } void GraphicsContext3D::stencilMaskSeparate(GC3Denum face, GC3Duint mask) { makeContextCurrent(); - ::glStencilMaskSeparate(face, mask); + m_functions->glStencilMaskSeparate(face, mask); } void GraphicsContext3D::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass) { makeContextCurrent(); - ::glStencilOp(fail, zfail, zpass); + m_functions->glStencilOp(fail, zfail, zpass); } void GraphicsContext3D::stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass) { makeContextCurrent(); - ::glStencilOpSeparate(face, fail, zfail, zpass); + m_functions->glStencilOpSeparate(face, fail, zfail, zpass); } void GraphicsContext3D::texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat value) { makeContextCurrent(); - ::glTexParameterf(target, pname, value); + m_functions->glTexParameterf(target, pname, value); } void GraphicsContext3D::texParameteri(GC3Denum target, GC3Denum pname, GC3Dint value) { makeContextCurrent(); - ::glTexParameteri(target, pname, value); + m_functions->glTexParameteri(target, pname, value); } void GraphicsContext3D::uniform1f(GC3Dint location, GC3Dfloat v0) { makeContextCurrent(); - ::glUniform1f(location, v0); + m_functions->glUniform1f(location, v0); } void GraphicsContext3D::uniform1fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* array) { makeContextCurrent(); - ::glUniform1fv(location, size, array); + m_functions->glUniform1fv(location, size, array); } void GraphicsContext3D::uniform2f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1) { makeContextCurrent(); - ::glUniform2f(location, v0, v1); + m_functions->glUniform2f(location, v0, v1); } void GraphicsContext3D::uniform2fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* array) { // FIXME: length needs to be a multiple of 2. makeContextCurrent(); - ::glUniform2fv(location, size, array); + m_functions->glUniform2fv(location, size, array); } void GraphicsContext3D::uniform3f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2) { makeContextCurrent(); - ::glUniform3f(location, v0, v1, v2); + m_functions->glUniform3f(location, v0, v1, v2); } void GraphicsContext3D::uniform3fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* array) { // FIXME: length needs to be a multiple of 3. makeContextCurrent(); - ::glUniform3fv(location, size, array); + m_functions->glUniform3fv(location, size, array); } void GraphicsContext3D::uniform4f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) { makeContextCurrent(); - ::glUniform4f(location, v0, v1, v2, v3); + m_functions->glUniform4f(location, v0, v1, v2, v3); } void GraphicsContext3D::uniform4fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* array) { // FIXME: length needs to be a multiple of 4. makeContextCurrent(); - ::glUniform4fv(location, size, array); + m_functions->glUniform4fv(location, size, array); } void GraphicsContext3D::uniform1i(GC3Dint location, GC3Dint v0) { makeContextCurrent(); - ::glUniform1i(location, v0); + m_functions->glUniform1i(location, v0); } void GraphicsContext3D::uniform1iv(GC3Dint location, GC3Dsizei size, GC3Dint* array) { makeContextCurrent(); - ::glUniform1iv(location, size, array); + m_functions->glUniform1iv(location, size, array); } void GraphicsContext3D::uniform2i(GC3Dint location, GC3Dint v0, GC3Dint v1) { makeContextCurrent(); - ::glUniform2i(location, v0, v1); + m_functions->glUniform2i(location, v0, v1); } void GraphicsContext3D::uniform2iv(GC3Dint location, GC3Dsizei size, GC3Dint* array) { // FIXME: length needs to be a multiple of 2. makeContextCurrent(); - ::glUniform2iv(location, size, array); + m_functions->glUniform2iv(location, size, array); } void GraphicsContext3D::uniform3i(GC3Dint location, GC3Dint v0, GC3Dint v1, GC3Dint v2) { makeContextCurrent(); - ::glUniform3i(location, v0, v1, v2); + m_functions->glUniform3i(location, v0, v1, v2); } void GraphicsContext3D::uniform3iv(GC3Dint location, GC3Dsizei size, GC3Dint* array) { // FIXME: length needs to be a multiple of 3. makeContextCurrent(); - ::glUniform3iv(location, size, array); + m_functions->glUniform3iv(location, size, array); } void GraphicsContext3D::uniform4i(GC3Dint location, GC3Dint v0, GC3Dint v1, GC3Dint v2, GC3Dint v3) { makeContextCurrent(); - ::glUniform4i(location, v0, v1, v2, v3); + m_functions->glUniform4i(location, v0, v1, v2, v3); } void GraphicsContext3D::uniform4iv(GC3Dint location, GC3Dsizei size, GC3Dint* array) { // FIXME: length needs to be a multiple of 4. makeContextCurrent(); - ::glUniform4iv(location, size, array); + m_functions->glUniform4iv(location, size, array); } void GraphicsContext3D::uniformMatrix2fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* array) { // FIXME: length needs to be a multiple of 4. makeContextCurrent(); - ::glUniformMatrix2fv(location, size, transpose, array); + m_functions->glUniformMatrix2fv(location, size, transpose, array); } void GraphicsContext3D::uniformMatrix3fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* array) { // FIXME: length needs to be a multiple of 9. makeContextCurrent(); - ::glUniformMatrix3fv(location, size, transpose, array); + m_functions->glUniformMatrix3fv(location, size, transpose, array); } void GraphicsContext3D::uniformMatrix4fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* array) { // FIXME: length needs to be a multiple of 16. makeContextCurrent(); - ::glUniformMatrix4fv(location, size, transpose, array); + m_functions->glUniformMatrix4fv(location, size, transpose, array); } void GraphicsContext3D::useProgram(Platform3DObject program) { makeContextCurrent(); - ::glUseProgram(program); + m_functions->glUseProgram(program); } void GraphicsContext3D::validateProgram(Platform3DObject program) @@ -1049,85 +1051,85 @@ void GraphicsContext3D::validateProgram(Platform3DObject program) ASSERT(program); makeContextCurrent(); - ::glValidateProgram(program); + m_functions->glValidateProgram(program); } void GraphicsContext3D::vertexAttrib1f(GC3Duint index, GC3Dfloat v0) { makeContextCurrent(); - ::glVertexAttrib1f(index, v0); + m_functions->glVertexAttrib1f(index, v0); } void GraphicsContext3D::vertexAttrib1fv(GC3Duint index, GC3Dfloat* array) { makeContextCurrent(); - ::glVertexAttrib1fv(index, array); + m_functions->glVertexAttrib1fv(index, array); } void GraphicsContext3D::vertexAttrib2f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1) { makeContextCurrent(); - ::glVertexAttrib2f(index, v0, v1); + m_functions->glVertexAttrib2f(index, v0, v1); } void GraphicsContext3D::vertexAttrib2fv(GC3Duint index, GC3Dfloat* array) { makeContextCurrent(); - ::glVertexAttrib2fv(index, array); + m_functions->glVertexAttrib2fv(index, array); } void GraphicsContext3D::vertexAttrib3f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2) { makeContextCurrent(); - ::glVertexAttrib3f(index, v0, v1, v2); + m_functions->glVertexAttrib3f(index, v0, v1, v2); } void GraphicsContext3D::vertexAttrib3fv(GC3Duint index, GC3Dfloat* array) { makeContextCurrent(); - ::glVertexAttrib3fv(index, array); + m_functions->glVertexAttrib3fv(index, array); } void GraphicsContext3D::vertexAttrib4f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) { makeContextCurrent(); - ::glVertexAttrib4f(index, v0, v1, v2, v3); + m_functions->glVertexAttrib4f(index, v0, v1, v2, v3); } void GraphicsContext3D::vertexAttrib4fv(GC3Duint index, GC3Dfloat* array) { makeContextCurrent(); - ::glVertexAttrib4fv(index, array); + m_functions->glVertexAttrib4fv(index, array); } void GraphicsContext3D::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset) { makeContextCurrent(); - ::glVertexAttribPointer(index, size, type, normalized, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset))); + m_functions->glVertexAttribPointer(index, size, type, normalized, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset))); } void GraphicsContext3D::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) { makeContextCurrent(); - ::glViewport(x, y, width, height); + m_functions->glViewport(x, y, width, height); } void GraphicsContext3D::getBooleanv(GC3Denum pname, GC3Dboolean* value) { makeContextCurrent(); - ::glGetBooleanv(pname, value); + m_functions->glGetBooleanv(pname, value); } void GraphicsContext3D::getBufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) { makeContextCurrent(); - ::glGetBufferParameteriv(target, pname, value); + m_functions->glGetBufferParameteriv(target, pname, value); } void GraphicsContext3D::getFloatv(GC3Denum pname, GC3Dfloat* value) { makeContextCurrent(); - ::glGetFloatv(pname, value); + m_functions->glGetFloatv(pname, value); } void GraphicsContext3D::getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value) @@ -1135,13 +1137,13 @@ void GraphicsContext3D::getFramebufferAttachmentParameteriv(GC3Denum target, GC3 makeContextCurrent(); if (attachment == DEPTH_STENCIL_ATTACHMENT) attachment = DEPTH_ATTACHMENT; // Or STENCIL_ATTACHMENT, either works. - ::glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, value); + m_functions->glGetFramebufferAttachmentParameteriv(target, attachment, pname, value); } void GraphicsContext3D::getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value) { makeContextCurrent(); - ::glGetProgramiv(program, pname, value); + m_functions->glGetProgramiv(program, pname, value); } String GraphicsContext3D::getProgramInfoLog(Platform3DObject program) @@ -1150,13 +1152,13 @@ String GraphicsContext3D::getProgramInfoLog(Platform3DObject program) makeContextCurrent(); GLint length = 0; - ::glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length); + m_functions->glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length); if (!length) return String(); GLsizei size = 0; OwnArrayPtr<GLchar> info = adoptArrayPtr(new GLchar[length]); - ::glGetProgramInfoLog(program, length, &size, info.get()); + m_functions->glGetProgramInfoLog(program, length, &size, info.get()); return String(info.get()); } @@ -1164,7 +1166,7 @@ String GraphicsContext3D::getProgramInfoLog(Platform3DObject program) void GraphicsContext3D::getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) { makeContextCurrent(); - ::glGetRenderbufferParameterivEXT(target, pname, value); + m_functions->glGetRenderbufferParameteriv(target, pname, value); } void GraphicsContext3D::getShaderiv(Platform3DObject shader, GC3Denum pname, GC3Dint* value) @@ -1178,7 +1180,7 @@ void GraphicsContext3D::getShaderiv(Platform3DObject shader, GC3Denum pname, GC3 switch (pname) { case DELETE_STATUS: case SHADER_TYPE: - ::glGetShaderiv(shader, pname, value); + m_functions->glGetShaderiv(shader, pname, value); break; case COMPILE_STATUS: if (result == m_shaderSourceMap.end()) { @@ -1217,13 +1219,13 @@ String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader) return entry.log; GLint length = 0; - ::glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); + m_functions->glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); if (!length) return String(); GLsizei size = 0; OwnArrayPtr<GLchar> info = adoptArrayPtr(new GLchar[length]); - ::glGetShaderInfoLog(shader, length, &size, info.get()); + m_functions->glGetShaderInfoLog(shader, length, &size, info.get()); return String(info.get()); } @@ -1245,25 +1247,25 @@ String GraphicsContext3D::getShaderSource(Platform3DObject shader) void GraphicsContext3D::getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value) { makeContextCurrent(); - ::glGetTexParameterfv(target, pname, value); + m_functions->glGetTexParameterfv(target, pname, value); } void GraphicsContext3D::getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) { makeContextCurrent(); - ::glGetTexParameteriv(target, pname, value); + m_functions->glGetTexParameteriv(target, pname, value); } void GraphicsContext3D::getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value) { makeContextCurrent(); - ::glGetUniformfv(program, location, value); + m_functions->glGetUniformfv(program, location, value); } void GraphicsContext3D::getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value) { makeContextCurrent(); - ::glGetUniformiv(program, location, value); + m_functions->glGetUniformiv(program, location, value); } GC3Dint GraphicsContext3D::getUniformLocation(Platform3DObject program, const String& name) @@ -1277,19 +1279,19 @@ GC3Dint GraphicsContext3D::getUniformLocation(Platform3DObject program, const St // reference the mapped name rather than the external name. String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_UNIFORM, name); - return ::glGetUniformLocation(program, mappedName.utf8().data()); + return m_functions->glGetUniformLocation(program, mappedName.utf8().data()); } void GraphicsContext3D::getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value) { makeContextCurrent(); - ::glGetVertexAttribfv(index, pname, value); + m_functions->glGetVertexAttribfv(index, pname, value); } void GraphicsContext3D::getVertexAttribiv(GC3Duint index, GC3Denum pname, GC3Dint* value) { makeContextCurrent(); - ::glGetVertexAttribiv(index, pname, value); + m_functions->glGetVertexAttribiv(index, pname, value); } GC3Dsizeiptr GraphicsContext3D::getVertexAttribOffset(GC3Duint index, GC3Denum pname) @@ -1297,7 +1299,7 @@ GC3Dsizeiptr GraphicsContext3D::getVertexAttribOffset(GC3Duint index, GC3Denum p makeContextCurrent(); GLvoid* pointer = 0; - ::glGetVertexAttribPointerv(index, pname, &pointer); + m_functions->glGetVertexAttribPointerv(index, pname, &pointer); return static_cast<GC3Dsizeiptr>(reinterpret_cast<intptr_t>(pointer)); } @@ -1306,26 +1308,26 @@ void GraphicsContext3D::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xo makeContextCurrent(); // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size. - ::glTexSubImage2D(target, level, xoff, yoff, width, height, format, type, pixels); + m_functions->glTexSubImage2D(target, level, xoff, yoff, width, height, format, type, pixels); } void GraphicsContext3D::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data) { makeContextCurrent(); - ::glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); + m_functions->glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); } void GraphicsContext3D::compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data) { makeContextCurrent(); - ::glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); + m_functions->glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); } Platform3DObject GraphicsContext3D::createBuffer() { makeContextCurrent(); GLuint o = 0; - glGenBuffers(1, &o); + m_functions->glGenBuffers(1, &o); return o; } @@ -1333,42 +1335,42 @@ Platform3DObject GraphicsContext3D::createFramebuffer() { makeContextCurrent(); GLuint o = 0; - glGenFramebuffersEXT(1, &o); + m_functions->glGenFramebuffers(1, &o); return o; } Platform3DObject GraphicsContext3D::createProgram() { makeContextCurrent(); - return glCreateProgram(); + return m_functions->glCreateProgram(); } Platform3DObject GraphicsContext3D::createRenderbuffer() { makeContextCurrent(); GLuint o = 0; - glGenRenderbuffersEXT(1, &o); + m_functions->glGenRenderbuffers(1, &o); return o; } Platform3DObject GraphicsContext3D::createShader(GC3Denum type) { makeContextCurrent(); - return glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER); + return m_functions->glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER); } Platform3DObject GraphicsContext3D::createTexture() { makeContextCurrent(); GLuint o = 0; - glGenTextures(1, &o); + m_functions->glGenTextures(1, &o); return o; } void GraphicsContext3D::deleteBuffer(Platform3DObject buffer) { makeContextCurrent(); - glDeleteBuffers(1, &buffer); + m_functions->glDeleteBuffers(1, &buffer); } void GraphicsContext3D::deleteFramebuffer(Platform3DObject framebuffer) @@ -1379,25 +1381,25 @@ void GraphicsContext3D::deleteFramebuffer(Platform3DObject framebuffer) // operations after it gets deleted. bindFramebuffer(FRAMEBUFFER, 0); } - glDeleteFramebuffersEXT(1, &framebuffer); + m_functions->glDeleteFramebuffers(1, &framebuffer); } void GraphicsContext3D::deleteProgram(Platform3DObject program) { makeContextCurrent(); - glDeleteProgram(program); + m_functions->glDeleteProgram(program); } void GraphicsContext3D::deleteRenderbuffer(Platform3DObject renderbuffer) { makeContextCurrent(); - glDeleteRenderbuffersEXT(1, &renderbuffer); + m_functions->glDeleteRenderbuffers(1, &renderbuffer); } void GraphicsContext3D::deleteShader(Platform3DObject shader) { makeContextCurrent(); - glDeleteShader(shader); + m_functions->glDeleteShader(shader); } void GraphicsContext3D::deleteTexture(Platform3DObject texture) @@ -1405,7 +1407,7 @@ void GraphicsContext3D::deleteTexture(Platform3DObject texture) makeContextCurrent(); if (m_state.boundTexture0 == texture) m_state.boundTexture0 = 0; - glDeleteTextures(1, &texture); + m_functions->glDeleteTextures(1, &texture); } void GraphicsContext3D::synthesizeGLError(GC3Denum error) @@ -1431,7 +1433,7 @@ bool GraphicsContext3D::layerComposited() const void GraphicsContext3D::texImage2DDirect(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels) { makeContextCurrent(); - ::glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + m_functions->glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); } } diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp index 9e455a82a..edb7636d4 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp @@ -19,11 +19,7 @@ #include "config.h" #include "GraphicsContext3D.h" -#if USE(OPENGL_ES_2) -#include "Extensions3DOpenGLES.h" -#else -#include "Extensions3DOpenGL.h" -#endif +#include "Extensions3DOpenGLCommon.h" #include "GraphicsContext.h" #include "GraphicsSurface.h" #include "HostWindow.h" @@ -31,13 +27,13 @@ #include "ImageData.h" #include "NativeImageQt.h" #include "NotImplemented.h" -#include "OpenGLShims.h" #include "QWebPageClient.h" #include "SharedBuffer.h" #include "TextureMapperPlatformLayer.h" #include <qpa/qplatformpixmap.h> #include <wtf/text/CString.h> +#include <private/qopenglextensions_p.h> #include <QOffscreenSurface> #if USE(TEXTURE_MAPPER_GL) @@ -56,14 +52,31 @@ namespace WebCore { typedef char GLchar; #endif -#if !defined(GL_DEPTH24_STENCIL8) -#define GL_DEPTH24_STENCIL8 0x88F0 +#ifndef GL_VERTEX_PROGRAM_POINT_SIZE +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#endif + +#ifndef GL_POINT_SPRITE +#define GL_POINT_SPRITE 0x8861 +#endif + +#ifndef GL_DEPTH24_STENCIL8 +#define GL_DEPTH24_STENCIL8 0x88F0 +#endif + +#ifndef GL_READ_FRAMEBUFFER +#define GL_READ_FRAMEBUFFER 0x8CA8 +#endif + +#ifndef GL_DRAW_FRAMEBUFFER +#define GL_DRAW_FRAMEBUFFER 0x8CA9 #endif class GraphicsContext3DPrivate #if USE(ACCELERATED_COMPOSITING) : public TextureMapperPlatformLayer #endif + , public QOpenGLExtensions { public: GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*, GraphicsContext3D::RenderStyle); @@ -79,13 +92,15 @@ public: #endif QRectF boundingRect() const; - void blitMultisampleFramebuffer() const; - void blitMultisampleFramebufferAndRestoreContext() const; + void blitMultisampleFramebuffer(); + void blitMultisampleFramebufferAndRestoreContext(); bool makeCurrentIfNeeded() const; void createOffscreenBuffers(); void initializeANGLE(); void createGraphicsSurfaces(const IntSize&); + bool isOpenGLES() const; + GraphicsContext3D* m_context; HostWindow* m_hostWindow; PlatformGraphicsSurface3D m_surface; @@ -97,8 +112,22 @@ public: #endif }; +bool GraphicsContext3DPrivate::isOpenGLES() const +{ + if (m_platformContext) + return m_platformContext->isOpenGLES(); +#if USE(OPENGL_ES_2) + return true; +#else + return false; +#endif +} + bool GraphicsContext3D::isGLES2Compliant() const { + if (m_private) + return m_private->isOpenGLES(); + ASSERT_NOT_REACHED(); #if USE(OPENGL_ES_2) return true; #else @@ -117,6 +146,7 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, H m_platformContext = QOpenGLContext::currentContext(); if (m_platformContext) m_surface = m_platformContext->surface(); + initializeOpenGLFunctions(); return; } @@ -133,11 +163,15 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, H if (shareContext) m_platformContext->setShareContext(shareContext); - if (!m_platformContext->create()) + if (!m_platformContext->create()) { + delete m_platformContext; + m_platformContext = 0; return; + } makeCurrentIfNeeded(); + initializeOpenGLFunctions(); #if USE(GRAPHICS_SURFACE) IntSize surfaceSize(m_context->m_currentWidth, m_context->m_currentHeight); m_surfaceFlags = GraphicsSurface::SupportsTextureTarget @@ -153,31 +187,31 @@ void GraphicsContext3DPrivate::createOffscreenBuffers() glGenFramebuffers(/* count */ 1, &m_context->m_fbo); glGenTextures(1, &m_context->m_texture); - glBindTexture(GraphicsContext3D::TEXTURE_2D, m_context->m_texture); - glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR); - glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); - glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); - glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); - glBindTexture(GraphicsContext3D::TEXTURE_2D, 0); + glBindTexture(GL_TEXTURE_2D, m_context->m_texture); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, 0); // Create a multisample FBO. if (m_context->m_attrs.antialias) { glGenFramebuffers(1, &m_context->m_multisampleFBO); - glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_multisampleFBO); + glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_multisampleFBO); m_context->m_state.boundFBO = m_context->m_multisampleFBO; glGenRenderbuffers(1, &m_context->m_multisampleColorBuffer); if (m_context->m_attrs.stencil || m_context->m_attrs.depth) glGenRenderbuffers(1, &m_context->m_multisampleDepthStencilBuffer); } else { // Bind canvas FBO. - glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_fbo); m_context->m_state.boundFBO = m_context->m_fbo; -#if USE(OPENGL_ES_2) - if (m_context->m_attrs.depth) - glGenRenderbuffers(1, &m_context->m_depthBuffer); - if (m_context->m_attrs.stencil) - glGenRenderbuffers(1, &m_context->m_stencilBuffer); -#endif + if (isOpenGLES()) { + if (m_context->m_attrs.depth) + glGenRenderbuffers(1, &m_context->m_depthBuffer); + if (m_context->m_attrs.stencil) + glGenRenderbuffers(1, &m_context->m_stencilBuffer); + } if (m_context->m_attrs.stencil || m_context->m_attrs.depth) glGenRenderbuffers(1, &m_context->m_depthStencilBuffer); } @@ -246,9 +280,9 @@ void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper painter->beginNativePainting(); makeCurrentIfNeeded(); - glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_fbo); QImage offscreenImage = qt_gl_read_framebuffer(QSize(width, height), true, true); - glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_state.boundFBO); + glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_state.boundFBO); painter->endNativePainting(); @@ -285,19 +319,21 @@ QRectF GraphicsContext3DPrivate::boundingRect() const return QRectF(QPointF(0, 0), QSizeF(m_context->m_currentWidth, m_context->m_currentHeight)); } -void GraphicsContext3DPrivate::blitMultisampleFramebuffer() const +void GraphicsContext3DPrivate::blitMultisampleFramebuffer() { if (!m_context->m_attrs.antialias) return; -#if !USE(OPENGL_ES_2) - glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, m_context->m_multisampleFBO); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, m_context->m_fbo); - glBlitFramebuffer(0, 0, m_context->m_currentWidth, m_context->m_currentHeight, 0, 0, m_context->m_currentWidth, m_context->m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); -#endif - glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_state.boundFBO); + + if (!isOpenGLES()) { + glBindFramebuffer(GL_READ_FRAMEBUFFER, m_context->m_multisampleFBO); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_context->m_fbo); + glBlitFramebuffer(0, 0, m_context->m_currentWidth, m_context->m_currentHeight, 0, 0, m_context->m_currentWidth, m_context->m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); + } + + glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_state.boundFBO); } -void GraphicsContext3DPrivate::blitMultisampleFramebufferAndRestoreContext() const +void GraphicsContext3DPrivate::blitMultisampleFramebufferAndRestoreContext() { const QOpenGLContext* currentContext = QOpenGLContext::currentContext(); QSurface* currentSurface = 0; @@ -347,16 +383,13 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) : m_currentWidth(0) , m_currentHeight(0) - , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT) , m_attrs(attrs) , m_renderStyle(renderStyle) , m_texture(0) , m_compositorTexture(0) , m_fbo(0) -#if USE(OPENGL_ES_2) , m_depthBuffer(0) , m_stencilBuffer(0) -#endif , m_depthStencilBuffer(0) , m_layerComposited(false) , m_internalColorFormat(0) @@ -364,19 +397,20 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi , m_multisampleDepthStencilBuffer(0) , m_multisampleColorBuffer(0) , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow, renderStyle))) + , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT) { - validateAttributes(); - if (!m_private->m_surface || !m_private->m_platformContext) { LOG_ERROR("GraphicsContext3D: GL context creation failed."); m_private = nullptr; return; } + m_functions = m_private.get(); + validateAttributes(); + static bool initialized = false; static bool success = true; if (!initialized) { - success = initializeOpenGLShims(); initialized = true; } if (!success) { @@ -389,13 +423,13 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi m_private->initializeANGLE(); -#if !USE(OPENGL_ES_2) - glEnable(GL_POINT_SPRITE); - glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); -#endif + if (!isGLES2Compliant()) { + m_functions->glEnable(GL_POINT_SPRITE); + m_functions->glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); + } if (renderStyle != RenderToCurrentGLContext) - glClearColor(0.0, 0.0, 0.0, 0.0); + m_functions->glClearColor(0.0, 0.0, 0.0, 0.0); } GraphicsContext3D::~GraphicsContext3D() @@ -405,22 +439,24 @@ GraphicsContext3D::~GraphicsContext3D() return; makeContextCurrent(); - glDeleteTextures(1, &m_texture); - glDeleteFramebuffers(1, &m_fbo); + m_functions->glDeleteTextures(1, &m_texture); + m_functions->glDeleteFramebuffers(1, &m_fbo); if (m_attrs.antialias) { - glDeleteRenderbuffers(1, &m_multisampleColorBuffer); - glDeleteFramebuffers(1, &m_multisampleFBO); + m_functions->glDeleteRenderbuffers(1, &m_multisampleColorBuffer); + m_functions->glDeleteFramebuffers(1, &m_multisampleFBO); if (m_attrs.stencil || m_attrs.depth) - glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer); + m_functions->glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer); } else if (m_attrs.stencil || m_attrs.depth) { -#if USE(OPENGL_ES_2) - if (m_attrs.depth) - glDeleteRenderbuffers(1, &m_depthBuffer); - if (m_attrs.stencil) - glDeleteRenderbuffers(1, &m_stencilBuffer); -#endif - glDeleteRenderbuffers(1, &m_depthStencilBuffer); + if (isGLES2Compliant()) { + if (m_attrs.depth) + m_functions->glDeleteRenderbuffers(1, &m_depthBuffer); + if (m_attrs.stencil) + m_functions->glDeleteRenderbuffers(1, &m_stencilBuffer); + } + m_functions->glDeleteRenderbuffers(1, &m_depthStencilBuffer); } + + m_functions = 0; } PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() @@ -442,7 +478,7 @@ PlatformLayer* GraphicsContext3D::platformLayer() const bool GraphicsContext3D::makeContextCurrent() { - if (!m_private || m_renderStyle == RenderToCurrentGLContext) + if (!m_private) return false; return m_private->makeCurrentIfNeeded(); } diff --git a/Source/WebCore/platform/graphics/qt/QFramebufferPaintDevice.cpp b/Source/WebCore/platform/graphics/qt/QFramebufferPaintDevice.cpp index e5a935fbc..a4c088cbf 100644 --- a/Source/WebCore/platform/graphics/qt/QFramebufferPaintDevice.cpp +++ b/Source/WebCore/platform/graphics/qt/QFramebufferPaintDevice.cpp @@ -19,6 +19,7 @@ #include "config.h" #include "QFramebufferPaintDevice.h" +#include <QOpenGLFunctions> QFramebufferPaintDevice::QFramebufferPaintDevice(const QSize& size) : QOpenGLPaintDevice(size) @@ -27,8 +28,8 @@ QFramebufferPaintDevice::QFramebufferPaintDevice(const QSize& size) m_surface = QOpenGLContext::currentContext()->surface(); setPaintFlipped(true); m_framebufferObject.bind(); - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT); + context()->functions()->glClearColor(0, 0, 0, 0); + context()->functions()->glClear(GL_COLOR_BUFFER_BIT); } void QFramebufferPaintDevice::ensureActiveTarget() diff --git a/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h b/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h index 2fea7b004..7b9f209cc 100644 --- a/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h +++ b/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h @@ -40,7 +40,7 @@ static int clientAttributes[] = { static_cast<int>(GLX_VISUAL_ID), 0, GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT, - GLX_BIND_TO_TEXTURE_RGBA_EXT, TRUE, + GLX_BIND_TO_TEXTURE_RGBA_EXT, GL_TRUE, 0 }; diff --git a/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp b/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp index 23f8afb48..dd27d7755 100644 --- a/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp +++ b/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp @@ -31,6 +31,7 @@ #include <QGuiApplication> #include <QOpenGLContext> #include <qpa/qplatformnativeinterface.h> +#include <GL/gl.h> #include <GL/glext.h> #include <GL/glx.h> #else diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp index 7e70bbb0d..d409d9a65 100644 --- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp +++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp @@ -36,9 +36,7 @@ #include "TextureMapperPlatformLayer.h" #include <wtf/CurrentTime.h> #include <wtf/HashMap.h> -#ifndef NDEBUG #include <wtf/TemporaryChange.h> -#endif #include <wtf/text/CString.h> namespace WebCore { @@ -102,9 +100,7 @@ void CoordinatedGraphicsLayer::didChangeGeometry() CoordinatedGraphicsLayer::CoordinatedGraphicsLayer(GraphicsLayerClient* client) : GraphicsLayer(client) -#ifndef NDEBUG , m_isPurging(false) -#endif , m_shouldUpdateVisibleRect(true) , m_shouldSyncLayerState(true) , m_shouldSyncChildren(true) @@ -996,6 +992,8 @@ void CoordinatedGraphicsLayer::removeTile(uint32_t tileID) { ASSERT(m_coordinator); ASSERT(m_coordinator->isFlushingLayerChanges() || m_isPurging); + if (m_isPurging) + return; m_layerState.tilesToRemove.append(tileID); } @@ -1047,9 +1045,7 @@ void CoordinatedGraphicsLayer::updateContentBuffers() void CoordinatedGraphicsLayer::purgeBackingStores() { -#ifndef NDEBUG TemporaryChange<bool> updateModeProtector(m_isPurging, true); -#endif m_mainBackingStore.clear(); m_previousBackingStore.clear(); diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h index cfbc2135d..0c7ef5daf 100644 --- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h +++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h @@ -218,9 +218,7 @@ private: FloatPoint m_adjustedPosition; FloatPoint3D m_adjustedAnchorPoint; -#ifndef NDEBUG bool m_isPurging; -#endif bool m_shouldUpdateVisibleRect: 1; bool m_shouldSyncLayerState: 1; bool m_shouldSyncChildren: 1; diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp index 32c7dace4..acd382cdb 100644 --- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp +++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp @@ -690,8 +690,6 @@ void CoordinatedGraphicsScene::purgeGLResources() m_rootLayer.clear(); m_rootLayerID = InvalidCoordinatedLayerID; - m_layers.clear(); - m_fixedLayers.clear(); m_textureMapper.clear(); m_backingStores.clear(); m_backingStoresWithPendingBuffers.clear(); diff --git a/Source/WebCore/platform/qt/QWebPageClient.h b/Source/WebCore/platform/qt/QWebPageClient.h index 791cee91c..d07907287 100644 --- a/Source/WebCore/platform/qt/QWebPageClient.h +++ b/Source/WebCore/platform/qt/QWebPageClient.h @@ -34,15 +34,11 @@ #include <GraphicsLayer.h> #endif -#if USE(3D_GRAPHICS) -#include <GraphicsContext3D.h> -#endif - #include <QPalette> #include <QRect> -#include <QOpenGLContext> QT_BEGIN_NAMESPACE +class QOpenGLContext; class QStyle; class QWindow; QT_END_NAMESPACE diff --git a/Source/WebCore/platform/qt/RenderThemeQt.cpp b/Source/WebCore/platform/qt/RenderThemeQt.cpp index 321fd1108..8a6232ea9 100644 --- a/Source/WebCore/platform/qt/RenderThemeQt.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQt.cpp @@ -813,17 +813,19 @@ bool RenderThemeQt::paintMediaSliderTrack(RenderObject* o, const PaintInfo& pain paintMediaBackground(p->painter, r); if (MediaPlayer* player = mediaElement->player()) { + float duration = player->duration(); + // Get the buffered parts of the media RefPtr<TimeRanges> buffered = player->buffered(); - if (buffered->length() > 0 && player->duration() < std::numeric_limits<float>::infinity()) { + if (buffered->length() > 0 && duration > 0.0f && duration < std::numeric_limits<float>::infinity()) { // Set the transform and brush WorldMatrixTransformer transformer(p->painter, o, r); p->painter->setBrush(getMediaControlForegroundColor()); // Paint each buffered section for (int i = 0; i < buffered->length(); i++) { - float startX = (buffered->start(i, IGNORE_EXCEPTION) / player->duration()) * 100; - float width = ((buffered->end(i, IGNORE_EXCEPTION) / player->duration()) * 100) - startX; + float startX = (buffered->start(i, IGNORE_EXCEPTION) / duration) * 100; + float width = ((buffered->end(i, IGNORE_EXCEPTION) / duration) * 100) - startX; p->painter->drawRect(startX, 37, width, 26); } } diff --git a/Source/WebKit2/WebKit2.pro b/Source/WebKit2/WebKit2.pro index 7013d3038..66129d359 100644 --- a/Source/WebKit2/WebKit2.pro +++ b/Source/WebKit2/WebKit2.pro @@ -10,3 +10,5 @@ derived_sources.file = DerivedSources.pri target.file = Target.pri SUBDIRS += derived_sources target + +addStrictSubdirOrderBetween(derived_sources, target) diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp index 4d8210329..fa6f276b7 100644 --- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp +++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp @@ -212,6 +212,8 @@ void CoordinatedLayerTreeHost::renderNextFrame() void CoordinatedLayerTreeHost::purgeBackingStores() { + // Wait for CoordinatedGraphicsScene::setActive(true) to be called. + m_isWaitingForRenderer = true; m_coordinator->purgeBackingStores(); } |
