#include "cc/tiles/software_image_decode_cache.h"
#include "cc/paint/draw_image.h"
#include "cc/paint/paint_image_builder.h"
#include "cc/test/fake_paint_image_generator.h"
#include "cc/test/skia_common.h"
#include "cc/test/test_tile_task_runner.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkAlphaType.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkColorType.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkM44.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkSize.h"
namespace cc {
namespace {
TargetColorParams DefaultTargetColorParams() { … }
sk_sp<SkColorSpace> DefaultSkColorSpace() { … }
size_t kLockedMemoryLimitBytes = …;
class TestSoftwareImageDecodeCache : public SoftwareImageDecodeCache { … };
SkM44 CreateMatrix(const SkSize& scale, bool is_decomposable) { … }
PaintImage CreatePaintImage(int width, int height) { … }
PaintImage CreatePaintImage(int width,
int height,
const TargetColorParams& target_color_params) { … }
class SoftwareImageDecodeCacheTest : public testing::Test { … };
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyNoneQuality) { … }
TEST_F(SoftwareImageDecodeCacheTest,
ImageKeyLowQualityIncreasedToMediumIfDownscale) { … }
TEST_F(SoftwareImageDecodeCacheTest,
ImageKeyMediumQualityDropsToLowIfMipLevel0) { … }
TEST_F(SoftwareImageDecodeCacheTest, LowUnscalableFormatStaysLow) { … }
TEST_F(SoftwareImageDecodeCacheTest, HighUnscalableFormatBecomesLow) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyLowQualityKeptLowIfUpscale) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyMediumQuality) { … }
TEST_F(SoftwareImageDecodeCacheTest,
ImageKeyMediumQualityDropToLowIfEnlarging) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyMediumQualityDropToLowIfIdentity) { … }
TEST_F(SoftwareImageDecodeCacheTest,
ImageKeyMediumQualityDropToLowIfNearlyIdentity) { … }
TEST_F(SoftwareImageDecodeCacheTest,
ImageKeyMediumQualityDropToLowIfNearlyIdentity2) { … }
TEST_F(SoftwareImageDecodeCacheTest,
ImageKeyMediumQualityDropToLowIfNotDecomposable) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyMediumQualityAt1_5Scale) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyMediumQualityAt1_0cale) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyLowQualityAt0_75Scale) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyMediumQualityAt0_5Scale) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyMediumQualityAt0_49Scale) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyMediumQualityAt0_1Scale) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyMediumQualityAt0_01Scale) { … }
TEST_F(SoftwareImageDecodeCacheTest,
ImageKeyFullDowscalesDropsHighQualityToMedium) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyUpscaleIsLowQuality) { … }
TEST_F(SoftwareImageDecodeCacheTest,
ImageKeyHighQualityDropToMediumIfTooLarge) { … }
TEST_F(SoftwareImageDecodeCacheTest,
ImageKeyHighQualityDropToLowIfNotDecomposable) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyHighQualityDropToLowIfIdentity) { … }
TEST_F(SoftwareImageDecodeCacheTest,
ImageKeyHighQualityDropToLowIfNearlyIdentity) { … }
TEST_F(SoftwareImageDecodeCacheTest,
ImageKeyHighQualityDropToLowIfNearlyIdentity2) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageKeyDownscaleMipLevelWithRounding) { … }
TEST_F(SoftwareImageDecodeCacheTest, OriginalDecodesAreEqual) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageRectDoesNotContainSrcRect) { … }
TEST_F(SoftwareImageDecodeCacheTest, ImageRectDoesNotContainSrcRectWithScale) { … }
TEST_F(SoftwareImageDecodeCacheTest, GetTaskForImageSameImage) { … }
TEST_F(SoftwareImageDecodeCacheTest, GetTaskForImageProcessUnrefCancel) { … }
TEST_F(SoftwareImageDecodeCacheTest, GetTaskForImageSameImageDifferentQuality) { … }
TEST_F(SoftwareImageDecodeCacheTest, GetTaskForImageSameImageDifferentSize) { … }
TEST_F(SoftwareImageDecodeCacheTest, GetTaskForImageDifferentImage) { … }
#if defined(MEMORY_SANITIZER)
#define MAYBE_GetTaskForImageDifferentColorSpace …
#else
#define MAYBE_GetTaskForImageDifferentColorSpace …
#endif
TEST_F(SoftwareImageDecodeCacheTest, MAYBE_GetTaskForImageDifferentColorSpace) { … }
TEST_F(SoftwareImageDecodeCacheTest, GetTaskForImageAlreadyDecoded) { … }
TEST_F(SoftwareImageDecodeCacheTest, GetTaskForImageAlreadyPrerolled) { … }
TEST_F(SoftwareImageDecodeCacheTest, GetTaskForImageCanceledGetsNewTask) { … }
TEST_F(SoftwareImageDecodeCacheTest,
GetTaskForImageCanceledWhileReffedGetsNewTask) { … }
TEST_F(SoftwareImageDecodeCacheTest, GetDecodedImageForDraw) { … }
TEST_F(SoftwareImageDecodeCacheTest,
GetDecodedImageForDrawWithNonContainedSrcRect) { … }
TEST_F(SoftwareImageDecodeCacheTest, GetDecodedImageForDrawAtRasterDecode) { … }
TEST_F(SoftwareImageDecodeCacheTest,
GetDecodedImageForDrawAtRasterDecodeMultipleTimes) { … }
TEST_F(SoftwareImageDecodeCacheTest, ZeroSizedImagesAreSkipped) { … }
TEST_F(SoftwareImageDecodeCacheTest, NonOverlappingSrcRectImagesAreSkipped) { … }
TEST_F(SoftwareImageDecodeCacheTest, LowQualityFilterIsHandled) { … }
TEST_F(SoftwareImageDecodeCacheTest, LowQualityScaledSubrectIsHandled) { … }
TEST_F(SoftwareImageDecodeCacheTest, NoneQualityScaledSubrectIsHandled) { … }
TEST_F(SoftwareImageDecodeCacheTest, MediumQualityAt01_5ScaleIsHandled) { … }
TEST_F(SoftwareImageDecodeCacheTest, MediumQualityAt1_0ScaleIsHandled) { … }
TEST_F(SoftwareImageDecodeCacheTest, MediumQualityAt0_75ScaleIsHandled) { … }
TEST_F(SoftwareImageDecodeCacheTest, MediumQualityAt0_5ScaleIsHandled) { … }
TEST_F(SoftwareImageDecodeCacheTest, MediumQualityAt0_49ScaleIsHandled) { … }
TEST_F(SoftwareImageDecodeCacheTest, MediumQualityAt0_1ScaleIsHandled) { … }
TEST_F(SoftwareImageDecodeCacheTest, MediumQualityAt0_01ScaleIsHandled) { … }
TEST_F(SoftwareImageDecodeCacheTest, MediumQualityAt0_001ScaleIsHandled) { … }
TEST_F(SoftwareImageDecodeCacheTest,
MediumQualityImagesAreTheSameAt0_5And0_49Scale) { … }
TEST_F(SoftwareImageDecodeCacheTest, ClearCache) { … }
TEST_F(SoftwareImageDecodeCacheTest, CacheDecodesExpectedFrames) { … }
TEST_F(SoftwareImageDecodeCacheTest, SizeSubrectingIsHandled) { … }
TEST_F(SoftwareImageDecodeCacheTest, EmptyTargetSizeDecode) { … }
TEST_F(SoftwareImageDecodeCacheTest, BitmapImageColorConverted) { … }
TEST_F(SoftwareImageDecodeCacheTest, BitmapImageNotColorConverted) { … }
TEST_F(SoftwareImageDecodeCacheTest, DISABLED_ContentIdCaching) { … }
TEST_F(SoftwareImageDecodeCacheTest, DecodeToScale) { … }
TEST_F(SoftwareImageDecodeCacheTest, DecodeToScaleSubrect) { … }
TEST_F(SoftwareImageDecodeCacheTest, DecodeToScaleNoneQuality) { … }
TEST_F(SoftwareImageDecodeCacheTest, HdrDecodeToHdr) { … }
TEST_F(SoftwareImageDecodeCacheTest, HdrDecodeToSdr) { … }
TEST_F(SoftwareImageDecodeCacheTest, ReduceCacheOnUnrefWithTasks) { … }
TEST_F(SoftwareImageDecodeCacheTest, ReduceCacheOnUnrefWithDraw) { … }
}
}