| 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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 surface->Canvas()->drawImage(std::move(image), 0, 0); | 587 surface->Canvas()->drawImage(std::move(image), 0, 0); |
| 588 | 588 |
| 589 surface->SetImageBuffer(this); | 589 surface->SetImageBuffer(this); |
| 590 if (client_) | 590 if (client_) |
| 591 client_->RestoreCanvasMatrixClipStack(surface->Canvas()); | 591 client_->RestoreCanvasMatrixClipStack(surface->Canvas()); |
| 592 surface_ = std::move(surface); | 592 surface_ = std::move(surface); |
| 593 | 593 |
| 594 UpdateGPUMemoryUsage(); | 594 UpdateGPUMemoryUsage(); |
| 595 } | 595 } |
| 596 | 596 |
| 597 void ImageBuffer::SetNeedsCompositingUpdate() { |
| 598 if (client_) |
| 599 client_->SetNeedsCompositingUpdate(); |
| 600 } |
| 601 |
| 597 bool ImageDataBuffer::EncodeImage(const String& mime_type, | 602 bool ImageDataBuffer::EncodeImage(const String& mime_type, |
| 598 const double& quality, | 603 const double& quality, |
| 599 Vector<unsigned char>* encoded_image) const { | 604 Vector<unsigned char>* encoded_image) const { |
| 600 if (mime_type == "image/jpeg") { | 605 if (mime_type == "image/jpeg") { |
| 601 if (!JPEGImageEncoder::Encode(*this, quality, encoded_image)) | 606 if (!JPEGImageEncoder::Encode(*this, quality, encoded_image)) |
| 602 return false; | 607 return false; |
| 603 } else if (mime_type == "image/webp") { | 608 } else if (mime_type == "image/webp") { |
| 604 int compression_quality = WEBPImageEncoder::kDefaultCompressionQuality; | 609 int compression_quality = WEBPImageEncoder::kDefaultCompressionQuality; |
| 605 if (quality >= 0.0 && quality <= 1.0) | 610 if (quality >= 0.0 && quality <= 1.0) |
| 606 compression_quality = static_cast<int>(quality * 100 + 0.5); | 611 compression_quality = static_cast<int>(quality * 100 + 0.5); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 620 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type)); | 625 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type)); |
| 621 | 626 |
| 622 Vector<unsigned char> result; | 627 Vector<unsigned char> result; |
| 623 if (!EncodeImage(mime_type, quality, &result)) | 628 if (!EncodeImage(mime_type, quality, &result)) |
| 624 return "data:,"; | 629 return "data:,"; |
| 625 | 630 |
| 626 return "data:" + mime_type + ";base64," + Base64Encode(result); | 631 return "data:" + mime_type + ";base64," + Base64Encode(result); |
| 627 } | 632 } |
| 628 | 633 |
| 629 } // namespace blink | 634 } // namespace blink |
| OLD | NEW |