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

Side by Side 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: Created 6 years, 3 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
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 , m_contextProvider(contextProvider) 79 , m_contextProvider(contextProvider)
80 , m_imageBuffer(0) 80 , m_imageBuffer(0)
81 , m_msaaSampleCount(msaaSampleCount) 81 , m_msaaSampleCount(msaaSampleCount)
82 , m_bytesAllocated(0) 82 , m_bytesAllocated(0)
83 , m_didRecordDrawCommand(false) 83 , m_didRecordDrawCommand(false)
84 , m_isSurfaceValid(true) 84 , m_isSurfaceValid(true)
85 , m_framesPending(0) 85 , m_framesPending(0)
86 , m_framesSinceMailboxRelease(0) 86 , m_framesSinceMailboxRelease(0)
87 , m_destructionInProgress(false) 87 , m_destructionInProgress(false)
88 , m_rateLimitingEnabled(false) 88 , m_rateLimitingEnabled(false)
89 , m_nearestNeighbor(false)
89 , m_isHidden(false) 90 , m_isHidden(false)
90 , m_next(0) 91 , m_next(0)
91 , m_prev(0) 92 , m_prev(0)
92 , m_lastImageId(0) 93 , m_lastImageId(0)
93 , m_releasedMailboxInfoIndex(InvalidMailboxIndex) 94 , m_releasedMailboxInfoIndex(InvalidMailboxIndex)
94 { 95 {
95 ASSERT(m_canvas); 96 ASSERT(m_canvas);
96 ASSERT(m_surface); 97 ASSERT(m_surface);
97 ASSERT(m_contextProvider); 98 ASSERT(m_contextProvider);
98 // Used by browser tests to detect the use of a Canvas2DLayerBridge. 99 // Used by browser tests to detect the use of a Canvas2DLayerBridge.
99 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation"); 100 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation");
100 m_layer = adoptPtr(Platform::current()->compositorSupport()->createExternalT extureLayer(this)); 101 m_layer = adoptPtr(Platform::current()->compositorSupport()->createExternalT extureLayer(this));
101 m_layer->setOpaque(opacityMode == Opaque); 102 m_layer->setOpaque(opacityMode == Opaque);
102 m_layer->setBlendBackgroundColor(opacityMode != Opaque); 103 m_layer->setBlendBackgroundColor(opacityMode != Opaque);
103 GraphicsLayer::registerContentsLayer(m_layer->layer()); 104 GraphicsLayer::registerContentsLayer(m_layer->layer());
104 m_layer->setRateLimitContext(m_rateLimitingEnabled); 105 m_layer->setRateLimitContext(m_rateLimitingEnabled);
106 m_layer->setNearestNeighbor(m_nearestNeighbor);
105 m_canvas->setNotificationClient(this); 107 m_canvas->setNotificationClient(this);
106 #ifndef NDEBUG 108 #ifndef NDEBUG
107 canvas2DLayerBridgeInstanceCounter.increment(); 109 canvas2DLayerBridgeInstanceCounter.increment();
108 #endif 110 #endif
109 } 111 }
110 112
111 Canvas2DLayerBridge::~Canvas2DLayerBridge() 113 Canvas2DLayerBridge::~Canvas2DLayerBridge()
112 { 114 {
113 ASSERT(m_destructionInProgress); 115 ASSERT(m_destructionInProgress);
114 ASSERT(!Canvas2DLayerManager::get().isInList(this)); 116 ASSERT(!Canvas2DLayerManager::get().isInList(this));
(...skipping 28 matching lines...) Expand all
143 m_layer->clearTexture(); 145 m_layer->clearTexture();
144 // Orphaning the layer is required to trigger the recration of a new layer 146 // Orphaning the layer is required to trigger the recration of a new layer
145 // in the case where destruction is caused by a canvas resize. Test: 147 // in the case where destruction is caused by a canvas resize. Test:
146 // virtual/gpu/fast/canvas/canvas-resize-after-paint-without-layout.html 148 // virtual/gpu/fast/canvas/canvas-resize-after-paint-without-layout.html
147 m_layer->layer()->removeFromParent(); 149 m_layer->layer()->removeFromParent();
148 // To anyone who ever hits this assert: Please update crbug.com/344666 150 // To anyone who ever hits this assert: Please update crbug.com/344666
149 // with repro steps. 151 // with repro steps.
150 ASSERT(!m_bytesAllocated); 152 ASSERT(!m_bytesAllocated);
151 } 153 }
152 154
155 void Canvas2DLayerBridge::setNearestNeighbor(bool nearestNeighbor)
156 {
157 ASSERT(!m_destructionInProgress);
158 if (m_nearestNeighbor != nearestNeighbor) {
159 m_nearestNeighbor = nearestNeighbor;
160 m_layer->setNearestNeighbor(m_nearestNeighbor);
161 }
162 }
163
153 void Canvas2DLayerBridge::setIsHidden(bool hidden) 164 void Canvas2DLayerBridge::setIsHidden(bool hidden)
154 { 165 {
155 ASSERT(!m_destructionInProgress); 166 ASSERT(!m_destructionInProgress);
156 bool newHiddenValue = hidden || m_destructionInProgress; 167 bool newHiddenValue = hidden || m_destructionInProgress;
157 if (m_isHidden == newHiddenValue) 168 if (m_isHidden == newHiddenValue)
158 return; 169 return;
159 170
160 m_isHidden = newHiddenValue; 171 m_isHidden = newHiddenValue;
161 if (isHidden()) { 172 if (isHidden()) {
162 freeTransientResources(); 173 freeTransientResources();
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 // This copy constructor should only be used for Vector reallocation 598 // This copy constructor should only be used for Vector reallocation
588 // Assuming 'other' is to be destroyed, we transfer m_image and 599 // Assuming 'other' is to be destroyed, we transfer m_image and
589 // m_parentLayerBridge ownership rather than do a refcount dance. 600 // m_parentLayerBridge ownership rather than do a refcount dance.
590 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); 601 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox));
591 m_image = const_cast<MailboxInfo*>(&other)->m_image.release(); 602 m_image = const_cast<MailboxInfo*>(&other)->m_image.release();
592 m_parentLayerBridge = const_cast<MailboxInfo*>(&other)->m_parentLayerBridge. release(); 603 m_parentLayerBridge = const_cast<MailboxInfo*>(&other)->m_parentLayerBridge. release();
593 m_status = other.m_status; 604 m_status = other.m_status;
594 } 605 }
595 606
596 } // namespace blink 607 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698