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 5 #include "cc/paint/decode_stashing_image_provider.h" 6 7 namespace cc { DecodeStashingImageProvider(ImageProvider * source_provider)8DecodeStashingImageProvider::DecodeStashingImageProvider( 9 ImageProvider* source_provider) 10 : source_provider_(source_provider) { 11 DCHECK(source_provider_); 12 } 13 DecodeStashingImageProvider::~DecodeStashingImageProvider() = default; 14 GetRasterContent(const DrawImage & draw_image)15ImageProvider::ScopedResult DecodeStashingImageProvider::GetRasterContent( 16 const DrawImage& draw_image) { 17 // TODO(xidachen): Ensure this function works with paint worklet generated 18 // images. 19 auto decode = source_provider_->GetRasterContent(draw_image); 20 if (!decode.needs_unlock()) 21 return decode; 22 23 // No need to add any destruction callback to the returned image. The images 24 // decoded here match the lifetime of this provider. 25 auto result = ScopedResult(decode.decoded_image()); 26 decoded_images_->push_back(std::move(decode)); 27 return result; 28 } 29 Reset()30void DecodeStashingImageProvider::Reset() { 31 decoded_images_->clear(); 32 } 33 34 } // namespace cc 35