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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from Kent; merge. 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved.
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "platform/image-encoders/WEBPImageEncoder.h" 47 #include "platform/image-encoders/WEBPImageEncoder.h"
48 #include "public/platform/Platform.h" 48 #include "public/platform/Platform.h"
49 #include "public/platform/WebExternalTextureMailbox.h" 49 #include "public/platform/WebExternalTextureMailbox.h"
50 #include "public/platform/WebGraphicsContext3DProvider.h" 50 #include "public/platform/WebGraphicsContext3DProvider.h"
51 #include "skia/ext/texture_handle.h" 51 #include "skia/ext/texture_handle.h"
52 #include "third_party/skia/include/core/SkPicture.h" 52 #include "third_party/skia/include/core/SkPicture.h"
53 #include "third_party/skia/include/gpu/GrContext.h" 53 #include "third_party/skia/include/gpu/GrContext.h"
54 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" 54 #include "third_party/skia/include/gpu/gl/GrGLTypes.h"
55 #include "wtf/CheckedNumeric.h" 55 #include "wtf/CheckedNumeric.h"
56 #include "wtf/MathExtras.h" 56 #include "wtf/MathExtras.h"
57 #include "wtf/PtrUtil.h"
57 #include "wtf/Vector.h" 58 #include "wtf/Vector.h"
58 #include "wtf/text/Base64.h" 59 #include "wtf/text/Base64.h"
59 #include "wtf/text/WTFString.h" 60 #include "wtf/text/WTFString.h"
60 #include "wtf/typed_arrays/ArrayBufferContents.h" 61 #include "wtf/typed_arrays/ArrayBufferContents.h"
62 #include <memory>
61 63
62 namespace blink { 64 namespace blink {
63 65
64 PassOwnPtr<ImageBuffer> ImageBuffer::create(PassOwnPtr<ImageBufferSurface> surfa ce) 66 std::unique_ptr<ImageBuffer> ImageBuffer::create(std::unique_ptr<ImageBufferSurf ace> surface)
65 { 67 {
66 if (!surface->isValid()) 68 if (!surface->isValid())
67 return nullptr; 69 return nullptr;
68 return adoptPtr(new ImageBuffer(std::move(surface))); 70 return wrapUnique(new ImageBuffer(std::move(surface)));
69 } 71 }
70 72
71 PassOwnPtr<ImageBuffer> ImageBuffer::create(const IntSize& size, OpacityMode opa cityMode, ImageInitializationMode initializationMode) 73 std::unique_ptr<ImageBuffer> ImageBuffer::create(const IntSize& size, OpacityMod e opacityMode, ImageInitializationMode initializationMode)
72 { 74 {
73 OwnPtr<ImageBufferSurface> surface(adoptPtr(new UnacceleratedImageBufferSurf ace(size, opacityMode, initializationMode))); 75 std::unique_ptr<ImageBufferSurface> surface(wrapUnique(new UnacceleratedImag eBufferSurface(size, opacityMode, initializationMode)));
74 if (!surface->isValid()) 76 if (!surface->isValid())
75 return nullptr; 77 return nullptr;
76 return adoptPtr(new ImageBuffer(std::move(surface))); 78 return wrapUnique(new ImageBuffer(std::move(surface)));
77 } 79 }
78 80
79 ImageBuffer::ImageBuffer(PassOwnPtr<ImageBufferSurface> surface) 81 ImageBuffer::ImageBuffer(std::unique_ptr<ImageBufferSurface> surface)
80 : m_snapshotState(InitialSnapshotState) 82 : m_snapshotState(InitialSnapshotState)
81 , m_surface(std::move(surface)) 83 , m_surface(std::move(surface))
82 , m_client(0) 84 , m_client(0)
83 , m_gpuMemoryUsage(0) 85 , m_gpuMemoryUsage(0)
84 { 86 {
85 m_surface->setImageBuffer(this); 87 m_surface->setImageBuffer(this);
86 updateGPUMemoryUsage(); 88 updateGPUMemoryUsage();
87 } 89 }
88 90
89 intptr_t ImageBuffer::s_globalGPUMemoryUsage = 0; 91 intptr_t ImageBuffer::s_globalGPUMemoryUsage = 0;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 if (!m_surface->isAccelerated()) 194 if (!m_surface->isAccelerated())
193 return false; 195 return false;
194 196
195 197
196 ASSERT(textureImage->isTextureBacked()); // isAccelerated() check above shou ld guarantee this 198 ASSERT(textureImage->isTextureBacked()); // isAccelerated() check above shou ld guarantee this
197 // Get the texture ID, flushing pending operations if needed. 199 // Get the texture ID, flushing pending operations if needed.
198 const GrGLTextureInfo* textureInfo = skia::GrBackendObjectToGrGLTextureInfo( textureImage->getTextureHandle(true)); 200 const GrGLTextureInfo* textureInfo = skia::GrBackendObjectToGrGLTextureInfo( textureImage->getTextureHandle(true));
199 if (!textureInfo || !textureInfo->fID) 201 if (!textureInfo || !textureInfo->fID)
200 return false; 202 return false;
201 203
202 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current() ->createSharedOffscreenGraphicsContext3DProvider()); 204 std::unique_ptr<WebGraphicsContext3DProvider> provider = wrapUnique(Platform ::current()->createSharedOffscreenGraphicsContext3DProvider());
203 if (!provider) 205 if (!provider)
204 return false; 206 return false;
205 gpu::gles2::GLES2Interface* sharedGL = provider->contextGL(); 207 gpu::gles2::GLES2Interface* sharedGL = provider->contextGL();
206 208
207 OwnPtr<WebExternalTextureMailbox> mailbox = adoptPtr(new WebExternalTextureM ailbox); 209 std::unique_ptr<WebExternalTextureMailbox> mailbox = wrapUnique(new WebExter nalTextureMailbox);
208 mailbox->textureSize = WebSize(textureImage->width(), textureImage->height() ); 210 mailbox->textureSize = WebSize(textureImage->width(), textureImage->height() );
209 211
210 // Contexts may be in a different share group. We must transfer the texture through a mailbox first 212 // Contexts may be in a different share group. We must transfer the texture through a mailbox first
211 sharedGL->GenMailboxCHROMIUM(mailbox->name); 213 sharedGL->GenMailboxCHROMIUM(mailbox->name);
212 sharedGL->ProduceTextureDirectCHROMIUM(textureInfo->fID, textureInfo->fTarge t, mailbox->name); 214 sharedGL->ProduceTextureDirectCHROMIUM(textureInfo->fID, textureInfo->fTarge t, mailbox->name);
213 const GLuint64 sharedFenceSync = sharedGL->InsertFenceSyncCHROMIUM(); 215 const GLuint64 sharedFenceSync = sharedGL->InsertFenceSyncCHROMIUM();
214 sharedGL->Flush(); 216 sharedGL->Flush();
215 217
216 sharedGL->GenSyncTokenCHROMIUM(sharedFenceSync, mailbox->syncToken); 218 sharedGL->GenSyncTokenCHROMIUM(sharedFenceSync, mailbox->syncToken);
217 mailbox->validSyncToken = true; 219 mailbox->validSyncToken = true;
(...skipping 18 matching lines...) Expand all
236 // Undo grContext texture binding changes introduced in this function 238 // Undo grContext texture binding changes introduced in this function
237 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); 239 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState);
238 240
239 return true; 241 return true;
240 } 242 }
241 243
242 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu ffer, SourceDrawingBuffer sourceBuffer) 244 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu ffer, SourceDrawingBuffer sourceBuffer)
243 { 245 {
244 if (!drawingBuffer || !m_surface->isAccelerated()) 246 if (!drawingBuffer || !m_surface->isAccelerated())
245 return false; 247 return false;
246 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current() ->createSharedOffscreenGraphicsContext3DProvider()); 248 std::unique_ptr<WebGraphicsContext3DProvider> provider = wrapUnique(Platform ::current()->createSharedOffscreenGraphicsContext3DProvider());
247 if (!provider) 249 if (!provider)
248 return false; 250 return false;
249 gpu::gles2::GLES2Interface* gl = provider->contextGL(); 251 gpu::gles2::GLES2Interface* gl = provider->contextGL();
250 GLuint textureId = m_surface->getBackingTextureHandleForOverwrite(); 252 GLuint textureId = m_surface->getBackingTextureHandleForOverwrite();
251 if (!textureId) 253 if (!textureId)
252 return false; 254 return false;
253 255
254 gl->Flush(); 256 gl->Flush();
255 257
256 return drawingBuffer->copyToPlatformTexture(gl, textureId, GL_RGBA, 258 return drawingBuffer->copyToPlatformTexture(gl, textureId, GL_RGBA,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 402 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
401 403
402 Vector<unsigned char> result; 404 Vector<unsigned char> result;
403 if (!encodeImage(mimeType, quality, &result)) 405 if (!encodeImage(mimeType, quality, &result))
404 return "data:,"; 406 return "data:,";
405 407
406 return "data:" + mimeType + ";base64," + base64Encode(result); 408 return "data:" + mimeType + ";base64," + base64Encode(result);
407 } 409 }
408 410
409 } // namespace blink 411 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698