Index: Source/platform/graphics/Canvas2DLayerBridge.cpp |
diff --git a/Source/platform/graphics/Canvas2DLayerBridge.cpp b/Source/platform/graphics/Canvas2DLayerBridge.cpp |
index f504a01c90a916e6e191b530ea566df3ef3a893b..76242e6c9b05aa5bf2d2f63e6495e90b63706a33 100644 |
--- a/Source/platform/graphics/Canvas2DLayerBridge.cpp |
+++ b/Source/platform/graphics/Canvas2DLayerBridge.cpp |
@@ -91,10 +91,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) |
, m_opacityMode(opacityMode) |
{ |
@@ -108,6 +110,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(); |
@@ -156,6 +159,15 @@ 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); |
+ } |
+} |
+ |
void Canvas2DLayerBridge::setIsHidden(bool hidden) |
{ |
ASSERT(!m_destructionInProgress); |
@@ -418,9 +430,11 @@ 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(); |
+ m_lastFilter = filter; |
MailboxInfo* mailboxInfo = createMailboxInfo(); |
mailboxInfo->m_status = MailboxInUse; |
@@ -435,6 +449,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. |
@@ -447,8 +463,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); |