chromium/cc/paint/discardable_image_map_unittest.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "cc/paint/discardable_image_map.h"

#include <stddef.h>

#include <algorithm>
#include <limits>
#include <memory>

#include "base/check.h"
#include "base/containers/contains.h"
#include "base/memory/ref_counted.h"
#include "base/test/gtest_util.h"
#include "base/values.h"
#include "cc/base/region.h"
#include "cc/paint/paint_flags.h"
#include "cc/paint/paint_op_buffer.h"
#include "cc/paint/paint_recorder.h"
#include "cc/paint/skottie_color_map.h"
#include "cc/paint/skottie_frame_data.h"
#include "cc/paint/skottie_resource_metadata.h"
#include "cc/test/fake_content_layer_client.h"
#include "cc/test/fake_recording_source.h"
#include "cc/test/lottie_test_data.h"
#include "cc/test/paint_image_matchers.h"
#include "cc/test/skia_common.h"
#include "cc/test/test_paint_worklet_input.h"
#include "skia/buildflags.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkBlendMode.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkClipOp.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkGraphics.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkImageGenerator.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkMatrix.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"
#include "third_party/skia/include/core/SkTileMode.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/skia_conversions.h"

namespace cc {
namespace {
_;
Contains;
Eq;
Field;
FieldsAre;
FloatNear;
IsEmpty;
SizeIs;
UnorderedElementsAre;
Rects;

struct PositionScaleDrawImage {};

PaintRecord CreateRecording(const PaintImage& discardable_image,
                            const gfx::Rect& visible_rect) {}

}  // namespace

class DiscardableImageMapTest : public testing::Test {};

TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectTest) {}

TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectNonZeroLayer) {}

TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectOnePixelQuery) {}

TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMassiveImage) {}

TEST_F(DiscardableImageMapTest, PaintDestroyedWhileImageIsDrawn) {}

// Check if SkNoDrawCanvas does not crash for large layers.
TEST_F(DiscardableImageMapTest, RestoreSavedBigLayers) {}

// Test if SaveLayer and Restore work together.
// 1. Move cursor to (25, 25) draw a black rect of size 25x25.
// 2. save layer, move the cursor by (100, 100) or to point (125, 125), draw a
// red rect of size 25x25.
// 3. Restore layer, so the cursor moved back to (25, 25), move cursor by (100,
// 0) or at the point (125, 25), draw a yellow rect of size 25x25.
//  (25, 25)
//  +---+
//  |   |
//  +---+
//  (25, 125) (125, 125)
//  +---+     +---+
//  |   |     |   |
//  +---+     +---+
TEST_F(DiscardableImageMapTest, RestoreSavedTransformedLayers) {}

TEST_F(DiscardableImageMapTest, NullPaintOnSaveLayer) {}

TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMaxImage) {}

TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMaxImageMaxLayer) {}

TEST_F(DiscardableImageMapTest, GetDiscardableImagesRectInBounds) {}

TEST_F(DiscardableImageMapTest, GetDiscardableImagesInShader) {}

TEST_F(DiscardableImageMapTest, ClipsImageRects) {}

TEST_F(DiscardableImageMapTest, GathersDiscardableImagesFromNestedOps) {}

TEST_F(DiscardableImageMapTest, GathersAnimatedImages) {}

TEST_F(DiscardableImageMapTest, GathersPaintWorklets) {}

TEST_F(DiscardableImageMapTest, CapturesImagesInPaintRecordShaders) {}

TEST_F(DiscardableImageMapTest, CapturesImagesInPaintFilters) {}

TEST_F(DiscardableImageMapTest, CapturesImagesInSaveLayers) {}

TEST_F(DiscardableImageMapTest, EmbeddedShaderWithAnimatedImages) {}

TEST_F(DiscardableImageMapTest, DecodingModeHintsBasic) {}

TEST_F(DiscardableImageMapTest, DecodingModeHintsDuplicates) {}

TEST_F(DiscardableImageMapTest, TracksImageRegions) {}

TEST_F(DiscardableImageMapTest, ImagesUnderDrawScrollingContentsOp) {}

#if BUILDFLAG(SKIA_SUPPORT_SKOTTIE)
TEST_F(DiscardableImageMapTest,
       GetDiscardableImagesInRectSkottieWithoutImages) {}

TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectSkottieWithImages) {}

TEST_F(DiscardableImageMapTest,
       GetDiscardableImagesInRectSkottieWithImagesScalesProperly) {}

#endif  // BUILDFLAG(SKIA_SUPPORT_SKOTTIE)

}  // namespace cc