#ifndef CC_SLIM_UI_RESOURCE_LAYER_H_
#define CC_SLIM_UI_RESOURCE_LAYER_H_
#include "base/component_export.h"
#include "base/gtest_prod_util.h"
#include "cc/resources/ui_resource_client.h"
#include "cc/slim/layer.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/geometry/point_f.h"
namespace cc::slim {
class COMPONENT_EXPORT(CC_SLIM) UIResourceLayer : public Layer {
public:
static scoped_refptr<UIResourceLayer> Create();
void SetUIResourceId(cc::UIResourceId id);
void SetBitmap(const SkBitmap& bitmap);
void SetUV(const gfx::PointF& top_left, const gfx::PointF& bottom_right);
void SetLayerTree(LayerTree* tree) override;
protected:
FRIEND_TEST_ALL_PREFIXES(SlimLayerTest, UIResourceLayerProperties);
UIResourceLayer();
~UIResourceLayer() override;
cc::UIResourceId resource_id() const { return resource_id_; }
auto uv_top_left() const { return uv_top_left_; }
auto uv_bottom_right() const { return uv_bottom_right_; }
bool HasDrawableContent() const override;
void AppendQuads(viz::CompositorRenderPass& render_pass,
FrameData& data,
const gfx::Transform& transform_to_root,
const gfx::Transform& transform_to_target,
const gfx::Rect* clip_in_target,
const gfx::Rect& visible_rect,
float opacity) override;
private:
void RefreshResource();
void SetUIResourceIdInternal(cc::UIResourceId resource_id);
cc::UIResourceId resource_id_ = 0;
SkBitmap bitmap_;
gfx::PointF uv_top_left_;
gfx::PointF uv_bottom_right_{1.0f, 1.0f};
};
}
#endif