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

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: rebase 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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 PaintImage(std::move(image), animation_type, completion_state), 0, 0); 592 PaintImage(std::move(image), animation_type, completion_state), 0, 0);
593 593
594 surface->SetImageBuffer(this); 594 surface->SetImageBuffer(this);
595 if (client_) 595 if (client_)
596 client_->RestoreCanvasMatrixClipStack(surface->Canvas()); 596 client_->RestoreCanvasMatrixClipStack(surface->Canvas());
597 surface_ = std::move(surface); 597 surface_ = std::move(surface);
598 598
599 UpdateGPUMemoryUsage(); 599 UpdateGPUMemoryUsage();
600 } 600 }
601 601
602 void ImageBuffer::SetNeedsCompositingUpdate() {
603 if (client_)
604 client_->SetNeedsCompositingUpdate();
605 }
606
602 bool ImageDataBuffer::EncodeImage(const String& mime_type, 607 bool ImageDataBuffer::EncodeImage(const String& mime_type,
603 const double& quality, 608 const double& quality,
604 Vector<unsigned char>* encoded_image) const { 609 Vector<unsigned char>* encoded_image) const {
605 if (mime_type == "image/jpeg") { 610 if (mime_type == "image/jpeg") {
606 if (!JPEGImageEncoder::Encode(*this, quality, encoded_image)) 611 if (!JPEGImageEncoder::Encode(*this, quality, encoded_image))
607 return false; 612 return false;
608 } else if (mime_type == "image/webp") { 613 } else if (mime_type == "image/webp") {
609 int compression_quality = WEBPImageEncoder::kDefaultCompressionQuality; 614 int compression_quality = WEBPImageEncoder::kDefaultCompressionQuality;
610 if (quality >= 0.0 && quality <= 1.0) 615 if (quality >= 0.0 && quality <= 1.0)
611 compression_quality = static_cast<int>(quality * 100 + 0.5); 616 compression_quality = static_cast<int>(quality * 100 + 0.5);
(...skipping 13 matching lines...) Expand all
625 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type)); 630 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type));
626 631
627 Vector<unsigned char> result; 632 Vector<unsigned char> result;
628 if (!EncodeImage(mime_type, quality, &result)) 633 if (!EncodeImage(mime_type, quality, &result))
629 return "data:,"; 634 return "data:,";
630 635
631 return "data:" + mime_type + ";base64," + Base64Encode(result); 636 return "data:" + mime_type + ";base64," + Base64Encode(result);
632 } 637 }
633 638
634 } // namespace blink 639 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698