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

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

Issue 2495953002: Support uploads of sub-rectangles of canvases to 2D and 3D textures. (Closed)
Patch Set: Fixed regression in accelerated video-to-texture uploads. Marked Mac Intel failures. Created 4 years, 1 month 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 WebLayer* ImageBuffer::platformLayer() const { 207 WebLayer* ImageBuffer::platformLayer() const {
208 return m_surface->layer(); 208 return m_surface->layer();
209 } 209 }
210 210
211 bool ImageBuffer::copyToPlatformTexture(gpu::gles2::GLES2Interface* gl, 211 bool ImageBuffer::copyToPlatformTexture(gpu::gles2::GLES2Interface* gl,
212 GLuint texture, 212 GLuint texture,
213 GLenum internalFormat, 213 GLenum internalFormat,
214 GLenum destType, 214 GLenum destType,
215 GLint level, 215 GLint level,
216 bool premultiplyAlpha, 216 bool premultiplyAlpha,
217 bool flipY) { 217 bool flipY,
218 const IntPoint& destPoint,
219 const IntRect& sourceSubRectangle) {
218 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM( 220 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(
219 GL_TEXTURE_2D, internalFormat, destType, level)) 221 GL_TEXTURE_2D, internalFormat, destType, level))
220 return false; 222 return false;
221 223
222 if (!isSurfaceValid()) 224 if (!isSurfaceValid())
223 return false; 225 return false;
224 226
225 sk_sp<const SkImage> textureImage = m_surface->newImageSnapshot( 227 sk_sp<const SkImage> textureImage = m_surface->newImageSnapshot(
226 PreferAcceleration, SnapshotReasonCopyToWebGLTexture); 228 PreferAcceleration, SnapshotReasonCopyToWebGLTexture);
227 if (!textureImage) 229 if (!textureImage)
(...skipping 29 matching lines...) Expand all
257 gpu::SyncToken produceSyncToken; 259 gpu::SyncToken produceSyncToken;
258 sharedGL->GenSyncTokenCHROMIUM(sharedFenceSync, produceSyncToken.GetData()); 260 sharedGL->GenSyncTokenCHROMIUM(sharedFenceSync, produceSyncToken.GetData());
259 gl->WaitSyncTokenCHROMIUM(produceSyncToken.GetConstData()); 261 gl->WaitSyncTokenCHROMIUM(produceSyncToken.GetConstData());
260 262
261 GLuint sourceTexture = 263 GLuint sourceTexture =
262 gl->CreateAndConsumeTextureCHROMIUM(textureInfo->fTarget, mailbox.name); 264 gl->CreateAndConsumeTextureCHROMIUM(textureInfo->fTarget, mailbox.name);
263 265
264 // The canvas is stored in a premultiplied format, so unpremultiply if 266 // The canvas is stored in a premultiplied format, so unpremultiply if
265 // necessary. The canvas is also stored in an inverted position, so the flip 267 // necessary. The canvas is also stored in an inverted position, so the flip
266 // semantics are reversed. 268 // semantics are reversed.
267 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, 269 // It is expected that callers of this method have already allocated
268 flipY ? GL_FALSE : GL_TRUE, GL_FALSE, 270 // the platform texture with the appropriate size.
269 premultiplyAlpha ? GL_FALSE : GL_TRUE); 271 gl->CopySubTextureCHROMIUM(sourceTexture, texture, destPoint.x(),
272 destPoint.y(), sourceSubRectangle.x(),
273 sourceSubRectangle.y(), sourceSubRectangle.width(),
274 sourceSubRectangle.height(),
275 flipY ? GL_FALSE : GL_TRUE, GL_FALSE,
276 premultiplyAlpha ? GL_FALSE : GL_TRUE);
270 277
271 gl->DeleteTextures(1, &sourceTexture); 278 gl->DeleteTextures(1, &sourceTexture);
272 279
273 const GLuint64 contextFenceSync = gl->InsertFenceSyncCHROMIUM(); 280 const GLuint64 contextFenceSync = gl->InsertFenceSyncCHROMIUM();
274 281
275 gl->Flush(); 282 gl->Flush();
276 283
277 gpu::SyncToken copySyncToken; 284 gpu::SyncToken copySyncToken;
278 gl->GenSyncTokenCHROMIUM(contextFenceSync, copySyncToken.GetData()); 285 gl->GenSyncTokenCHROMIUM(contextFenceSync, copySyncToken.GetData());
279 sharedGL->WaitSyncTokenCHROMIUM(copySyncToken.GetConstData()); 286 sharedGL->WaitSyncTokenCHROMIUM(copySyncToken.GetConstData());
(...skipping 19 matching lines...) Expand all
299 if (!provider) 306 if (!provider)
300 return false; 307 return false;
301 gpu::gles2::GLES2Interface* gl = provider->contextGL(); 308 gpu::gles2::GLES2Interface* gl = provider->contextGL();
302 GLuint textureId = m_surface->getBackingTextureHandleForOverwrite(); 309 GLuint textureId = m_surface->getBackingTextureHandleForOverwrite();
303 if (!textureId) 310 if (!textureId)
304 return false; 311 return false;
305 312
306 gl->Flush(); 313 gl->Flush();
307 314
308 return drawingBuffer->copyToPlatformTexture( 315 return drawingBuffer->copyToPlatformTexture(
309 gl, textureId, GL_RGBA, GL_UNSIGNED_BYTE, 0, true, false, sourceBuffer); 316 gl, textureId, GL_RGBA, GL_UNSIGNED_BYTE, 0, true, false, IntPoint(0, 0),
317 IntRect(IntPoint(0, 0), drawingBuffer->size()), sourceBuffer);
310 } 318 }
311 319
312 void ImageBuffer::draw(GraphicsContext& context, 320 void ImageBuffer::draw(GraphicsContext& context,
313 const FloatRect& destRect, 321 const FloatRect& destRect,
314 const FloatRect* srcPtr, 322 const FloatRect* srcPtr,
315 SkBlendMode op) { 323 SkBlendMode op) {
316 if (!isSurfaceValid()) 324 if (!isSurfaceValid())
317 return; 325 return;
318 326
319 FloatRect srcRect = 327 FloatRect srcRect =
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 562 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
555 563
556 Vector<unsigned char> result; 564 Vector<unsigned char> result;
557 if (!encodeImage(mimeType, quality, &result)) 565 if (!encodeImage(mimeType, quality, &result))
558 return "data:,"; 566 return "data:,";
559 567
560 return "data:" + mimeType + ";base64," + base64Encode(result); 568 return "data:" + mimeType + ";base64," + base64Encode(result);
561 } 569 }
562 570
563 } // namespace blink 571 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698