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

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

Powered by Google App Engine
This is Rietveld 408576698