| Index: Source/platform/graphics/Canvas2DLayerBridge.cpp
|
| diff --git a/Source/platform/graphics/Canvas2DLayerBridge.cpp b/Source/platform/graphics/Canvas2DLayerBridge.cpp
|
| index e74a1c7a0a0bcbbe47e46c8605a3faa68c7880c9..89a50a54e91d810a8ec5b32222f0ce26274c2152 100644
|
| --- a/Source/platform/graphics/Canvas2DLayerBridge.cpp
|
| +++ b/Source/platform/graphics/Canvas2DLayerBridge.cpp
|
| @@ -88,10 +88,12 @@ Canvas2DLayerBridge::Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider
|
| , m_framesSinceMailboxRelease(0)
|
| , m_destructionInProgress(false)
|
| , m_rateLimitingEnabled(false)
|
| + , m_filterLevel(SkPaint::kLow_FilterLevel)
|
| , m_isHidden(false)
|
| , m_next(0)
|
| , m_prev(0)
|
| , m_lastImageId(0)
|
| + , m_lastFilter(GL_LINEAR)
|
| , m_releasedMailboxInfoIndex(InvalidMailboxIndex)
|
| {
|
| ASSERT(m_canvas);
|
| @@ -104,6 +106,7 @@ Canvas2DLayerBridge::Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider
|
| m_layer->setBlendBackgroundColor(opacityMode != Opaque);
|
| GraphicsLayer::registerContentsLayer(m_layer->layer());
|
| m_layer->setRateLimitContext(m_rateLimitingEnabled);
|
| + m_layer->setNearestNeighbor(m_filterLevel == SkPaint::kNone_FilterLevel);
|
| m_canvas->setNotificationClient(this);
|
| #ifndef NDEBUG
|
| canvas2DLayerBridgeInstanceCounter.increment();
|
| @@ -152,6 +155,16 @@ void Canvas2DLayerBridge::beginDestruction()
|
| ASSERT(!m_bytesAllocated);
|
| }
|
|
|
| +void Canvas2DLayerBridge::setFilterLevel(SkPaint::FilterLevel filterLevel)
|
| +{
|
| + ASSERT(!m_destructionInProgress);
|
| + if (m_filterLevel != filterLevel) {
|
| + m_filterLevel = filterLevel;
|
| + m_layer->setNearestNeighbor(m_filterLevel == SkPaint::kNone_FilterLevel);
|
| + m_imageBuffer->notifySurfaceInvalid();
|
| + }
|
| +}
|
| +
|
| void Canvas2DLayerBridge::setIsHidden(bool hidden)
|
| {
|
| ASSERT(!m_destructionInProgress);
|
| @@ -414,7 +427,8 @@ bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox,
|
| RefPtr<SkImage> image = adoptRef(m_canvas->newImageSnapshot());
|
|
|
| // Early exit if canvas was not drawn to since last prepareMailbox
|
| - if (image->uniqueID() == m_lastImageId)
|
| + GLenum filter = m_filterLevel == SkPaint::kNone_FilterLevel ? GL_NEAREST : GL_LINEAR;
|
| + if (image->uniqueID() == m_lastImageId && filter == m_lastFilter)
|
| return false;
|
| m_lastImageId = image->uniqueID();
|
|
|
| @@ -431,6 +445,8 @@ bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox,
|
| mailboxInfo->m_parentLayerBridge = this;
|
| *outMailbox = mailboxInfo->m_mailbox;
|
|
|
| + mailboxInfo->m_mailbox.nearestNeighbor = filter == GL_NEAREST;
|
| +
|
| GrContext* grContext = m_contextProvider->grContext();
|
| if (!grContext)
|
| return true; // for testing: skip gl stuff when using a mock graphics context.
|
| @@ -443,8 +459,8 @@ bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox,
|
| mailboxInfo->m_image->getTexture()->textureParamsModified();
|
|
|
| webContext->bindTexture(GL_TEXTURE_2D, mailboxInfo->m_image->getTexture()->getTextureHandle());
|
| - webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
| - webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
| + webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
| + webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
| webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| webContext->produceTextureCHROMIUM(GL_TEXTURE_2D, mailboxInfo->m_mailbox.name);
|
|
|