| 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 // Using accelerated 2d canvas with software renderer, which | 595 // Using accelerated 2d canvas with software renderer, which |
| 596 // should only happen in tests that use fake graphics contexts | 596 // should only happen in tests that use fake graphics contexts |
| 597 // or in Android WebView in software mode. In this case, we do | 597 // or in Android WebView in software mode. In this case, we do |
| 598 // not care about producing any results for this canvas. | 598 // not care about producing any results for this canvas. |
| 599 skipQueuedDrawCommands(); | 599 skipQueuedDrawCommands(); |
| 600 m_lastImageId = 0; | 600 m_lastImageId = 0; |
| 601 return false; | 601 return false; |
| 602 } | 602 } |
| 603 | 603 |
| 604 RefPtr<SkImage> image = newImageSnapshot(PreferAcceleration); | 604 RefPtr<SkImage> image = newImageSnapshot(PreferAcceleration); |
| 605 if (!image) | 605 if (!image || !image->getTexture()) |
| 606 return false; | 606 return false; |
| 607 | 607 |
| 608 WebGraphicsContext3D* webContext = context(); | 608 WebGraphicsContext3D* webContext = context(); |
| 609 | 609 |
| 610 // Early exit if canvas was not drawn to since last prepareMailbox | 610 // Early exit if canvas was not drawn to since last prepareMailbox |
| 611 GLenum filter = m_filterQuality == kNone_SkFilterQuality ? GL_NEAREST : GL_L
INEAR; | 611 GLenum filter = m_filterQuality == kNone_SkFilterQuality ? GL_NEAREST : GL_L
INEAR; |
| 612 if (image->uniqueID() == m_lastImageId && filter == m_lastFilter) | 612 if (image->uniqueID() == m_lastImageId && filter == m_lastFilter) |
| 613 return false; | 613 return false; |
| 614 m_lastImageId = image->uniqueID(); | 614 m_lastImageId = image->uniqueID(); |
| 615 m_lastFilter = filter; | 615 m_lastFilter = filter; |
| 616 | 616 |
| 617 { | 617 { |
| 618 MailboxInfo tmp; | 618 MailboxInfo tmp; |
| 619 tmp.m_image = image; | 619 tmp.m_image = image; |
| 620 tmp.m_parentLayerBridge = this; | 620 tmp.m_parentLayerBridge = this; |
| 621 m_mailboxes.prepend(tmp); | 621 m_mailboxes.prepend(tmp); |
| 622 } | 622 } |
| 623 MailboxInfo& mailboxInfo = m_mailboxes.first(); | 623 MailboxInfo& mailboxInfo = m_mailboxes.first(); |
| 624 | 624 |
| 625 mailboxInfo.m_mailbox.nearestNeighbor = filter == GL_NEAREST; | 625 mailboxInfo.m_mailbox.nearestNeighbor = filter == GL_NEAREST; |
| 626 | 626 |
| 627 GrContext* grContext = m_contextProvider->grContext(); | 627 GrContext* grContext = m_contextProvider->grContext(); |
| 628 if (!grContext) | 628 if (!grContext) |
| 629 return true; // for testing: skip gl stuff when using a mock graphics co
ntext. | 629 return true; // for testing: skip gl stuff when using a mock graphics co
ntext. |
| 630 | 630 |
| 631 // Need to flush skia's internal queue because texture is about to be access
ed directly | 631 // Need to flush skia's internal queue because texture is about to be access
ed directly |
| 632 grContext->flush(); | 632 grContext->flush(); |
| 633 | 633 |
| 634 ASSERT(image->getTexture()); | |
| 635 | |
| 636 // Because of texture sharing with the compositor, we must invalidate | 634 // Because of texture sharing with the compositor, we must invalidate |
| 637 // the state cached in skia so that the deferred copy on write | 635 // the state cached in skia so that the deferred copy on write |
| 638 // in SkSurface_Gpu does not make any false assumptions. | 636 // in SkSurface_Gpu does not make any false assumptions. |
| 639 mailboxInfo.m_image->getTexture()->textureParamsModified(); | 637 mailboxInfo.m_image->getTexture()->textureParamsModified(); |
| 640 mailboxInfo.m_mailbox.textureTarget = GL_TEXTURE_2D; | 638 mailboxInfo.m_mailbox.textureTarget = GL_TEXTURE_2D; |
| 641 | 639 |
| 642 webContext->bindTexture(GL_TEXTURE_2D, mailboxInfo.m_image->getTexture()->ge
tTextureHandle()); | 640 webContext->bindTexture(GL_TEXTURE_2D, mailboxInfo.m_image->getTexture()->ge
tTextureHandle()); |
| 643 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); | 641 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); |
| 644 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); | 642 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); |
| 645 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE
); | 643 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE
); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 m_image = other.m_image; | 820 m_image = other.m_image; |
| 823 m_parentLayerBridge = other.m_parentLayerBridge; | 821 m_parentLayerBridge = other.m_parentLayerBridge; |
| 824 } | 822 } |
| 825 | 823 |
| 826 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) | 824 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) |
| 827 { | 825 { |
| 828 blink::Platform::current()->histogramEnumeration("Canvas.HibernationEvents",
event, HibernationEventCount); | 826 blink::Platform::current()->histogramEnumeration("Canvas.HibernationEvents",
event, HibernationEventCount); |
| 829 } | 827 } |
| 830 | 828 |
| 831 } // namespace blink | 829 } // namespace blink |
| OLD | NEW |