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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 , m_surface(surface) | 84 , m_surface(surface) |
85 , m_contextProvider(contextProvider) | 85 , m_contextProvider(contextProvider) |
86 , m_imageBuffer(0) | 86 , m_imageBuffer(0) |
87 , m_msaaSampleCount(msaaSampleCount) | 87 , m_msaaSampleCount(msaaSampleCount) |
88 , m_bytesAllocated(0) | 88 , m_bytesAllocated(0) |
89 , m_didRecordDrawCommand(false) | 89 , m_didRecordDrawCommand(false) |
90 , m_isSurfaceValid(true) | 90 , m_isSurfaceValid(true) |
91 , m_framesPending(0) | 91 , m_framesPending(0) |
92 , m_destructionInProgress(false) | 92 , m_destructionInProgress(false) |
93 , m_rateLimitingEnabled(false) | 93 , m_rateLimitingEnabled(false) |
94 , m_filterLevel(SkPaint::kLow_FilterLevel) | 94 , m_filterQuality(kLow_SkFilterQuality) |
95 , m_isHidden(false) | 95 , m_isHidden(false) |
96 , m_next(0) | 96 , m_next(0) |
97 , m_prev(0) | 97 , m_prev(0) |
98 , m_lastImageId(0) | 98 , m_lastImageId(0) |
99 , m_lastFilter(GL_LINEAR) | 99 , m_lastFilter(GL_LINEAR) |
100 , m_opacityMode(opacityMode) | 100 , m_opacityMode(opacityMode) |
101 { | 101 { |
102 ASSERT(m_canvas); | 102 ASSERT(m_canvas); |
103 ASSERT(m_surface); | 103 ASSERT(m_surface); |
104 ASSERT(m_contextProvider); | 104 ASSERT(m_contextProvider); |
105 // Used by browser tests to detect the use of a Canvas2DLayerBridge. | 105 // Used by browser tests to detect the use of a Canvas2DLayerBridge. |
106 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation"); | 106 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation"); |
107 m_layer = adoptPtr(Platform::current()->compositorSupport()->createExternalT
extureLayer(this)); | 107 m_layer = adoptPtr(Platform::current()->compositorSupport()->createExternalT
extureLayer(this)); |
108 m_layer->setOpaque(opacityMode == Opaque); | 108 m_layer->setOpaque(opacityMode == Opaque); |
109 m_layer->setBlendBackgroundColor(opacityMode != Opaque); | 109 m_layer->setBlendBackgroundColor(opacityMode != Opaque); |
110 GraphicsLayer::registerContentsLayer(m_layer->layer()); | 110 GraphicsLayer::registerContentsLayer(m_layer->layer()); |
111 m_layer->setRateLimitContext(m_rateLimitingEnabled); | 111 m_layer->setRateLimitContext(m_rateLimitingEnabled); |
112 m_layer->setNearestNeighbor(m_filterLevel == SkPaint::kNone_FilterLevel); | 112 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality); |
113 m_canvas->setNotificationClient(this); | 113 m_canvas->setNotificationClient(this); |
114 #ifndef NDEBUG | 114 #ifndef NDEBUG |
115 canvas2DLayerBridgeInstanceCounter.increment(); | 115 canvas2DLayerBridgeInstanceCounter.increment(); |
116 #endif | 116 #endif |
117 } | 117 } |
118 | 118 |
119 Canvas2DLayerBridge::~Canvas2DLayerBridge() | 119 Canvas2DLayerBridge::~Canvas2DLayerBridge() |
120 { | 120 { |
121 ASSERT(m_destructionInProgress); | 121 ASSERT(m_destructionInProgress); |
122 ASSERT(!Canvas2DLayerManager::get().isInList(this)); | 122 ASSERT(!Canvas2DLayerManager::get().isInList(this)); |
(...skipping 22 matching lines...) Expand all Loading... |
145 m_layer->clearTexture(); | 145 m_layer->clearTexture(); |
146 // 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 |
147 // 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: |
148 // virtual/gpu/fast/canvas/canvas-resize-after-paint-without-layout.html | 148 // virtual/gpu/fast/canvas/canvas-resize-after-paint-without-layout.html |
149 m_layer->layer()->removeFromParent(); | 149 m_layer->layer()->removeFromParent(); |
150 // 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 |
151 // with repro steps. | 151 // with repro steps. |
152 ASSERT(!m_bytesAllocated); | 152 ASSERT(!m_bytesAllocated); |
153 } | 153 } |
154 | 154 |
155 void Canvas2DLayerBridge::setFilterLevel(SkPaint::FilterLevel filterLevel) | 155 void Canvas2DLayerBridge::setFilterQuality(SkFilterQuality filterQuality) |
156 { | 156 { |
157 ASSERT(!m_destructionInProgress); | 157 ASSERT(!m_destructionInProgress); |
158 m_filterLevel = filterLevel; | 158 m_filterQuality = filterQuality; |
159 m_layer->setNearestNeighbor(m_filterLevel == SkPaint::kNone_FilterLevel); | 159 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality); |
160 } | 160 } |
161 | 161 |
162 void Canvas2DLayerBridge::setIsHidden(bool hidden) | 162 void Canvas2DLayerBridge::setIsHidden(bool hidden) |
163 { | 163 { |
164 ASSERT(!m_destructionInProgress); | 164 ASSERT(!m_destructionInProgress); |
165 bool newHiddenValue = hidden || m_destructionInProgress; | 165 bool newHiddenValue = hidden || m_destructionInProgress; |
166 if (m_isHidden == newHiddenValue) | 166 if (m_isHidden == newHiddenValue) |
167 return; | 167 return; |
168 | 168 |
169 m_isHidden = newHiddenValue; | 169 m_isHidden = newHiddenValue; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 WebGraphicsContext3D* webContext = context(); | 368 WebGraphicsContext3D* webContext = context(); |
369 | 369 |
370 // Release to skia textures that were previouosly released by the | 370 // Release to skia textures that were previouosly released by the |
371 // compositor. We do this before acquiring the next snapshot in | 371 // compositor. We do this before acquiring the next snapshot in |
372 // order to cap maximum gpu memory consumption. | 372 // order to cap maximum gpu memory consumption. |
373 flush(); | 373 flush(); |
374 | 374 |
375 RefPtr<SkImage> image = adoptRef(m_canvas->newImageSnapshot()); | 375 RefPtr<SkImage> image = adoptRef(m_canvas->newImageSnapshot()); |
376 | 376 |
377 // Early exit if canvas was not drawn to since last prepareMailbox | 377 // Early exit if canvas was not drawn to since last prepareMailbox |
378 GLenum filter = m_filterLevel == SkPaint::kNone_FilterLevel ? GL_NEAREST : G
L_LINEAR; | 378 GLenum filter = m_filterQuality == kNone_SkFilterQuality ? GL_NEAREST : GL_L
INEAR; |
379 if (image->uniqueID() == m_lastImageId && filter == m_lastFilter) | 379 if (image->uniqueID() == m_lastImageId && filter == m_lastFilter) |
380 return false; | 380 return false; |
381 m_lastImageId = image->uniqueID(); | 381 m_lastImageId = image->uniqueID(); |
382 m_lastFilter = filter; | 382 m_lastFilter = filter; |
383 | 383 |
384 { | 384 { |
385 MailboxInfo tmp; | 385 MailboxInfo tmp; |
386 tmp.m_image = image; | 386 tmp.m_image = image; |
387 tmp.m_parentLayerBridge = this; | 387 tmp.m_parentLayerBridge = this; |
388 m_mailboxes.prepend(tmp); | 388 m_mailboxes.prepend(tmp); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 return adoptRef(m_canvas->newImageSnapshot()); | 527 return adoptRef(m_canvas->newImageSnapshot()); |
528 } | 528 } |
529 | 529 |
530 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { | 530 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { |
531 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); | 531 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); |
532 m_image = other.m_image; | 532 m_image = other.m_image; |
533 m_parentLayerBridge = other.m_parentLayerBridge; | 533 m_parentLayerBridge = other.m_parentLayerBridge; |
534 } | 534 } |
535 | 535 |
536 } // namespace blink | 536 } // namespace blink |
OLD | NEW |