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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Self-review. Created 4 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) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved.
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 if (m_client) 176 if (m_client)
177 m_client->notifySurfaceInvalid(); 177 m_client->notifySurfaceInvalid();
178 } 178 }
179 179
180 void ImageBuffer::resetCanvas(SkCanvas* canvas) const 180 void ImageBuffer::resetCanvas(SkCanvas* canvas) const
181 { 181 {
182 if (m_client) 182 if (m_client)
183 m_client->restoreCanvasMatrixClipStack(canvas); 183 m_client->restoreCanvasMatrixClipStack(canvas);
184 } 184 }
185 185
186 PassRefPtr<SkImage> ImageBuffer::newSkImageSnapshot(AccelerationHint hint, Snaps hotReason reason) const 186 sk_sp<SkImage> ImageBuffer::newSkImageSnapshot(AccelerationHint hint, SnapshotRe ason reason) const
187 { 187 {
188 if (m_snapshotState == InitialSnapshotState) 188 if (m_snapshotState == InitialSnapshotState)
189 m_snapshotState = DidAcquireSnapshot; 189 m_snapshotState = DidAcquireSnapshot;
190 190
191 if (!isSurfaceValid()) 191 if (!isSurfaceValid())
192 return nullptr; 192 return nullptr;
193 return m_surface->newImageSnapshot(hint, reason); 193 return m_surface->newImageSnapshot(hint, reason);
194 } 194 }
195 195
196 PassRefPtr<Image> ImageBuffer::newImageSnapshot(AccelerationHint hint, SnapshotR eason reason) const 196 PassRefPtr<Image> ImageBuffer::newImageSnapshot(AccelerationHint hint, SnapshotR eason reason) const
197 { 197 {
198 RefPtr<SkImage> snapshot = newSkImageSnapshot(hint, reason); 198 sk_sp<SkImage> snapshot = newSkImageSnapshot(hint, reason);
199 if (!snapshot) 199 if (!snapshot)
200 return nullptr; 200 return nullptr;
201 return StaticBitmapImage::create(snapshot); 201 return StaticBitmapImage::create(snapshot);
f(malita) 2016/09/01 03:55:38 std:move(snapshot)
Łukasz Anforowicz 2016/09/01 20:50:58 Done.
202 } 202 }
203 203
204 void ImageBuffer::didDraw(const FloatRect& rect) const 204 void ImageBuffer::didDraw(const FloatRect& rect) const
205 { 205 {
206 if (m_snapshotState == DidAcquireSnapshot) 206 if (m_snapshotState == DidAcquireSnapshot)
207 m_snapshotState = DrawnToAfterSnapshot; 207 m_snapshotState = DrawnToAfterSnapshot;
208 m_surface->didDraw(rect); 208 m_surface->didDraw(rect);
209 } 209 }
210 210
211 WebLayer* ImageBuffer::platformLayer() const 211 WebLayer* ImageBuffer::platformLayer() const
212 { 212 {
213 return m_surface->layer(); 213 return m_surface->layer();
214 } 214 }
215 215
216 bool ImageBuffer::copyToPlatformTexture(gpu::gles2::GLES2Interface* gl, GLuint t exture, GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlp ha, bool flipY) 216 bool ImageBuffer::copyToPlatformTexture(gpu::gles2::GLES2Interface* gl, GLuint t exture, GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlp ha, bool flipY)
217 { 217 {
218 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalForm at, destType, level)) 218 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalForm at, destType, level))
219 return false; 219 return false;
220 220
221 if (!isSurfaceValid()) 221 if (!isSurfaceValid())
222 return false; 222 return false;
223 223
224 RefPtr<const SkImage> textureImage = m_surface->newImageSnapshot(PreferAccel eration, SnapshotReasonCopyToWebGLTexture); 224 sk_sp<const SkImage> textureImage = m_surface->newImageSnapshot(PreferAccele ration, SnapshotReasonCopyToWebGLTexture);
225 if (!textureImage) 225 if (!textureImage)
226 return false; 226 return false;
227 227
228 if (!m_surface->isAccelerated()) 228 if (!m_surface->isAccelerated())
229 return false; 229 return false;
230 230
231 231
232 ASSERT(textureImage->isTextureBacked()); // isAccelerated() check above shou ld guarantee this 232 ASSERT(textureImage->isTextureBacked()); // isAccelerated() check above shou ld guarantee this
233 // Get the texture ID, flushing pending operations if needed. 233 // Get the texture ID, flushing pending operations if needed.
234 const GrGLTextureInfo* textureInfo = skia::GrBackendObjectToGrGLTextureInfo( textureImage->getTextureHandle(true)); 234 const GrGLTextureInfo* textureInfo = skia::GrBackendObjectToGrGLTextureInfo( textureImage->getTextureHandle(true));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 WTF::ArrayBufferContents result(data, allocSizeInBytes, WTF::ArrayBuffer Contents::NotShared); 336 WTF::ArrayBufferContents result(data, allocSizeInBytes, WTF::ArrayBuffer Contents::NotShared);
337 result.transfer(contents); 337 result.transfer(contents);
338 return true; 338 return true;
339 } 339 }
340 340
341 DCHECK(canvas()); 341 DCHECK(canvas());
342 342
343 if (ExpensiveCanvasHeuristicParameters::GetImageDataForcesNoAcceleration && !RuntimeEnabledFeatures::canvas2dFixedRenderingModeEnabled()) 343 if (ExpensiveCanvasHeuristicParameters::GetImageDataForcesNoAcceleration && !RuntimeEnabledFeatures::canvas2dFixedRenderingModeEnabled())
344 const_cast<ImageBuffer*>(this)->disableAcceleration(); 344 const_cast<ImageBuffer*>(this)->disableAcceleration();
345 345
346 RefPtr<SkImage> snapshot = m_surface->newImageSnapshot(PreferNoAcceleration, SnapshotReasonGetImageData); 346 sk_sp<SkImage> snapshot = m_surface->newImageSnapshot(PreferNoAcceleration, SnapshotReasonGetImageData);
347 if (!snapshot) 347 if (!snapshot)
348 return false; 348 return false;
349 349
350 const bool mayHaveStrayArea = 350 const bool mayHaveStrayArea =
351 m_surface->isAccelerated() // GPU readback may fail silently 351 m_surface->isAccelerated() // GPU readback may fail silently
352 || rect.x() < 0 352 || rect.x() < 0
353 || rect.y() < 0 353 || rect.y() < 0
354 || rect.maxX() > m_surface->size().width() 354 || rect.maxX() > m_surface->size().width()
355 || rect.maxY() > m_surface->size().height(); 355 || rect.maxY() > m_surface->size().height();
356 size_t allocSizeInBytes = rect.width() * rect.height() * 4; 356 size_t allocSizeInBytes = rect.width() * rect.height() * 4;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 478 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
479 479
480 Vector<unsigned char> result; 480 Vector<unsigned char> result;
481 if (!encodeImage(mimeType, quality, &result)) 481 if (!encodeImage(mimeType, quality, &result))
482 return "data:,"; 482 return "data:,";
483 483
484 return "data:" + mimeType + ";base64," + base64Encode(result); 484 return "data:" + mimeType + ";base64," + base64Encode(result);
485 } 485 }
486 486
487 } // namespace blink 487 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698