| OLD | NEW |
| 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 388 |
| 389 SkAlphaType alphaType = (multiplied == Premultiplied || useF16Workaround) | 389 SkAlphaType alphaType = (multiplied == Premultiplied || useF16Workaround) |
| 390 ? kPremul_SkAlphaType | 390 ? kPremul_SkAlphaType |
| 391 : kUnpremul_SkAlphaType; | 391 : kUnpremul_SkAlphaType; |
| 392 // The workaround path use a canvas draw under the hood, which can only | 392 // The workaround path use a canvas draw under the hood, which can only |
| 393 // use N32 at this time. | 393 // use N32 at this time. |
| 394 SkColorType colorType = | 394 SkColorType colorType = |
| 395 useF16Workaround ? kN32_SkColorType : kRGBA_8888_SkColorType; | 395 useF16Workaround ? kN32_SkColorType : kRGBA_8888_SkColorType; |
| 396 SkImageInfo info = | 396 SkImageInfo info = |
| 397 SkImageInfo::Make(rect.width(), rect.height(), colorType, alphaType, | 397 SkImageInfo::Make(rect.width(), rect.height(), colorType, alphaType, |
| 398 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)); | 398 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)); |
| 399 | 399 |
| 400 snapshot->readPixels(info, result.data(), 4 * rect.width(), rect.x(), | 400 snapshot->readPixels(info, result.data(), 4 * rect.width(), rect.x(), |
| 401 rect.y()); | 401 rect.y()); |
| 402 | 402 |
| 403 if (useF16Workaround) { | 403 if (useF16Workaround) { |
| 404 uint32_t* pixel = (uint32_t*)result.data(); | 404 uint32_t* pixel = (uint32_t*)result.data(); |
| 405 size_t pixelCount = allocSizeInBytes / sizeof(uint32_t); | 405 size_t pixelCount = allocSizeInBytes / sizeof(uint32_t); |
| 406 // TODO(skbug.com/5853): make readPixels support RGBA output so that we no | 406 // TODO(skbug.com/5853): make readPixels support RGBA output so that we no |
| 407 // longer | 407 // longer |
| 408 // have to do this. | 408 // have to do this. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 ASSERT(destY < m_surface->size().height()); | 449 ASSERT(destY < m_surface->size().height()); |
| 450 ASSERT(originY >= 0); | 450 ASSERT(originY >= 0); |
| 451 ASSERT(originY < sourceRect.maxY()); | 451 ASSERT(originY < sourceRect.maxY()); |
| 452 | 452 |
| 453 const size_t srcBytesPerRow = 4 * sourceSize.width(); | 453 const size_t srcBytesPerRow = 4 * sourceSize.width(); |
| 454 const void* srcAddr = source + originY * srcBytesPerRow + originX * 4; | 454 const void* srcAddr = source + originY * srcBytesPerRow + originX * 4; |
| 455 SkAlphaType alphaType = (multiplied == Premultiplied) ? kPremul_SkAlphaType | 455 SkAlphaType alphaType = (multiplied == Premultiplied) ? kPremul_SkAlphaType |
| 456 : kUnpremul_SkAlphaType; | 456 : kUnpremul_SkAlphaType; |
| 457 SkImageInfo info = SkImageInfo::Make( | 457 SkImageInfo info = SkImageInfo::Make( |
| 458 sourceRect.width(), sourceRect.height(), kRGBA_8888_SkColorType, | 458 sourceRect.width(), sourceRect.height(), kRGBA_8888_SkColorType, |
| 459 alphaType, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)); | 459 alphaType, SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)); |
| 460 | 460 |
| 461 m_surface->writePixels(info, srcAddr, srcBytesPerRow, destX, destY); | 461 m_surface->writePixels(info, srcAddr, srcBytesPerRow, destX, destY); |
| 462 } | 462 } |
| 463 | 463 |
| 464 void ImageBuffer::updateGPUMemoryUsage() const { | 464 void ImageBuffer::updateGPUMemoryUsage() const { |
| 465 if (this->isAccelerated()) { | 465 if (this->isAccelerated()) { |
| 466 // If image buffer is accelerated, we should keep track of GPU memory usage. | 466 // If image buffer is accelerated, we should keep track of GPU memory usage. |
| 467 int gpuBufferCount = 2; | 467 int gpuBufferCount = 2; |
| 468 CheckedNumeric<intptr_t> checkedGPUUsage = 4 * gpuBufferCount; | 468 CheckedNumeric<intptr_t> checkedGPUUsage = 4 * gpuBufferCount; |
| 469 checkedGPUUsage *= this->size().width(); | 469 checkedGPUUsage *= this->size().width(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 554 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 555 | 555 |
| 556 Vector<unsigned char> result; | 556 Vector<unsigned char> result; |
| 557 if (!encodeImage(mimeType, quality, &result)) | 557 if (!encodeImage(mimeType, quality, &result)) |
| 558 return "data:,"; | 558 return "data:,"; |
| 559 | 559 |
| 560 return "data:" + mimeType + ";base64," + base64Encode(result); | 560 return "data:" + mimeType + ";base64," + base64Encode(result); |
| 561 } | 561 } |
| 562 | 562 |
| 563 } // namespace blink | 563 } // namespace blink |
| OLD | NEW |