| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 texture = 0; | 1538 texture = 0; |
| 1539 if (texture && texture->getTarget() && texture->getTarget() != target) { | 1539 if (texture && texture->getTarget() && texture->getTarget() != target) { |
| 1540 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", "textures can not
be used with multiple targets"); | 1540 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", "textures can not
be used with multiple targets"); |
| 1541 return; | 1541 return; |
| 1542 } | 1542 } |
| 1543 | 1543 |
| 1544 // ScriptState may be null if this method is called internally | 1544 // ScriptState may be null if this method is called internally |
| 1545 // during restoration of texture unit bindings. Skip the | 1545 // during restoration of texture unit bindings. Skip the |
| 1546 // preserveObjectWrapper work in this case. | 1546 // preserveObjectWrapper work in this case. |
| 1547 v8::Local<v8::String> hiddenValueName; | 1547 v8::Local<v8::String> hiddenValueName; |
| 1548 V8CopyablePersistent<v8::Array>* persistentCache = nullptr; | 1548 ScopedPersistent<v8::Array>* persistentCache = nullptr; |
| 1549 if (target == GL_TEXTURE_2D) { | 1549 if (target == GL_TEXTURE_2D) { |
| 1550 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; | 1550 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; |
| 1551 | 1551 |
| 1552 if (!m_activeTextureUnit) | 1552 if (!m_activeTextureUnit) |
| 1553 drawingBuffer()->setTexture2DBinding(objectOrZero(texture)); | 1553 drawingBuffer()->setTexture2DBinding(objectOrZero(texture)); |
| 1554 if (scriptState) { | 1554 if (scriptState) { |
| 1555 hiddenValueName = V8HiddenValue::webgl2DTextures(scriptState->isolat
e()); | 1555 hiddenValueName = V8HiddenValue::webgl2DTextures(scriptState->isolat
e()); |
| 1556 persistentCache = &m_2DTextureWrappers; | 1556 persistentCache = &m_2DTextureWrappers; |
| 1557 } | 1557 } |
| 1558 } else if (target == GL_TEXTURE_CUBE_MAP) { | 1558 } else if (target == GL_TEXTURE_CUBE_MAP) { |
| (...skipping 4718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6277 for (int i = startIndex; i >= 0; --i) { | 6277 for (int i = startIndex; i >= 0; --i) { |
| 6278 if (m_textureUnits[i].m_texture2DBinding | 6278 if (m_textureUnits[i].m_texture2DBinding |
| 6279 || m_textureUnits[i].m_textureCubeMapBinding) { | 6279 || m_textureUnits[i].m_textureCubeMapBinding) { |
| 6280 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 6280 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
| 6281 return; | 6281 return; |
| 6282 } | 6282 } |
| 6283 } | 6283 } |
| 6284 m_onePlusMaxNonDefaultTextureUnit = 0; | 6284 m_onePlusMaxNonDefaultTextureUnit = 0; |
| 6285 } | 6285 } |
| 6286 | 6286 |
| 6287 void WebGLRenderingContextBase::preserveObjectWrapper(ScriptState* scriptState,
ScriptWrappable* sourceObject, v8::Local<v8::String> hiddenValueName, V8Copyable
Persistent<v8::Array>* persistentCache, uint32_t index, ScriptWrappable* targetO
bject) | 6287 void WebGLRenderingContextBase::preserveObjectWrapper(ScriptState* scriptState,
ScriptWrappable* sourceObject, v8::Local<v8::String> hiddenValueName, ScopedPers
istent<v8::Array>* persistentCache, uint32_t index, ScriptWrappable* targetObjec
t) |
| 6288 { | 6288 { |
| 6289 v8::Isolate* isolate = scriptState->isolate(); | 6289 v8::Isolate* isolate = scriptState->isolate(); |
| 6290 if (persistentCache->IsEmpty()) { | 6290 if (persistentCache->isEmpty()) { |
| 6291 // TODO(kbr): eliminate the persistent caches and just use | 6291 // TODO(kbr): eliminate the persistent caches and just use |
| 6292 // V8HiddenValue::getHiddenValue. Unfortunately, it's | 6292 // V8HiddenValue::getHiddenValue. Unfortunately, it's |
| 6293 // currently too slow to use. crbug.com/611864 | 6293 // currently too slow to use. crbug.com/611864 |
| 6294 persistentCache->Reset(isolate, v8::Array::New(isolate)); | 6294 persistentCache->set(isolate, v8::Array::New(isolate)); |
| 6295 V8HiddenValue::setHiddenValue( | 6295 V8HiddenValue::setHiddenValue( |
| 6296 scriptState, | 6296 scriptState, |
| 6297 sourceObject->newLocalWrapper(isolate), | 6297 sourceObject->newLocalWrapper(isolate), |
| 6298 hiddenValueName, | 6298 hiddenValueName, |
| 6299 persistentCache->Get(isolate)); | 6299 persistentCache->newLocal(isolate)); |
| 6300 // It is important to mark the persistent cache as weak | 6300 // It is important to mark the persistent cache as weak |
| 6301 // (phantom, actually). Otherwise there will be a reference | 6301 // (phantom, actually). Otherwise there will be a reference |
| 6302 // cycle between it and its JavaScript wrapper, and currently | 6302 // cycle between it and its JavaScript wrapper, and currently |
| 6303 // there are problems collecting such cycles. | 6303 // there are problems collecting such cycles. |
| 6304 persistentCache->SetWeak(); | 6304 persistentCache->setPhantom(); |
| 6305 } | 6305 } |
| 6306 | 6306 |
| 6307 v8::Local<v8::Array> localCache = persistentCache->Get(isolate); | 6307 v8::Local<v8::Array> localCache = persistentCache->newLocal(isolate); |
| 6308 if (targetObject) { | 6308 if (targetObject) { |
| 6309 v8CallOrCrash(localCache->Set(scriptState->context(), index, targetObjec
t->newLocalWrapper(isolate))); | 6309 v8CallOrCrash(localCache->Set(scriptState->context(), index, targetObjec
t->newLocalWrapper(isolate))); |
| 6310 } else { | 6310 } else { |
| 6311 v8CallOrCrash(localCache->Set(scriptState->context(), index, v8::Null(is
olate))); | 6311 v8CallOrCrash(localCache->Set(scriptState->context(), index, v8::Null(is
olate))); |
| 6312 } | 6312 } |
| 6313 } | 6313 } |
| 6314 | 6314 |
| 6315 void WebGLRenderingContextBase::maybePreserveDefaultVAOObjectWrapper(ScriptState
* scriptState) | 6315 void WebGLRenderingContextBase::maybePreserveDefaultVAOObjectWrapper(ScriptState
* scriptState) |
| 6316 { | 6316 { |
| 6317 ASSERT(scriptState); | 6317 ASSERT(scriptState); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6384 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6384 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 6385 } | 6385 } |
| 6386 | 6386 |
| 6387 void WebGLRenderingContextBase::restoreUnpackParameters() | 6387 void WebGLRenderingContextBase::restoreUnpackParameters() |
| 6388 { | 6388 { |
| 6389 if (m_unpackAlignment != 1) | 6389 if (m_unpackAlignment != 1) |
| 6390 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6390 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 6391 } | 6391 } |
| 6392 | 6392 |
| 6393 } // namespace blink | 6393 } // namespace blink |
| OLD | NEW |