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

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

Issue 2262533002: Stop using GrTexture::get/setCustomData in Canvas2DLayerBridge (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 if (!gl) 335 if (!gl)
336 return false; 336 return false;
337 337
338 GLuint textureID = skia::GrBackendObjectToGrGLTextureInfo(mailboxInfo.m_imag e->getTextureHandle(true))->fID; 338 GLuint textureID = skia::GrBackendObjectToGrGLTextureInfo(mailboxInfo.m_imag e->getTextureHandle(true))->fID;
339 gl->BindTexture(GL_TEXTURE_2D, textureID); 339 gl->BindTexture(GL_TEXTURE_2D, textureID);
340 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter()); 340 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter());
341 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLFilter()); 341 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLFilter());
342 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 342 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
343 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 343 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
344 344
345 // Re-use the texture's existing mailbox, if there is one. 345 gl->GenMailboxCHROMIUM(mailboxInfo.m_mailbox.name);
346 if (mailboxInfo.m_image->getTexture()->getCustomData()) { 346 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailboxInfo.m_mailbox.name);
347 DCHECK(mailboxInfo.m_image->getTexture()->getCustomData()->size() == siz eof(mailboxInfo.m_mailbox.name));
348 memcpy(&mailboxInfo.m_mailbox.name[0], mailboxInfo.m_image->getTexture() ->getCustomData()->data(), sizeof(mailboxInfo.m_mailbox.name));
349 } else {
350 gl->GenMailboxCHROMIUM(mailboxInfo.m_mailbox.name);
351 sk_sp<SkData> mailboxNameData = SkData::MakeWithCopy(&mailboxInfo.m_mail box.name[0], sizeof(mailboxInfo.m_mailbox.name));
352 mailboxInfo.m_image->getTexture()->setCustomData(mailboxNameData.get());
353 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailboxInfo.m_mailbox.name);
354 }
355 347
356 if (isHidden()) { 348 if (isHidden()) {
357 // With hidden canvases, we release the SkImage immediately because 349 // With hidden canvases, we release the SkImage immediately because
358 // there is no need for animations to be double buffered. 350 // there is no need for animations to be double buffered.
359 mailboxInfo.m_image.clear(); 351 mailboxInfo.m_image.clear();
360 } else { 352 } else {
361 // FIXME: We'd rather insert a syncpoint than perform a flush here, 353 // FIXME: We'd rather insert a syncpoint than perform a flush here,
362 // but currently the canvas will flicker if we don't flush here. 354 // but currently the canvas will flicker if we don't flush here.
363 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); 355 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM();
364 gl->Flush(); 356 gl->Flush();
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 #endif // USE_IOSURFACE_FOR_2D_CANVAS 833 #endif // USE_IOSURFACE_FOR_2D_CANVAS
842 if (mailbox.validSyncToken) { 834 if (mailbox.validSyncToken) {
843 contextGL()->WaitSyncTokenCHROMIUM(mailbox.syncToken); 835 contextGL()->WaitSyncTokenCHROMIUM(mailbox.syncToken);
844 } 836 }
845 GrTexture* texture = releasedMailboxInfo->m_image->getTexture(); 837 GrTexture* texture = releasedMailboxInfo->m_image->getTexture();
846 if (texture) { 838 if (texture) {
847 if (lostResource) { 839 if (lostResource) {
848 texture->abandon(); 840 texture->abandon();
849 } else { 841 } else {
850 texture->textureParamsModified(); 842 texture->textureParamsModified();
843 // Break the mailbox association to avoid leaking mailboxes every time skia recycles a texture.
844 gpu::gles2::GLES2Interface* gl = contextGL();
845 if (gl)
846 gl->ProduceTextureDirectCHROMIUM(0, GL_TEXTURE_2D, relea sedMailboxInfo->m_mailbox.name);
851 } 847 }
852 } 848 }
853 } 849 }
854 850
855 #if USE_IOSURFACE_FOR_2D_CANVAS 851 #if USE_IOSURFACE_FOR_2D_CANVAS
856 if (!releasedMailboxInfo->m_imageInfo.empty() && !lostResource) { 852 if (!releasedMailboxInfo->m_imageInfo.empty() && !lostResource) {
857 m_imageInfoCache.append(releasedMailboxInfo->m_imageInfo); 853 m_imageInfoCache.append(releasedMailboxInfo->m_imageInfo);
858 } 854 }
859 #endif // USE_IOSURFACE_FOR_2D_CANVAS 855 #endif // USE_IOSURFACE_FOR_2D_CANVAS
860 } 856 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 #endif // USE_IOSURFACE_FOR_2D_CANVAS 988 #endif // USE_IOSURFACE_FOR_2D_CANVAS
993 } 989 }
994 990
995 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) 991 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event)
996 { 992 {
997 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount)); 993 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount));
998 hibernationHistogram.count(event); 994 hibernationHistogram.count(event);
999 } 995 }
1000 996
1001 } // namespace blink 997 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698