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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 Canvas2DLayerBridge::Canvas2DLayerBridge( | 124 Canvas2DLayerBridge::Canvas2DLayerBridge( |
125 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, | 125 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, |
126 const IntSize& size, | 126 const IntSize& size, |
127 int msaaSampleCount, | 127 int msaaSampleCount, |
128 OpacityMode opacityMode, | 128 OpacityMode opacityMode, |
129 AccelerationMode accelerationMode, | 129 AccelerationMode accelerationMode, |
130 sk_sp<SkColorSpace> colorSpace, | 130 sk_sp<SkColorSpace> colorSpace, |
131 SkColorType colorType) | 131 SkColorType colorType) |
132 : m_contextProvider(std::move(contextProvider)), | 132 : m_contextProvider(std::move(contextProvider)), |
133 m_logger(wrapUnique(new Logger)), | 133 m_logger(WTF::wrapUnique(new Logger)), |
134 m_weakPtrFactory(this), | 134 m_weakPtrFactory(this), |
135 m_imageBuffer(0), | 135 m_imageBuffer(0), |
136 m_msaaSampleCount(msaaSampleCount), | 136 m_msaaSampleCount(msaaSampleCount), |
137 m_bytesAllocated(0), | 137 m_bytesAllocated(0), |
138 m_haveRecordedDrawCommands(false), | 138 m_haveRecordedDrawCommands(false), |
139 m_destructionInProgress(false), | 139 m_destructionInProgress(false), |
140 m_filterQuality(kLow_SkFilterQuality), | 140 m_filterQuality(kLow_SkFilterQuality), |
141 m_isHidden(false), | 141 m_isHidden(false), |
142 m_isDeferralEnabled(true), | 142 m_isDeferralEnabled(true), |
143 m_isRegisteredTaskObserver(false), | 143 m_isRegisteredTaskObserver(false), |
(...skipping 19 matching lines...) Expand all Loading... |
163 #if USE_IOSURFACE_FOR_2D_CANVAS | 163 #if USE_IOSURFACE_FOR_2D_CANVAS |
164 clearCHROMIUMImageCache(); | 164 clearCHROMIUMImageCache(); |
165 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 165 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
166 | 166 |
167 m_layer.reset(); | 167 m_layer.reset(); |
168 DCHECK_EQ(0u, m_mailboxes.size()); | 168 DCHECK_EQ(0u, m_mailboxes.size()); |
169 } | 169 } |
170 | 170 |
171 void Canvas2DLayerBridge::startRecording() { | 171 void Canvas2DLayerBridge::startRecording() { |
172 DCHECK(m_isDeferralEnabled); | 172 DCHECK(m_isDeferralEnabled); |
173 m_recorder = wrapUnique(new SkPictureRecorder); | 173 m_recorder = WTF::wrapUnique(new SkPictureRecorder); |
174 SkCanvas* canvas = | 174 SkCanvas* canvas = |
175 m_recorder->beginRecording(m_size.width(), m_size.height(), nullptr); | 175 m_recorder->beginRecording(m_size.width(), m_size.height(), nullptr); |
176 // Always save an initial frame, to support resetting the top level matrix | 176 // Always save an initial frame, to support resetting the top level matrix |
177 // and clip. | 177 // and clip. |
178 canvas->save(); | 178 canvas->save(); |
179 | 179 |
180 if (m_imageBuffer) { | 180 if (m_imageBuffer) { |
181 m_imageBuffer->resetCanvas(canvas); | 181 m_imageBuffer->resetCanvas(canvas); |
182 } | 182 } |
183 m_recordingPixelCount = 0; | 183 m_recordingPixelCount = 0; |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 } | 840 } |
841 | 841 |
842 bool Canvas2DLayerBridge::restoreSurface() { | 842 bool Canvas2DLayerBridge::restoreSurface() { |
843 DCHECK(!m_destructionInProgress); | 843 DCHECK(!m_destructionInProgress); |
844 if (m_destructionInProgress) | 844 if (m_destructionInProgress) |
845 return false; | 845 return false; |
846 DCHECK(isAccelerated() && !m_surface); | 846 DCHECK(isAccelerated() && !m_surface); |
847 | 847 |
848 gpu::gles2::GLES2Interface* sharedGL = nullptr; | 848 gpu::gles2::GLES2Interface* sharedGL = nullptr; |
849 m_layer->clearTexture(); | 849 m_layer->clearTexture(); |
850 m_contextProvider = wrapUnique( | 850 m_contextProvider = WTF::wrapUnique( |
851 Platform::current()->createSharedOffscreenGraphicsContext3DProvider()); | 851 Platform::current()->createSharedOffscreenGraphicsContext3DProvider()); |
852 if (m_contextProvider) | 852 if (m_contextProvider) |
853 sharedGL = m_contextProvider->contextGL(); | 853 sharedGL = m_contextProvider->contextGL(); |
854 | 854 |
855 if (sharedGL && sharedGL->GetGraphicsResetStatusKHR() == GL_NO_ERROR) { | 855 if (sharedGL && sharedGL->GetGraphicsResetStatusKHR() == GL_NO_ERROR) { |
856 GrContext* grCtx = m_contextProvider->grContext(); | 856 GrContext* grCtx = m_contextProvider->grContext(); |
857 bool surfaceIsAccelerated; | 857 bool surfaceIsAccelerated; |
858 sk_sp<SkSurface> surface( | 858 sk_sp<SkSurface> surface( |
859 createSkSurface(grCtx, m_size, m_msaaSampleCount, m_opacityMode, | 859 createSkSurface(grCtx, m_size, m_msaaSampleCount, m_opacityMode, |
860 m_colorSpace, m_colorType, &surfaceIsAccelerated)); | 860 m_colorSpace, m_colorType, &surfaceIsAccelerated)); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 default; | 1141 default; |
1142 | 1142 |
1143 void Canvas2DLayerBridge::Logger::reportHibernationEvent( | 1143 void Canvas2DLayerBridge::Logger::reportHibernationEvent( |
1144 HibernationEvent event) { | 1144 HibernationEvent event) { |
1145 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, | 1145 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, |
1146 ("Canvas.HibernationEvents", HibernationEventCount)); | 1146 ("Canvas.HibernationEvents", HibernationEventCount)); |
1147 hibernationHistogram.count(event); | 1147 hibernationHistogram.count(event); |
1148 } | 1148 } |
1149 | 1149 |
1150 } // namespace blink | 1150 } // namespace blink |
OLD | NEW |