#ifndef UI_GFX_IMAGE_IMAGE_INTERNAL_H_
#define UI_GFX_IMAGE_IMAGE_INTERNAL_H_
#include <map>
#include <memory>
#include "base/memory/ref_counted.h"
#include "build/build_config.h"
#include "ui/gfx/image/image.h"
#if BUILDFLAG(IS_MAC)
#include <CoreGraphics/CoreGraphics.h>
#endif
namespace gfx::internal {
class ImageRepPNG;
class ImageRepSkia;
class ImageRepCocoa;
class ImageRepCocoaTouch;
class ImageRep {
public:
ImageRep(const ImageRep&) = delete;
ImageRep& operator=(const ImageRep&) = delete;
virtual ~ImageRep();
const ImageRepPNG* AsImageRepPNG() const;
ImageRepPNG* AsImageRepPNG();
const ImageRepSkia* AsImageRepSkia() const;
ImageRepSkia* AsImageRepSkia();
#if BUILDFLAG(IS_IOS)
const ImageRepCocoaTouch* AsImageRepCocoaTouch() const;
ImageRepCocoaTouch* AsImageRepCocoaTouch();
#elif BUILDFLAG(IS_MAC)
const ImageRepCocoa* AsImageRepCocoa() const;
ImageRepCocoa* AsImageRepCocoa();
#endif
Image::RepresentationType type() const { return type_; }
virtual int Width() const = 0;
virtual int Height() const = 0;
virtual gfx::Size Size() const = 0;
protected:
explicit ImageRep(Image::RepresentationType rep);
private:
Image::RepresentationType type_;
};
class ImageStorage : public base::RefCounted<ImageStorage> {
public:
explicit ImageStorage(Image::RepresentationType default_type);
ImageStorage(const ImageStorage&) = delete;
ImageStorage& operator=(const ImageStorage&) = delete;
Image::RepresentationType default_representation_type() const;
bool HasRepresentation(Image::RepresentationType type) const;
size_t RepresentationCount() const;
const ImageRep* GetRepresentation(Image::RepresentationType rep_type,
bool must_exist) const;
const ImageRep* AddRepresentation(std::unique_ptr<ImageRep> rep) const;
#if BUILDFLAG(IS_MAC)
void set_default_representation_color_space(CGColorSpaceRef color_space) {}
#endif
private:
friend class base::RefCounted<ImageStorage>;
~ImageStorage();
Image::RepresentationType default_representation_type_;
mutable std::map<Image::RepresentationType,
std::unique_ptr<internal::ImageRep>>
representations_;
};
}
#endif