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

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

Issue 2808493002: [blink] Request compositing update when canvas hibernates/wakes up. (Closed)
Patch Set: trigger compositing update from Canvas2DLayerBridge instead Created 3 years, 8 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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 surface->Canvas()->drawImage(std::move(image), 0, 0); 590 surface->Canvas()->drawImage(std::move(image), 0, 0);
591 591
592 surface->SetImageBuffer(this); 592 surface->SetImageBuffer(this);
593 if (client_) 593 if (client_)
594 client_->RestoreCanvasMatrixClipStack(surface->Canvas()); 594 client_->RestoreCanvasMatrixClipStack(surface->Canvas());
595 surface_ = std::move(surface); 595 surface_ = std::move(surface);
596 596
597 UpdateGPUMemoryUsage(); 597 UpdateGPUMemoryUsage();
598 } 598 }
599 599
600 void ImageBuffer::SetNeedsCompositingUpdate() {
601 if (client_)
602 client_->SetNeedsCompositingUpdate();
603 }
604
600 bool ImageDataBuffer::EncodeImage(const String& mime_type, 605 bool ImageDataBuffer::EncodeImage(const String& mime_type,
601 const double& quality, 606 const double& quality,
602 Vector<unsigned char>* encoded_image) const { 607 Vector<unsigned char>* encoded_image) const {
603 if (mime_type == "image/jpeg") { 608 if (mime_type == "image/jpeg") {
604 if (!JPEGImageEncoder::Encode(*this, quality, encoded_image)) 609 if (!JPEGImageEncoder::Encode(*this, quality, encoded_image))
605 return false; 610 return false;
606 } else if (mime_type == "image/webp") { 611 } else if (mime_type == "image/webp") {
607 int compression_quality = WEBPImageEncoder::kDefaultCompressionQuality; 612 int compression_quality = WEBPImageEncoder::kDefaultCompressionQuality;
608 if (quality >= 0.0 && quality <= 1.0) 613 if (quality >= 0.0 && quality <= 1.0)
609 compression_quality = static_cast<int>(quality * 100 + 0.5); 614 compression_quality = static_cast<int>(quality * 100 + 0.5);
(...skipping 13 matching lines...) Expand all
623 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type)); 628 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type));
624 629
625 Vector<unsigned char> result; 630 Vector<unsigned char> result;
626 if (!EncodeImage(mime_type, quality, &result)) 631 if (!EncodeImage(mime_type, quality, &result))
627 return "data:,"; 632 return "data:,";
628 633
629 return "data:" + mime_type + ";base64," + Base64Encode(result); 634 return "data:" + mime_type + ";base64," + Base64Encode(result);
630 } 635 }
631 636
632 } // namespace blink 637 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698