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

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

Issue 2261623002: Make DrawingBuffer and Canvas2DLayerBridge be cc::TextureLayerClients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: webmailbox: fix-passrefptr Created 4 years, 4 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 15 matching lines...) Expand all
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33 #include "platform/graphics/ImageBuffer.h" 33 #include "platform/graphics/ImageBuffer.h"
34 34
35 #include "gpu/command_buffer/client/gles2_interface.h" 35 #include "gpu/command_buffer/client/gles2_interface.h"
36 #include "gpu/command_buffer/common/mailbox.h"
37 #include "gpu/command_buffer/common/sync_token.h"
36 #include "platform/MIMETypeRegistry.h" 38 #include "platform/MIMETypeRegistry.h"
37 #include "platform/RuntimeEnabledFeatures.h" 39 #include "platform/RuntimeEnabledFeatures.h"
38 #include "platform/geometry/IntRect.h" 40 #include "platform/geometry/IntRect.h"
39 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" 41 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
40 #include "platform/graphics/GraphicsContext.h" 42 #include "platform/graphics/GraphicsContext.h"
41 #include "platform/graphics/ImageBufferClient.h" 43 #include "platform/graphics/ImageBufferClient.h"
42 #include "platform/graphics/RecordingImageBufferSurface.h" 44 #include "platform/graphics/RecordingImageBufferSurface.h"
43 #include "platform/graphics/StaticBitmapImage.h" 45 #include "platform/graphics/StaticBitmapImage.h"
44 #include "platform/graphics/UnacceleratedImageBufferSurface.h" 46 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
45 #include "platform/graphics/gpu/DrawingBuffer.h" 47 #include "platform/graphics/gpu/DrawingBuffer.h"
46 #include "platform/graphics/gpu/Extensions3DUtil.h" 48 #include "platform/graphics/gpu/Extensions3DUtil.h"
47 #include "platform/graphics/skia/SkiaUtils.h" 49 #include "platform/graphics/skia/SkiaUtils.h"
48 #include "platform/image-encoders/JPEGImageEncoder.h" 50 #include "platform/image-encoders/JPEGImageEncoder.h"
49 #include "platform/image-encoders/PNGImageEncoder.h" 51 #include "platform/image-encoders/PNGImageEncoder.h"
50 #include "platform/image-encoders/WEBPImageEncoder.h" 52 #include "platform/image-encoders/WEBPImageEncoder.h"
51 #include "public/platform/Platform.h" 53 #include "public/platform/Platform.h"
52 #include "public/platform/WebExternalTextureMailbox.h"
53 #include "public/platform/WebGraphicsContext3DProvider.h" 54 #include "public/platform/WebGraphicsContext3DProvider.h"
54 #include "skia/ext/texture_handle.h" 55 #include "skia/ext/texture_handle.h"
55 #include "third_party/skia/include/core/SkPicture.h" 56 #include "third_party/skia/include/core/SkPicture.h"
56 #include "third_party/skia/include/gpu/GrContext.h" 57 #include "third_party/skia/include/gpu/GrContext.h"
57 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" 58 #include "third_party/skia/include/gpu/gl/GrGLTypes.h"
58 #include "wtf/CheckedNumeric.h" 59 #include "wtf/CheckedNumeric.h"
59 #include "wtf/MathExtras.h" 60 #include "wtf/MathExtras.h"
60 #include "wtf/PtrUtil.h" 61 #include "wtf/PtrUtil.h"
61 #include "wtf/Vector.h" 62 #include "wtf/Vector.h"
62 #include "wtf/text/Base64.h" 63 #include "wtf/text/Base64.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // Get the texture ID, flushing pending operations if needed. 220 // Get the texture ID, flushing pending operations if needed.
220 const GrGLTextureInfo* textureInfo = skia::GrBackendObjectToGrGLTextureInfo( textureImage->getTextureHandle(true)); 221 const GrGLTextureInfo* textureInfo = skia::GrBackendObjectToGrGLTextureInfo( textureImage->getTextureHandle(true));
221 if (!textureInfo || !textureInfo->fID) 222 if (!textureInfo || !textureInfo->fID)
222 return false; 223 return false;
223 224
224 std::unique_ptr<WebGraphicsContext3DProvider> provider = wrapUnique(Platform ::current()->createSharedOffscreenGraphicsContext3DProvider()); 225 std::unique_ptr<WebGraphicsContext3DProvider> provider = wrapUnique(Platform ::current()->createSharedOffscreenGraphicsContext3DProvider());
225 if (!provider) 226 if (!provider)
226 return false; 227 return false;
227 gpu::gles2::GLES2Interface* sharedGL = provider->contextGL(); 228 gpu::gles2::GLES2Interface* sharedGL = provider->contextGL();
228 229
229 std::unique_ptr<WebExternalTextureMailbox> mailbox = wrapUnique(new WebExter nalTextureMailbox); 230 gpu::Mailbox mailbox;
230 mailbox->textureSize = WebSize(textureImage->width(), textureImage->height() ); 231 IntSize textureSize(textureImage->width(), textureImage->height());
231 232
232 // Contexts may be in a different share group. We must transfer the texture through a mailbox first 233 // Contexts may be in a different share group. We must transfer the texture through a mailbox first
233 sharedGL->GenMailboxCHROMIUM(mailbox->name); 234 sharedGL->GenMailboxCHROMIUM(mailbox.name);
234 sharedGL->ProduceTextureDirectCHROMIUM(textureInfo->fID, textureInfo->fTarge t, mailbox->name); 235 sharedGL->ProduceTextureDirectCHROMIUM(textureInfo->fID, textureInfo->fTarge t, mailbox.name);
235 const GLuint64 sharedFenceSync = sharedGL->InsertFenceSyncCHROMIUM(); 236 const GLuint64 sharedFenceSync = sharedGL->InsertFenceSyncCHROMIUM();
236 sharedGL->Flush(); 237 sharedGL->Flush();
237 238
238 sharedGL->GenSyncTokenCHROMIUM(sharedFenceSync, mailbox->syncToken); 239 gpu::SyncToken produceSyncToken;
239 mailbox->validSyncToken = true; 240 sharedGL->GenSyncTokenCHROMIUM(sharedFenceSync, produceSyncToken.GetData());
240 gl->WaitSyncTokenCHROMIUM(mailbox->syncToken); 241 gl->WaitSyncTokenCHROMIUM(produceSyncToken.GetConstData());
241 242
242 GLuint sourceTexture = gl->CreateAndConsumeTextureCHROMIUM(textureInfo->fTar get, mailbox->name); 243 GLuint sourceTexture = gl->CreateAndConsumeTextureCHROMIUM(textureInfo->fTar get, mailbox.name);
243 244
244 // The canvas is stored in a premultiplied format, so unpremultiply if neces sary. 245 // The canvas is stored in a premultiplied format, so unpremultiply if neces sary.
245 // The canvas is stored in an inverted position, so the flip semantics are r eversed. 246 // The canvas is stored in an inverted position, so the flip semantics are r eversed.
246 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, fl ipY ? GL_FALSE : GL_TRUE, GL_FALSE, premultiplyAlpha ? GL_FALSE : GL_TRUE); 247 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, fl ipY ? GL_FALSE : GL_TRUE, GL_FALSE, premultiplyAlpha ? GL_FALSE : GL_TRUE);
247 248
248 gl->DeleteTextures(1, &sourceTexture); 249 gl->DeleteTextures(1, &sourceTexture);
249 250
250 const GLuint64 contextFenceSync = gl->InsertFenceSyncCHROMIUM(); 251 const GLuint64 contextFenceSync = gl->InsertFenceSyncCHROMIUM();
251 252
252 gl->Flush(); 253 gl->Flush();
253 254
254 GLbyte syncToken[24]; 255 gpu::SyncToken copySyncToken;
255 gl->GenSyncTokenCHROMIUM(contextFenceSync, syncToken); 256 gl->GenSyncTokenCHROMIUM(contextFenceSync, copySyncToken.GetData());
256 sharedGL->WaitSyncTokenCHROMIUM(syncToken); 257 sharedGL->WaitSyncTokenCHROMIUM(copySyncToken.GetConstData());
257 // This disassociates the texture from the mailbox to avoid leaking the 258 // This disassociates the texture from the mailbox to avoid leaking the
258 // mapping between the two. 259 // mapping between the two.
259 sharedGL->ProduceTextureDirectCHROMIUM(0, textureInfo->fTarget, mailbox->nam e); 260 sharedGL->ProduceTextureDirectCHROMIUM(0, textureInfo->fTarget, mailbox.name );
260 261
261 // Undo grContext texture binding changes introduced in this function 262 // Undo grContext texture binding changes introduced in this function
262 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); 263 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState);
263 264
264 return true; 265 return true;
265 } 266 }
266 267
267 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu ffer, SourceDrawingBuffer sourceBuffer) 268 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu ffer, SourceDrawingBuffer sourceBuffer)
268 { 269 {
269 if (!drawingBuffer || !m_surface->isAccelerated()) 270 if (!drawingBuffer || !m_surface->isAccelerated())
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 465 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
465 466
466 Vector<unsigned char> result; 467 Vector<unsigned char> result;
467 if (!encodeImage(mimeType, quality, &result)) 468 if (!encodeImage(mimeType, quality, &result))
468 return "data:,"; 469 return "data:,";
469 470
470 return "data:" + mimeType + ";base64," + base64Encode(result); 471 return "data:" + mimeType + ";base64," + base64Encode(result);
471 } 472 }
472 473
473 } // namespace blink 474 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/DEPS ('k') | third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698