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

Unified Diff: Source/platform/graphics/Canvas2DLayerBridge.cpp

Issue 562583002: Implement image-rendering:pixelated for accelerated 2D canvases. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Don't call setImageInterpolationQuality Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/graphics/Canvas2DLayerBridge.h ('k') | Source/platform/graphics/ImageBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/Canvas2DLayerBridge.cpp
diff --git a/Source/platform/graphics/Canvas2DLayerBridge.cpp b/Source/platform/graphics/Canvas2DLayerBridge.cpp
index 8e0eb848235ff05e125bc2e39c2993d259ed7ed1..c350a1156e7005e5aa59052be15394b8d59de70a 100644
--- a/Source/platform/graphics/Canvas2DLayerBridge.cpp
+++ b/Source/platform/graphics/Canvas2DLayerBridge.cpp
@@ -91,10 +91,12 @@ Canvas2DLayerBridge::Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider
, m_framesPending(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_opacityMode(opacityMode)
{
ASSERT(m_canvas);
@@ -107,6 +109,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();
@@ -147,6 +150,13 @@ void Canvas2DLayerBridge::beginDestruction()
ASSERT(!m_bytesAllocated);
}
+void Canvas2DLayerBridge::setFilterLevel(SkPaint::FilterLevel filterLevel)
+{
+ ASSERT(!m_destructionInProgress);
+ m_filterLevel = filterLevel;
+ m_layer->setNearestNeighbor(m_filterLevel == SkPaint::kNone_FilterLevel);
+}
+
void Canvas2DLayerBridge::setIsHidden(bool hidden)
{
ASSERT(!m_destructionInProgress);
@@ -361,9 +371,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 tmp;
@@ -373,6 +385,8 @@ bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox,
}
MailboxInfo& mailboxInfo = m_mailboxes.first();
+ 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.
@@ -385,8 +399,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);
« no previous file with comments | « Source/platform/graphics/Canvas2DLayerBridge.h ('k') | Source/platform/graphics/ImageBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698