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

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

Issue 1097773004: Sharing of SharedArrayBuffer via PostMessage transfer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: . Created 5 years, 6 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 289
290 bool ImageBuffer::getImageData(Multiply multiplied, const IntRect& rect, WTF::Ar rayBufferContents& contents) const 290 bool ImageBuffer::getImageData(Multiply multiplied, const IntRect& rect, WTF::Ar rayBufferContents& contents) const
291 { 291 {
292 Checked<int, RecordOverflow> dataSize = 4; 292 Checked<int, RecordOverflow> dataSize = 4;
293 dataSize *= rect.width(); 293 dataSize *= rect.width();
294 dataSize *= rect.height(); 294 dataSize *= rect.height();
295 if (dataSize.hasOverflowed()) 295 if (dataSize.hasOverflowed())
296 return false; 296 return false;
297 297
298 if (!isSurfaceValid()) { 298 if (!isSurfaceValid()) {
299 WTF::ArrayBufferContents result(rect.width() * rect.height(), 4, WTF::Ar rayBufferContents::ZeroInitialize); 299 WTF::ArrayBufferContents result(rect.width() * rect.height(), 4, WTF::Ar rayBufferContents::NotShared, WTF::ArrayBufferContents::ZeroInitialize);
300 result.transfer(contents); 300 result.transfer(contents);
301 return true; 301 return true;
302 } 302 }
303 303
304 const bool hasStrayArea = 304 const bool hasStrayArea =
305 rect.x() < 0 305 rect.x() < 0
306 || rect.y() < 0 306 || rect.y() < 0
307 || rect.maxX() > m_surface->size().width() 307 || rect.maxX() > m_surface->size().width()
308 || rect.maxY() > m_surface->size().height(); 308 || rect.maxY() > m_surface->size().height();
309 WTF::ArrayBufferContents result( 309 WTF::ArrayBufferContents result(
310 rect.width() * rect.height(), 4, 310 rect.width() * rect.height(), 4,
311 WTF::ArrayBufferContents::NotShared,
311 hasStrayArea 312 hasStrayArea
312 ? WTF::ArrayBufferContents::ZeroInitialize 313 ? WTF::ArrayBufferContents::ZeroInitialize
313 : WTF::ArrayBufferContents::DontInitialize); 314 : WTF::ArrayBufferContents::DontInitialize);
314 315
315 SkAlphaType alphaType = (multiplied == Premultiplied) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; 316 SkAlphaType alphaType = (multiplied == Premultiplied) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
316 SkImageInfo info = SkImageInfo::Make(rect.width(), rect.height(), kRGBA_8888 _SkColorType, alphaType); 317 SkImageInfo info = SkImageInfo::Make(rect.width(), rect.height(), kRGBA_8888 _SkColorType, alphaType);
317 318
318 m_surface->willAccessPixels(); 319 m_surface->willAccessPixels();
319 ASSERT(canvas()); 320 ASSERT(canvas());
320 canvas()->readPixels(info, result.data(), 4 * rect.width(), rect.x(), rect.y ()); 321 canvas()->readPixels(info, result.data(), 4 * rect.width(), rect.x(), rect.y ());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 397 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
397 398
398 Vector<char> encodedImage; 399 Vector<char> encodedImage;
399 if (!encodeImage(*this, mimeType, quality, &encodedImage)) 400 if (!encodeImage(*this, mimeType, quality, &encodedImage))
400 return "data:,"; 401 return "data:,";
401 402
402 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); 403 return "data:" + mimeType + ";base64," + base64Encode(encodedImage);
403 } 404 }
404 405
405 } // namespace blink 406 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698