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

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

Issue 1418513016: Revert of webgl: optimize webgl.texSubImage2D(video) path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 if (m_snapshotState == DidAcquireSnapshot) 171 if (m_snapshotState == DidAcquireSnapshot)
172 m_snapshotState = DrawnToAfterSnapshot; 172 m_snapshotState = DrawnToAfterSnapshot;
173 m_surface->didDraw(rect); 173 m_surface->didDraw(rect);
174 } 174 }
175 175
176 WebLayer* ImageBuffer::platformLayer() const 176 WebLayer* ImageBuffer::platformLayer() const
177 { 177 {
178 return m_surface->layer(); 178 return m_surface->layer();
179 } 179 }
180 180
181 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, GLenum ta rget, Platform3DObject texture, 181 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3 DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premu ltiplyAlpha, bool flipY)
182 GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlpha, bool flipY)
183 { 182 {
184 return copyToPlatformTextureInternal(true, context, target, texture, interna lFormat, 183 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalForm at, destType, level))
185 destType, level, 0, 0, 0, 0, premultiplyAlpha, flipY);
186 }
187
188 bool ImageBuffer::copySubToPlatformTexture(WebGraphicsContext3D* context, GLenum target, Platform3DObject texture,
189 GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, bo ol premultiplyAlpha, bool flipY)
190 {
191 return copyToPlatformTextureInternal(false, context, target, texture, GL_FAL SE, GL_FALSE, level,
192 xoffset, yoffset, width, height, premultiplyAlpha, flipY);
193 }
194
195 bool ImageBuffer::copyToPlatformTextureInternal(bool isFullCopy, WebGraphicsCont ext3D* context, GLenum target,
196 Platform3DObject texture, GLenum internalFormat, GLenum destType, GLint leve l, GLint xoffset, GLint yoffset,
197 GLsizei width, GLsizei height, bool premultiplyAlpha, bool flipY)
198 {
199 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalFormat, des tType, level))
200 return false; 184 return false;
201 185
202 if (!isSurfaceValid()) 186 if (!isSurfaceValid())
203 return false; 187 return false;
204 188
205 RefPtr<const SkImage> textureImage = m_surface->newImageSnapshot(PreferAccel eration); 189 RefPtr<const SkImage> textureImage = m_surface->newImageSnapshot(PreferAccel eration);
206 if (!textureImage) 190 if (!textureImage)
207 return false; 191 return false;
208 192
209 if (!m_surface->isAccelerated()) 193 if (!m_surface->isAccelerated())
(...skipping 18 matching lines...) Expand all
228 // 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
229 sharedContext->genMailboxCHROMIUM(mailbox->name); 213 sharedContext->genMailboxCHROMIUM(mailbox->name);
230 sharedContext->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo x->name); 214 sharedContext->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo x->name);
231 sharedContext->flush(); 215 sharedContext->flush();
232 216
233 mailbox->syncPoint = sharedContext->insertSyncPoint(); 217 mailbox->syncPoint = sharedContext->insertSyncPoint();
234 218
235 context->waitSyncPoint(mailbox->syncPoint); 219 context->waitSyncPoint(mailbox->syncPoint);
236 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL _TEXTURE_2D, mailbox->name); 220 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL _TEXTURE_2D, mailbox->name);
237 221
238 WGC3Dboolean glFlipY = flipY ? GL_FALSE : GL_TRUE;
239 WGC3Dboolean glPremultiplyAlpha = premultiplyAlpha ? GL_FALSE : GL_TRUE;
240
241 // The canvas is stored in a premultiplied format, so unpremultiply if neces sary. 222 // The canvas is stored in a premultiplied format, so unpremultiply if neces sary.
242 // The canvas is stored in an inverted position, so the flip semantics are r eversed. 223 // The canvas is stored in an inverted position, so the flip semantics are r eversed.
243 if (isFullCopy) { 224 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, internal Format, destType, flipY ? GL_FALSE : GL_TRUE, GL_FALSE, premultiplyAlpha ? GL_FA LSE : GL_TRUE);
244 context->copyTextureCHROMIUM(target, sourceTexture, texture, internalFor mat, destType, glFlipY, GL_FALSE, glPremultiplyAlpha);
245 } else {
246 context->copySubTextureCHROMIUM(target, sourceTexture, texture, xoffset, yoffset, 0, 0, width, height, glFlipY, GL_FALSE, glPremultiplyAlpha);
247 }
248 225
249 context->deleteTexture(sourceTexture); 226 context->deleteTexture(sourceTexture);
250 227
251 context->flush(); 228 context->flush();
252 sharedContext->waitSyncPoint(context->insertSyncPoint()); 229 sharedContext->waitSyncPoint(context->insertSyncPoint());
253 230
254 // Undo grContext texture binding changes introduced in this function 231 // Undo grContext texture binding changes introduced in this function
255 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); 232 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState);
256 233
257 return true; 234 return true;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 376 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
400 377
401 Vector<char> encodedImage; 378 Vector<char> encodedImage;
402 if (!encodeImage(mimeType, quality, &encodedImage)) 379 if (!encodeImage(mimeType, quality, &encodedImage))
403 return "data:,"; 380 return "data:,";
404 381
405 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); 382 return "data:" + mimeType + ";base64," + base64Encode(encodedImage);
406 } 383 }
407 384
408 } // namespace blink 385 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698