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

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: Correcting bugs and use new cache mechanism from SkImage Created 6 years, 4 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 if (m_client) 123 if (m_client)
124 m_client->notifySurfaceInvalid(); 124 m_client->notifySurfaceInvalid();
125 } 125 }
126 126
127 void ImageBuffer::didPresent() 127 void ImageBuffer::didPresent()
128 { 128 {
129 if (m_client) 129 if (m_client)
130 m_client->didPresent(); 130 m_client->didPresent();
131 } 131 }
132 132
133 PassRefPtr<SkImage> ImageBuffer::newImageSnapshot() const
134 {
135 return m_surface->newImageSnapshot();
136 }
137
133 static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap) 138 static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap)
134 { 139 {
135 SkBitmap tmp; 140 SkBitmap tmp;
136 if (!bitmap.deepCopyTo(&tmp)) 141 if (!bitmap.deepCopyTo(&tmp))
137 bitmap.copyTo(&tmp, bitmap.colorType()); 142 bitmap.copyTo(&tmp, bitmap.colorType());
138 143
139 return tmp; 144 return tmp;
140 } 145 }
141 146
142 PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBeh avior) const 147 PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBeh avior) const
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) 427 if (!encodeImage(imageData, mimeType, quality, &encodedImage))
423 return "data:,"; 428 return "data:,";
424 429
425 Vector<char> base64Data; 430 Vector<char> base64Data;
426 base64Encode(encodedImage, base64Data); 431 base64Encode(encodedImage, base64Data);
427 432
428 return "data:" + mimeType + ";base64," + base64Data; 433 return "data:" + mimeType + ";base64," + base64Data;
429 } 434 }
430 435
431 } // namespace blink 436 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698