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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
index 548a2cd688c83a854dd177561d064c9f92e623a7..8bff5927ab95daf4dbec4473b96429ba9ac58d13 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
@@ -93,10 +93,11 @@
#include "public/platform/Platform.h"
#include "public/platform/functional/WebFunction.h"
#include "wtf/Functional.h"
-#include "wtf/PtrUtil.h"
+#include "wtf/PassOwnPtr.h"
#include "wtf/text/StringBuilder.h"
#include "wtf/text/StringUTF8Adaptor.h"
#include "wtf/typed_arrays/ArrayBufferContents.h"
+
#include <memory>
namespace blink {
@@ -536,18 +537,18 @@ struct ContextProviderCreationInfo {
Platform::GraphicsInfo* glInfo;
ScriptState* scriptState;
// Outputs.
- std::unique_ptr<WebGraphicsContext3DProvider> createdContextProvider;
+ OwnPtr<WebGraphicsContext3DProvider> createdContextProvider;
};
static void createContextProviderOnMainThread(ContextProviderCreationInfo* creationInfo, WaitableEvent* waitableEvent)
{
ASSERT(isMainThread());
- creationInfo->createdContextProvider = wrapUnique(Platform::current()->createOffscreenGraphicsContext3DProvider(
+ creationInfo->createdContextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsContext3DProvider(
creationInfo->contextAttributes, creationInfo->scriptState->getExecutionContext()->url(), 0, creationInfo->glInfo));
waitableEvent->signal();
}
-static std::unique_ptr<WebGraphicsContext3DProvider> createContextProviderOnWorkerThread(Platform::ContextAttributes contextAttributes, Platform::GraphicsInfo* glInfo, ScriptState* scriptState)
+static PassOwnPtr<WebGraphicsContext3DProvider> createContextProviderOnWorkerThread(Platform::ContextAttributes contextAttributes, Platform::GraphicsInfo* glInfo, ScriptState* scriptState)
{
WaitableEvent waitableEvent;
ContextProviderCreationInfo creationInfo;
@@ -560,7 +561,7 @@ static std::unique_ptr<WebGraphicsContext3DProvider> createContextProviderOnWork
return std::move(creationInfo.createdContextProvider);
}
-std::unique_ptr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createContextProviderInternal(HTMLCanvasElement* canvas, ScriptState* scriptState, WebGLContextAttributes attributes, unsigned webGLVersion)
+PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createContextProviderInternal(HTMLCanvasElement* canvas, ScriptState* scriptState, WebGLContextAttributes attributes, unsigned webGLVersion)
{
// Exactly one of these must be provided.
DCHECK_EQ(!canvas, !!scriptState);
@@ -569,10 +570,10 @@ std::unique_ptr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createC
Platform::ContextAttributes contextAttributes = toPlatformContextAttributes(attributes, webGLVersion);
Platform::GraphicsInfo glInfo;
- std::unique_ptr<WebGraphicsContext3DProvider> contextProvider;
+ OwnPtr<WebGraphicsContext3DProvider> contextProvider;
if (isMainThread()) {
const auto& url = canvas ? canvas->document().topDocument().url() : scriptState->getExecutionContext()->url();
- contextProvider = wrapUnique(Platform::current()->createOffscreenGraphicsContext3DProvider(
+ contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsContext3DProvider(
contextAttributes, url, 0, &glInfo));
} else {
contextProvider = createContextProviderOnWorkerThread(contextAttributes, &glInfo, scriptState);
@@ -598,7 +599,7 @@ std::unique_ptr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createC
return contextProvider;
}
-std::unique_ptr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGraphicsContext3DProvider(HTMLCanvasElement* canvas, WebGLContextAttributes attributes, unsigned webGLVersion)
+PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGraphicsContext3DProvider(HTMLCanvasElement* canvas, WebGLContextAttributes attributes, unsigned webGLVersion)
{
Document& document = canvas->document();
LocalFrame* frame = document.frame();
@@ -618,7 +619,7 @@ std::unique_ptr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createW
return createContextProviderInternal(canvas, nullptr, attributes, webGLVersion);
}
-std::unique_ptr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGraphicsContext3DProvider(ScriptState* scriptState, WebGLContextAttributes attributes, unsigned webGLVersion)
+PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGraphicsContext3DProvider(ScriptState* scriptState, WebGLContextAttributes attributes, unsigned webGLVersion)
{
return createContextProviderInternal(nullptr, scriptState, attributes, webGLVersion);
}
@@ -877,15 +878,15 @@ bool isSRGBFormat(GLenum internalformat)
} // namespace
-WebGLRenderingContextBase::WebGLRenderingContextBase(OffscreenCanvas* passedOffscreenCanvas, std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttributes& requestedAttributes)
+WebGLRenderingContextBase::WebGLRenderingContextBase(OffscreenCanvas* passedOffscreenCanvas, PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttributes& requestedAttributes)
: WebGLRenderingContextBase(nullptr, passedOffscreenCanvas, std::move(contextProvider), requestedAttributes)
{ }
-WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCanvas, std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttributes& requestedAttributes)
+WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttributes& requestedAttributes)
: WebGLRenderingContextBase(passedCanvas, nullptr, std::move(contextProvider), requestedAttributes)
{ }
-WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCanvas, OffscreenCanvas* passedOffscreenCanvas, std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttributes& requestedAttributes)
+WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCanvas, OffscreenCanvas* passedOffscreenCanvas, PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttributes& requestedAttributes)
: CanvasRenderingContext(passedCanvas, passedOffscreenCanvas)
, m_isHidden(false)
, m_contextLostMode(NotLostContext)
@@ -936,7 +937,7 @@ WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa
ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES2);
}
-PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(std::unique_ptr<WebGraphicsContext3DProvider> contextProvider)
+PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwnPtr<WebGraphicsContext3DProvider> contextProvider)
{
bool premultipliedAlpha = m_requestedAttributes.premultipliedAlpha();
bool wantAlphaChannel = m_requestedAttributes.alpha();
@@ -4433,9 +4434,9 @@ void WebGLRenderingContextBase::texImageHelperHTMLVideoElement(TexImageFunctionI
}
// Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU.
- std::unique_ptr<ImageBufferSurface> surface = wrapUnique(new AcceleratedImageBufferSurface(IntSize(video->videoWidth(), video->videoHeight())));
+ OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBufferSurface(IntSize(video->videoWidth(), video->videoHeight())));
if (surface->isValid()) {
- std::unique_ptr<ImageBuffer> imageBuffer(ImageBuffer::create(std::move(surface)));
+ OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(std::move(surface)));
if (imageBuffer) {
// The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface,
// we enable the WebMediaPlayer implementation to do any necessary color space conversion on the GPU (though it
@@ -4485,7 +4486,7 @@ void WebGLRenderingContextBase::texImageHelperImageBitmap(TexImageFunctionID fun
ASSERT(bitmap->bitmapImage());
RefPtr<SkImage> skImage = bitmap->bitmapImage()->imageForCurrentFrame();
SkPixmap pixmap;
- std::unique_ptr<uint8_t[]> pixelData;
+ OwnPtr<uint8_t[]> pixelData;
uint8_t* pixelDataPtr = nullptr;
// TODO(crbug.com/613411): peekPixels fails if the SkImage is texture-backed
// Use texture mailbox in that case.
@@ -6090,7 +6091,7 @@ void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB
Platform::ContextAttributes attributes = toPlatformContextAttributes(m_requestedAttributes, version());
Platform::GraphicsInfo glInfo;
- std::unique_ptr<WebGraphicsContext3DProvider> contextProvider = wrapUnique(Platform::current()->createOffscreenGraphicsContext3DProvider(
+ OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsContext3DProvider(
attributes, canvas()->document().topDocument().url(), 0, &glInfo));
RefPtr<DrawingBuffer> buffer;
if (contextProvider->bindToCurrentThread()) {
@@ -6132,7 +6133,7 @@ String WebGLRenderingContextBase::ensureNotNull(const String& text) const
}
WebGLRenderingContextBase::LRUImageBufferCache::LRUImageBufferCache(int capacity)
- : m_buffers(wrapArrayUnique(new std::unique_ptr<ImageBuffer>[capacity]))
+ : m_buffers(adoptArrayPtr(new OwnPtr<ImageBuffer>[capacity]))
, m_capacity(capacity)
{
}
@@ -6150,7 +6151,7 @@ ImageBuffer* WebGLRenderingContextBase::LRUImageBufferCache::imageBuffer(const I
return buf;
}
- std::unique_ptr<ImageBuffer> temp(ImageBuffer::create(size));
+ OwnPtr<ImageBuffer> temp(ImageBuffer::create(size));
if (!temp)
return nullptr;
i = std::min(m_capacity - 1, i);

Powered by Google App Engine
This is Rietveld 408576698