Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 1979953002: Remove OwnPtr::release() calls in modules/ (part 3). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 ContextProviderCreationInfo(Platform::ContextAttributes contextAttributes, P latform::GraphicsInfo glInfo, ScriptState* scriptState) 536 ContextProviderCreationInfo(Platform::ContextAttributes contextAttributes, P latform::GraphicsInfo glInfo, ScriptState* scriptState)
537 { 537 {
538 m_contextAttributes = contextAttributes; 538 m_contextAttributes = contextAttributes;
539 m_glInfo = glInfo; 539 m_glInfo = glInfo;
540 m_scriptState = scriptState; 540 m_scriptState = scriptState;
541 } 541 }
542 Platform::ContextAttributes contextAttributes() { return m_contextAttributes ; } 542 Platform::ContextAttributes contextAttributes() { return m_contextAttributes ; }
543 Platform::GraphicsInfo glInfo() { return m_glInfo; } 543 Platform::GraphicsInfo glInfo() { return m_glInfo; }
544 ScriptState* scriptState() { return m_scriptState; } 544 ScriptState* scriptState() { return m_scriptState; }
545 void setContextProvider(PassOwnPtr<WebGraphicsContext3DProvider> provider) { m_provider = std::move(provider); } 545 void setContextProvider(PassOwnPtr<WebGraphicsContext3DProvider> provider) { m_provider = std::move(provider); }
546 PassOwnPtr<WebGraphicsContext3DProvider> releaseContextProvider() { return m _provider.release(); } 546 PassOwnPtr<WebGraphicsContext3DProvider> releaseContextProvider() { return s td::move(m_provider); }
547 private: 547 private:
548 Platform::ContextAttributes m_contextAttributes; 548 Platform::ContextAttributes m_contextAttributes;
549 Platform::GraphicsInfo m_glInfo; 549 Platform::GraphicsInfo m_glInfo;
550 ScriptState* m_scriptState; 550 ScriptState* m_scriptState;
551 OwnPtr<WebGraphicsContext3DProvider> m_provider; 551 OwnPtr<WebGraphicsContext3DProvider> m_provider;
552 }; 552 };
553 553
554 void WebGLRenderingContextBase::createContextProviderOnMainThread(ContextProvide rCreationInfo* creationInfo, WaitableEvent* waitableEvent) 554 void WebGLRenderingContextBase::createContextProviderOnMainThread(ContextProvide rCreationInfo* creationInfo, WaitableEvent* waitableEvent)
555 { 555 {
556 ASSERT(isMainThread()); 556 ASSERT(isMainThread());
557 Platform::GraphicsInfo glInfo = creationInfo->glInfo(); 557 Platform::GraphicsInfo glInfo = creationInfo->glInfo();
558 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current() ->createOffscreenGraphicsContext3DProvider( 558 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current() ->createOffscreenGraphicsContext3DProvider(
559 creationInfo->contextAttributes(), creationInfo->scriptState()->getExecu tionContext()->url(), 0, &glInfo, Platform::DoNotBindToCurrentThread)); 559 creationInfo->contextAttributes(), creationInfo->scriptState()->getExecu tionContext()->url(), 0, &glInfo, Platform::DoNotBindToCurrentThread));
560 creationInfo->setContextProvider(provider.release()); 560 creationInfo->setContextProvider(std::move(provider));
561 waitableEvent->signal(); 561 waitableEvent->signal();
562 } 562 }
563 563
564 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createContex tProviderOnWorkerThread(Platform::ContextAttributes contextAttributes, Platform: :GraphicsInfo glInfo, ScriptState* scriptState) 564 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createContex tProviderOnWorkerThread(Platform::ContextAttributes contextAttributes, Platform: :GraphicsInfo glInfo, ScriptState* scriptState)
565 { 565 {
566 WaitableEvent waitableEvent; 566 WaitableEvent waitableEvent;
567 OwnPtr<ContextProviderCreationInfo> creationInfo = adoptPtr(new ContextProvi derCreationInfo(contextAttributes, glInfo, scriptState)); 567 OwnPtr<ContextProviderCreationInfo> creationInfo = adoptPtr(new ContextProvi derCreationInfo(contextAttributes, glInfo, scriptState));
568 WebTaskRunner* taskRunner = Platform::current()->mainThread()->getWebTaskRun ner(); 568 WebTaskRunner* taskRunner = Platform::current()->mainThread()->getWebTaskRun ner();
569 taskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&createContextProviderO nMainThread, AllowCrossThreadAccess(creationInfo.get()), AllowCrossThreadAccess( &waitableEvent))); 569 taskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&createContextProviderO nMainThread, AllowCrossThreadAccess(creationInfo.get()), AllowCrossThreadAccess( &waitableEvent)));
570 waitableEvent.wait(); 570 waitableEvent.wait();
(...skipping 23 matching lines...) Expand all
594 if (canvas) 594 if (canvas)
595 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webg lcontextcreationerror, false, true, extractWebGLContextCreationError(glInfo))); 595 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webg lcontextcreationerror, false, true, extractWebGLContextCreationError(glInfo)));
596 return nullptr; 596 return nullptr;
597 } 597 }
598 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); 598 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL();
599 if (!String(gl->GetString(GL_EXTENSIONS)).contains("GL_OES_packed_depth_sten cil")) { 599 if (!String(gl->GetString(GL_EXTENSIONS)).contains("GL_OES_packed_depth_sten cil")) {
600 if (canvas) 600 if (canvas)
601 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webg lcontextcreationerror, false, true, "OES_packed_depth_stencil support is require d.")); 601 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webg lcontextcreationerror, false, true, "OES_packed_depth_stencil support is require d."));
602 return nullptr; 602 return nullptr;
603 } 603 }
604 return contextProvider.release(); 604 return contextProvider;
605 } 605 }
606 606
607 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProvider(HTMLCanvasElement* canvas, WebGLContextAttributes attribu tes, unsigned webGLVersion) 607 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProvider(HTMLCanvasElement* canvas, WebGLContextAttributes attribu tes, unsigned webGLVersion)
608 { 608 {
609 Document& document = canvas->document(); 609 Document& document = canvas->document();
610 LocalFrame* frame = document.frame(); 610 LocalFrame* frame = document.frame();
611 if (!frame) { 611 if (!frame) {
612 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext.")); 612 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext."));
613 return nullptr; 613 return nullptr;
614 } 614 }
(...skipping 3643 matching lines...) Expand 10 before | Expand all | Expand 10 after
4258 // Otherwise, it will fall back to the normal SW path. 4258 // Otherwise, it will fall back to the normal SW path.
4259 if (GL_TEXTURE_2D == target) { 4259 if (GL_TEXTURE_2D == target) {
4260 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, type, level) 4260 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, type, level)
4261 && video->copyVideoTextureToPlatformTexture(contextGL(), texture->ob ject(), internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 4261 && video->copyVideoTextureToPlatformTexture(contextGL(), texture->ob ject(), internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
4262 return; 4262 return;
4263 } 4263 }
4264 4264
4265 // Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU. 4265 // Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU.
4266 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer Surface(IntSize(video->videoWidth(), video->videoHeight()))); 4266 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer Surface(IntSize(video->videoWidth(), video->videoHeight())));
4267 if (surface->isValid()) { 4267 if (surface->isValid()) {
4268 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release( ))); 4268 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(std::move(surfac e)));
4269 if (imageBuffer) { 4269 if (imageBuffer) {
4270 // The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface, 4270 // The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface,
4271 // we enable the WebMediaPlayer implementation to do any necessa ry color space conversion on the GPU (though it 4271 // we enable the WebMediaPlayer implementation to do any necessa ry color space conversion on the GPU (though it
4272 // may still do a CPU conversion and upload the results). 4272 // may still do a CPU conversion and upload the results).
4273 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi deo->videoWidth(), video->videoHeight()), nullptr); 4273 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi deo->videoWidth(), video->videoHeight()), nullptr);
4274 4274
4275 // This is a straight GPU-GPU copy, any necessary color space co nversion was handled in the paintCurrentFrameInContext() call. 4275 // This is a straight GPU-GPU copy, any necessary color space co nversion was handled in the paintCurrentFrameInContext() call.
4276 if (imageBuffer->copyToPlatformTexture(contextGL(), texture->obj ect(), internalformat, type, 4276 if (imageBuffer->copyToPlatformTexture(contextGL(), texture->obj ect(), internalformat, type,
4277 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 4277 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
4278 return; 4278 return;
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after
6048 m_drawingBuffer.clear(); 6048 m_drawingBuffer.clear();
6049 } 6049 }
6050 6050
6051 Platform::ContextAttributes attributes = toPlatformContextAttributes(m_reque stedAttributes, version()); 6051 Platform::ContextAttributes attributes = toPlatformContextAttributes(m_reque stedAttributes, version());
6052 Platform::GraphicsInfo glInfo; 6052 Platform::GraphicsInfo glInfo;
6053 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu rrent()->createOffscreenGraphicsContext3DProvider( 6053 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu rrent()->createOffscreenGraphicsContext3DProvider(
6054 attributes, canvas()->document().topDocument().url(), 0, &glInfo, Platfo rm::BindToCurrentThread)); 6054 attributes, canvas()->document().topDocument().url(), 0, &glInfo, Platfo rm::BindToCurrentThread));
6055 RefPtr<DrawingBuffer> buffer; 6055 RefPtr<DrawingBuffer> buffer;
6056 if (contextProvider) { 6056 if (contextProvider) {
6057 // Construct a new drawing buffer with the new GL context. 6057 // Construct a new drawing buffer with the new GL context.
6058 buffer = createDrawingBuffer(contextProvider.release()); 6058 buffer = createDrawingBuffer(std::move(contextProvider));
6059 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i s set to null. 6059 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i s set to null.
6060 } 6060 }
6061 if (!buffer) { 6061 if (!buffer) {
6062 if (m_contextLostMode == RealLostContext) { 6062 if (m_contextLostMode == RealLostContext) {
6063 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO M_HERE); 6063 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO M_HERE);
6064 } else { 6064 } else {
6065 // This likely shouldn't happen but is the best way to report it to the WebGL app. 6065 // This likely shouldn't happen but is the best way to report it to the WebGL app.
6066 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context "); 6066 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context ");
6067 } 6067 }
6068 return; 6068 return;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6107 if (buf->size() != size) 6107 if (buf->size() != size)
6108 continue; 6108 continue;
6109 bubbleToFront(i); 6109 bubbleToFront(i);
6110 return buf; 6110 return buf;
6111 } 6111 }
6112 6112
6113 OwnPtr<ImageBuffer> temp(ImageBuffer::create(size)); 6113 OwnPtr<ImageBuffer> temp(ImageBuffer::create(size));
6114 if (!temp) 6114 if (!temp)
6115 return nullptr; 6115 return nullptr;
6116 i = std::min(m_capacity - 1, i); 6116 i = std::min(m_capacity - 1, i);
6117 m_buffers[i] = temp.release(); 6117 m_buffers[i] = std::move(temp);
6118 6118
6119 ImageBuffer* buf = m_buffers[i].get(); 6119 ImageBuffer* buf = m_buffers[i].get();
6120 bubbleToFront(i); 6120 bubbleToFront(i);
6121 return buf; 6121 return buf;
6122 } 6122 }
6123 6123
6124 void WebGLRenderingContextBase::LRUImageBufferCache::bubbleToFront(int idx) 6124 void WebGLRenderingContextBase::LRUImageBufferCache::bubbleToFront(int idx)
6125 { 6125 {
6126 for (int i = idx; i > 0; --i) 6126 for (int i = idx; i > 0; --i)
6127 m_buffers[i].swap(m_buffers[i-1]); 6127 m_buffers[i].swap(m_buffers[i-1]);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698