decode_stashing_image_provider.cc 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "cc/paint/decode_stashing_image_provider.h"
  5. namespace cc {
  6. DecodeStashingImageProvider::DecodeStashingImageProvider(
  7. ImageProvider* source_provider)
  8. : source_provider_(source_provider) {
  9. DCHECK(source_provider_);
  10. }
  11. DecodeStashingImageProvider::~DecodeStashingImageProvider() = default;
  12. ImageProvider::ScopedResult DecodeStashingImageProvider::GetRasterContent(
  13. const DrawImage& draw_image) {
  14. // TODO(xidachen): Ensure this function works with paint worklet generated
  15. // images.
  16. auto decode = source_provider_->GetRasterContent(draw_image);
  17. if (!decode.needs_unlock())
  18. return decode;
  19. // No need to add any destruction callback to the returned image. The images
  20. // decoded here match the lifetime of this provider.
  21. auto result = ScopedResult(decode.decoded_image());
  22. decoded_images_->push_back(std::move(decode));
  23. return result;
  24. }
  25. void DecodeStashingImageProvider::Reset() {
  26. decoded_images_->clear();
  27. }
  28. } // namespace cc