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

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

Issue 1808403002: Move simple methods [F-S] from WebGraphicsContext3D to GLES2Interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bindFoo
Patch Set: simples-fplus: tests Created 4 years, 9 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // Need to flush skia's internal queue because texture is about to be access ed directly 212 // Need to flush skia's internal queue because texture is about to be access ed directly
213 GrContext* grContext = m_contextProvider->grContext(); 213 GrContext* grContext = m_contextProvider->grContext();
214 grContext->flush(); 214 grContext->flush();
215 215
216 ImageInfo imageInfo = createIOSurfaceBackedTexture(); 216 ImageInfo imageInfo = createIOSurfaceBackedTexture();
217 if (imageInfo.empty()) 217 if (imageInfo.empty())
218 return false; 218 return false;
219 219
220 gpu::gles2::GLES2Interface* gl = contextGL(); 220 gpu::gles2::GLES2Interface* gl = contextGL();
221 GLuint imageTexture = skia::GrBackendObjectToGrGLTextureInfo(image->getTextu reHandle(true))->fID; 221 GLuint imageTexture = skia::GrBackendObjectToGrGLTextureInfo(image->getTextu reHandle(true))->fID;
222 context()->copySubTextureCHROMIUM(imageTexture, imageInfo.m_textureId, 0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_FALSE); 222 gl->CopySubTextureCHROMIUM(imageTexture, imageInfo.m_textureId, 0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_FALSE);
223 223
224 MailboxInfo& info = m_mailboxes.first(); 224 MailboxInfo& info = m_mailboxes.first();
225 info.m_mailbox.textureTarget = GC3D_TEXTURE_RECTANGLE_ARB; 225 info.m_mailbox.textureTarget = GC3D_TEXTURE_RECTANGLE_ARB;
226 context()->genMailboxCHROMIUM(info.m_mailbox.name); 226 gl->GenMailboxCHROMIUM(info.m_mailbox.name);
227 context()->produceTextureDirectCHROMIUM(imageInfo.m_textureId, info.m_mailbo x.textureTarget, info.m_mailbox.name); 227 gl->ProduceTextureDirectCHROMIUM(imageInfo.m_textureId, info.m_mailbox.textu reTarget, info.m_mailbox.name);
228 info.m_mailbox.allowOverlay = true; 228 info.m_mailbox.allowOverlay = true;
229 229
230 const WGC3Duint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); 230 const WGC3Duint64 fenceSync = gl->InsertFenceSyncCHROMIUM();
231 context()->flush(); 231 context()->flush();
232 info.m_mailbox.validSyncToken = context()->genSyncTokenCHROMIUM(fenceSync, i nfo.m_mailbox.syncToken); 232 info.m_mailbox.validSyncToken = context()->genSyncTokenCHROMIUM(fenceSync, i nfo.m_mailbox.syncToken);
233 233
234 info.m_imageInfo = imageInfo; 234 info.m_imageInfo = imageInfo;
235 *outMailbox = info.m_mailbox; 235 *outMailbox = info.m_mailbox;
236 236
237 gl->BindTexture(GC3D_TEXTURE_RECTANGLE_ARB, 0); 237 gl->BindTexture(GC3D_TEXTURE_RECTANGLE_ARB, 0);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter( )); 350 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter( ));
351 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLFilter( )); 351 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLFilter( ));
352 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); 352 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
353 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); 353 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
354 354
355 // Re-use the texture's existing mailbox, if there is one. 355 // Re-use the texture's existing mailbox, if there is one.
356 if (mailboxInfo.m_image->getTexture()->getCustomData()) { 356 if (mailboxInfo.m_image->getTexture()->getCustomData()) {
357 ASSERT(mailboxInfo.m_image->getTexture()->getCustomData()->size() == siz eof(mailboxInfo.m_mailbox.name)); 357 ASSERT(mailboxInfo.m_image->getTexture()->getCustomData()->size() == siz eof(mailboxInfo.m_mailbox.name));
358 memcpy(&mailboxInfo.m_mailbox.name[0], mailboxInfo.m_image->getTexture() ->getCustomData()->data(), sizeof(mailboxInfo.m_mailbox.name)); 358 memcpy(&mailboxInfo.m_mailbox.name[0], mailboxInfo.m_image->getTexture() ->getCustomData()->data(), sizeof(mailboxInfo.m_mailbox.name));
359 } else { 359 } else {
360 context()->genMailboxCHROMIUM(mailboxInfo.m_mailbox.name); 360 gl->GenMailboxCHROMIUM(mailboxInfo.m_mailbox.name);
361 RefPtr<SkData> mailboxNameData = adoptRef(SkData::NewWithCopy(&mailboxIn fo.m_mailbox.name[0], sizeof(mailboxInfo.m_mailbox.name))); 361 RefPtr<SkData> mailboxNameData = adoptRef(SkData::NewWithCopy(&mailboxIn fo.m_mailbox.name[0], sizeof(mailboxInfo.m_mailbox.name)));
362 mailboxInfo.m_image->getTexture()->setCustomData(mailboxNameData.get()); 362 mailboxInfo.m_image->getTexture()->setCustomData(mailboxNameData.get());
363 webContext->produceTextureCHROMIUM(GL_TEXTURE_2D, mailboxInfo.m_mailbox. name); 363 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailboxInfo.m_mailbox.name);
364 } 364 }
365 365
366 if (isHidden()) { 366 if (isHidden()) {
367 // With hidden canvases, we release the SkImage immediately because 367 // With hidden canvases, we release the SkImage immediately because
368 // there is no need for animations to be double buffered. 368 // there is no need for animations to be double buffered.
369 mailboxInfo.m_image.clear(); 369 mailboxInfo.m_image.clear();
370 } else { 370 } else {
371 // FIXME: We'd rather insert a syncpoint than perform a flush here, 371 // FIXME: We'd rather insert a syncpoint than perform a flush here,
372 // but currently the canvas will flicker if we don't flush here. 372 // but currently the canvas will flicker if we don't flush here.
373 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); 373 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM();
374 webContext->flush(); 374 gl->Flush();
375 mailboxInfo.m_mailbox.validSyncToken = webContext->genSyncTokenCHROMIUM( fenceSync, mailboxInfo.m_mailbox.syncToken); 375 mailboxInfo.m_mailbox.validSyncToken = webContext->genSyncTokenCHROMIUM( fenceSync, mailboxInfo.m_mailbox.syncToken);
376 } 376 }
377 gl->BindTexture(GL_TEXTURE_2D, 0); 377 gl->BindTexture(GL_TEXTURE_2D, 0);
378 // Because we are changing the texture binding without going through skia, 378 // Because we are changing the texture binding without going through skia,
379 // we must dirty the context. 379 // we must dirty the context.
380 grContext->resetContext(kTextureBinding_GrGLBackendState); 380 grContext->resetContext(kTextureBinding_GrGLBackendState);
381 381
382 *outMailbox = mailboxInfo.m_mailbox; 382 *outMailbox = mailboxInfo.m_mailbox;
383 return true; 383 return true;
384 } 384 }
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 return; 700 return;
701 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flush"); 701 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flush");
702 flushRecordingOnly(); 702 flushRecordingOnly();
703 getOrCreateSurface()->getCanvas()->flush(); 703 getOrCreateSurface()->getCanvas()->flush();
704 } 704 }
705 705
706 void Canvas2DLayerBridge::flushGpu() 706 void Canvas2DLayerBridge::flushGpu()
707 { 707 {
708 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flushGpu"); 708 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flushGpu");
709 flush(); 709 flush();
710 WebGraphicsContext3D* webContext = context(); 710 gpu::gles2::GLES2Interface* gl = contextGL();
711 if (isAccelerated() && webContext) 711 if (isAccelerated() && gl)
712 webContext->flush(); 712 gl->Flush();
713 } 713 }
714 714
715 715
716 WebGraphicsContext3D* Canvas2DLayerBridge::context() 716 WebGraphicsContext3D* Canvas2DLayerBridge::context()
717 { 717 {
718 // Check on m_layer is necessary because context() may be called during 718 // Check on m_layer is necessary because context() may be called during
719 // the destruction of m_layer 719 // the destruction of m_layer
720 if (m_layer && !m_destructionInProgress) 720 if (m_layer && !m_destructionInProgress)
721 checkSurfaceValid(); // To ensure rate limiter is disabled if context is lost. 721 checkSurfaceValid(); // To ensure rate limiter is disabled if context is lost.
722 return m_contextProvider ? m_contextProvider->context3d() : 0; 722 return m_contextProvider ? m_contextProvider->context3d() : 0;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 #endif // USE_IOSURFACE_FOR_2D_CANVAS 1006 #endif // USE_IOSURFACE_FOR_2D_CANVAS
1007 } 1007 }
1008 1008
1009 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) 1009 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event)
1010 { 1010 {
1011 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount)); 1011 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount));
1012 hibernationHistogram.count(event); 1012 hibernationHistogram.count(event);
1013 } 1013 }
1014 1014
1015 } // namespace blink 1015 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698