| OLD | NEW | 
|     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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   222     gl->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     gl->GenMailboxCHROMIUM(info.m_mailbox.name); |   226     gl->GenMailboxCHROMIUM(info.m_mailbox.name); | 
|   227     gl->ProduceTextureDirectCHROMIUM(imageInfo.m_textureId, info.m_mailbox.textu
      reTarget, 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     gl->GenSyncTokenCHROMIUM(fenceSync, info.m_mailbox.syncToken); | 
 |   233     info.m_mailbox.validSyncToken = true; | 
|   233  |   234  | 
|   234     info.m_imageInfo = imageInfo; |   235     info.m_imageInfo = imageInfo; | 
|   235     *outMailbox = info.m_mailbox; |   236     *outMailbox = info.m_mailbox; | 
|   236  |   237  | 
|   237     gl->BindTexture(GC3D_TEXTURE_RECTANGLE_ARB, 0); |   238     gl->BindTexture(GC3D_TEXTURE_RECTANGLE_ARB, 0); | 
|   238  |   239  | 
|   239     // Because we are changing the texture binding without going through skia, |   240     // Because we are changing the texture binding without going through skia, | 
|   240     // we must dirty the context. |   241     // we must dirty the context. | 
|   241     grContext->resetContext(kTextureBinding_GrGLBackendState); |   242     grContext->resetContext(kTextureBinding_GrGLBackendState); | 
|   242  |   243  | 
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   336  |   337  | 
|   337     // Need to flush skia's internal queue because texture is about to be access
      ed directly |   338     // Need to flush skia's internal queue because texture is about to be access
      ed directly | 
|   338     grContext->flush(); |   339     grContext->flush(); | 
|   339  |   340  | 
|   340     // Because of texture sharing with the compositor, we must invalidate |   341     // Because of texture sharing with the compositor, we must invalidate | 
|   341     // the state cached in skia so that the deferred copy on write |   342     // the state cached in skia so that the deferred copy on write | 
|   342     // in SkSurface_Gpu does not make any false assumptions. |   343     // in SkSurface_Gpu does not make any false assumptions. | 
|   343     mailboxInfo.m_image->getTexture()->textureParamsModified(); |   344     mailboxInfo.m_image->getTexture()->textureParamsModified(); | 
|   344     mailboxInfo.m_mailbox.textureTarget = GL_TEXTURE_2D; |   345     mailboxInfo.m_mailbox.textureTarget = GL_TEXTURE_2D; | 
|   345  |   346  | 
|   346     WebGraphicsContext3D* webContext = context(); |  | 
|   347     gpu::gles2::GLES2Interface* gl = contextGL(); |   347     gpu::gles2::GLES2Interface* gl = contextGL(); | 
|   348     GLuint textureID = skia::GrBackendObjectToGrGLTextureInfo(mailboxInfo.m_imag
      e->getTextureHandle(true))->fID; |   348     GLuint textureID = skia::GrBackendObjectToGrGLTextureInfo(mailboxInfo.m_imag
      e->getTextureHandle(true))->fID; | 
|   349     gl->BindTexture(GL_TEXTURE_2D, textureID); |   349     gl->BindTexture(GL_TEXTURE_2D, textureID); | 
|   350     gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter()); |   350     gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter()); | 
|   351     gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLFilter()); |   351     gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLFilter()); | 
|   352     gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |   352     gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 
|   353     gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |   353     gl->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         gl->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         gl->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         gl->Flush(); |   374         gl->Flush(); | 
|   375         mailboxInfo.m_mailbox.validSyncToken = webContext->genSyncTokenCHROMIUM(
      fenceSync, mailboxInfo.m_mailbox.syncToken); |   375         gl->GenSyncTokenCHROMIUM(fenceSync, mailboxInfo.m_mailbox.syncToken); | 
 |   376         mailboxInfo.m_mailbox.validSyncToken = true; | 
|   376     } |   377     } | 
|   377     gl->BindTexture(GL_TEXTURE_2D, 0); |   378     gl->BindTexture(GL_TEXTURE_2D, 0); | 
|   378     // Because we are changing the texture binding without going through skia, |   379     // Because we are changing the texture binding without going through skia, | 
|   379     // we must dirty the context. |   380     // we must dirty the context. | 
|   380     grContext->resetContext(kTextureBinding_GrGLBackendState); |   381     grContext->resetContext(kTextureBinding_GrGLBackendState); | 
|   381  |   382  | 
|   382     *outMailbox = mailboxInfo.m_mailbox; |   383     *outMailbox = mailboxInfo.m_mailbox; | 
|   383     return true; |   384     return true; | 
|   384 } |   385 } | 
|   385  |   386  | 
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1006 #endif // USE_IOSURFACE_FOR_2D_CANVAS |  1007 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 
|  1007 } |  1008 } | 
|  1008  |  1009  | 
|  1009 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) |  1010 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) | 
|  1010 { |  1011 { | 
|  1011     DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib
      ernationEvents", HibernationEventCount)); |  1012     DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib
      ernationEvents", HibernationEventCount)); | 
|  1012     hibernationHistogram.count(event); |  1013     hibernationHistogram.count(event); | 
|  1013 } |  1014 } | 
|  1014  |  1015  | 
|  1015 } // namespace blink |  1016 } // namespace blink | 
| OLD | NEW |