diff --git a/cc/tiles/gpu_image_decode_cache.cc b/cc/tiles/gpu_image_decode_cache.cc index df1d24bc64e69..d350df523d17f 100644 --- a/cc/tiles/gpu_image_decode_cache.cc +++ b/cc/tiles/gpu_image_decode_cache.cc @@ -78,6 +78,9 @@ #include "ui/gfx/geometry/skia_conversions.h" #include "ui/gl/trace_util.h" +#include "base/logging.h" +#include "base/debug/stack_trace.h" +#include "base/threading/platform_thread.h" namespace cc { namespace { @@ -1301,6 +1304,7 @@ ImageDecodeCache::TaskResult GpuImageDecodeCache::GetTaskForImageAndRefInternal( base::AutoLock locker(lock_); const InUseCacheKey cache_key = InUseCacheKeyFromDrawImage(draw_image); ImageData* image_data = GetImageDataForDrawImage(draw_image, cache_key); + scoped_refptr new_data; if (!image_data) { // We need an ImageData, create one now. Note that hardware decode @@ -1311,6 +1315,11 @@ ImageDecodeCache::TaskResult GpuImageDecodeCache::GetTaskForImageAndRefInternal( draw_image, task_type == TaskType::kInRaster /* allow_hardware_decode */); image_data = new_data.get(); + + LOG(ERROR) + << "[11000]GpuImageDecodeCache::GetTaskForImageAndRefInternal 1 in ->> image_data: " + << image_data <<" , HasAtLeastOneRef:"<HasAtLeastOneRef()<<" , "<HasOneRef()<< " tname-> " << base::PlatformThread::GetName(); + } else if (image_data->decode.decode_failure) { // We have already tried and failed to decode this image, so just return. return TaskResult(false /* need_unref */, false /* is_at_raster_decode */, @@ -2147,9 +2156,20 @@ void GpuImageDecodeCache::UnrefImageInternal(const DrawImage& draw_image, --found->second.ref_count; --found->second.image_data->upload.ref_count; OwnershipChanged(draw_image, found->second.image_data.get()); + + auto* image_data = found->second.image_data.get(); + if(found->second.ref_count==0u){ + LOG(ERROR) + << "[11000]GpuImageDecodeCache::UnrefImageInternal in ->> image_data: " + << image_data <<" , ref_count:"<second.ref_count<<" , HasAtLeastOneRef:"<HasAtLeastOneRef()<<" , "<HasOneRef()<< " tname-> " << base::PlatformThread::GetName(); + } + if (found->second.ref_count == 0u) { in_use_cache_.erase(found); } + // LOG(ERROR) + // << "[11000]GpuImageDecodeCache::UnrefImageInternal in ->> image_data: " + // << image_data <<" , HasAtLeastOneRef:"<HasAtLeastOneRef()<<" , "<HasOneRef()<< " tname-> " << base::PlatformThread::GetName(); } // Called any time an image or decode ref count changes. Takes care of any @@ -2405,6 +2425,7 @@ void GpuImageDecodeCache::DecodeImageIfNecessary( DecodedAuxImageData aux_image_data[kAuxImageCount]; { base::AutoUnlock unlock(lock_); + for (auto aux_image : kAllAuxImages) { if (aux_image == AuxImage::kGainmap) { if (!draw_image.paint_image().HasGainmap()) { @@ -2414,6 +2435,11 @@ void GpuImageDecodeCache::DecodeImageIfNecessary( const auto aux_image_index = AuxImageIndex(aux_image); const auto info = image_data->GetImageInfo(aux_image); + LOG(ERROR) + << "[111111]GpuImageDecodeCache::DecodeImageIfNecessary in ->> image_data: " + << image_data <<" , HasAtLeastOneRef:"<HasAtLeastOneRef()<<" , "<HasOneRef()<<" , GetTotalSize:"<GetTotalSize()<< " tname-> " << base::PlatformThread::GetName(); + ClearCache(); + // Allocate the backing memory for the decode. std::unique_ptr backing_memory; if (base::FeatureList::IsEnabled( @@ -2427,6 +2453,8 @@ void GpuImageDecodeCache::DecodeImageIfNecessary( base::Unretained(this))); } + + // Do the decode. if (info.yuva.has_value()) { // Decode as YUV. @@ -2464,8 +2492,18 @@ void GpuImageDecodeCache::DecodeImageIfNecessary( } } } + + if(!image_data->HasAtLeastOneRef()){ + LOG(ERROR) + << "[22222]GpuImageDecodeCache::DecodeImageIfNecessary in ->> image_data: " + << image_data <<" , HasAtLeastOneRef:"<HasAtLeastOneRef()<<" , "<HasOneRef()<< " tname-> " << base::PlatformThread::GetName(); + } } + LOG(ERROR) + << "[11000]GpuImageDecodeCache::DecodeImageIfNecessary in ->> image_data: " + << image_data <<" , HasAtLeastOneRef:"<HasAtLeastOneRef()<<" , "<HasOneRef()<< " tname-> " << base::PlatformThread::GetName(); + if (image_data->decode.HasData()) { // An at-raster task decoded this before us. Ignore our decode, but ensure // that the expected number of images are populated.