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

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

Issue 358893002: Use newImageSnapshot() to get an image from a Canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Again in StaticBitmapPattern Created 6 years, 2 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 { 131 {
132 return m_surface->isValid() || m_surface->restore(); 132 return m_surface->isValid() || m_surface->restore();
133 } 133 }
134 134
135 void ImageBuffer::notifySurfaceInvalid() 135 void ImageBuffer::notifySurfaceInvalid()
136 { 136 {
137 if (m_client) 137 if (m_client)
138 m_client->notifySurfaceInvalid(); 138 m_client->notifySurfaceInvalid();
139 } 139 }
140 140
141 PassRefPtr<SkImage> ImageBuffer::newImageSnapshot() const
142 {
143 return m_surface->newImageSnapshot();
144 }
145
141 static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap) 146 static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap)
142 { 147 {
143 SkBitmap tmp; 148 SkBitmap tmp;
144 if (!bitmap.deepCopyTo(&tmp)) 149 if (!bitmap.deepCopyTo(&tmp))
145 bitmap.copyTo(&tmp, bitmap.colorType()); 150 bitmap.copyTo(&tmp, bitmap.colorType());
146 151
147 return tmp; 152 return tmp;
148 } 153 }
149 154
150 PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBeh avior) const 155 PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBeh avior) const
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 440 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
436 441
437 Vector<char> encodedImage; 442 Vector<char> encodedImage;
438 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) 443 if (!encodeImage(imageData, mimeType, quality, &encodedImage))
439 return "data:,"; 444 return "data:,";
440 445
441 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); 446 return "data:" + mimeType + ";base64," + base64Encode(encodedImage);
442 } 447 }
443 448
444 } // namespace blink 449 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698