20 #ifndef INCLUDED_VCL_INC_SKIA_UTILS_H
21 #define INCLUDED_VCL_INC_SKIA_UTILS_H
31 #include <SkSurface.h>
32 #include <tools/sk_app/VulkanWindowContext.h>
43 SkColorType
type = kN32_SkColorType,
44 SkAlphaType alpha = kPremul_SkAlphaType);
47 SkAlphaType alpha = kPremul_SkAlphaType)
68 const SkIRect& bounds);
70 inline Size imageSize(
const sk_sp<SkImage>& image) {
return Size(image->width(), image->height()); }
75 prepareSkia(std::unique_ptr<sk_app::WindowContext> (*createVulkanWindowContext)(
bool));
101 if (matrix.getScaleX() <= 1.0 / downscaleRatioThreshold
103 return SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear);
104 return SkSamplingOptions(SkCubicResampler::Mitchell());
106 return SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kNone);
108 return SkSamplingOptions(SkFilterMode::kNearest, SkMipmapMode::kNone);
111 return SkSamplingOptions();
116 const Size& destSize)
121 if (srcSize.
Width() / destSize.
Width() >= downscaleRatioThreshold
123 return SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear);
124 return SkSamplingOptions(SkCubicResampler::Mitchell());
126 return SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kNone);
128 return SkSamplingOptions(SkFilterMode::kNearest, SkMipmapMode::kNone);
131 return SkSamplingOptions();
141 return SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear);
142 return SkSamplingOptions(SkCubicResampler::Mitchell());
144 return SkSamplingOptions();
169 template <
typename charT,
typename traits>
170 inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>&
stream,
174 return stream <<
"EMPTY";
180 template <
typename charT,
typename traits>
181 inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream,
185 return stream <<
"EMPTY";
191 template <
typename charT,
typename traits>
192 inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream,
193 const SkRegion& region)
195 if (region.isEmpty())
196 return stream <<
"EMPTY";
198 SkRegion::Iterator it(region);
199 for (
int i = 0; !it.done(); it.next(), ++
i)
200 stream <<
"[" <<
i <<
"] " << it.rect();
205 template <
typename charT,
typename traits>
206 inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream,
207 const SkMatrix& matrix)
209 return stream <<
"[" << matrix[0] <<
" " << matrix[1] <<
" " << matrix[2] <<
"]"
210 <<
"[" << matrix[3] <<
" " << matrix[4] <<
" " << matrix[5] <<
"]"
211 <<
"[" << matrix[6] <<
" " << matrix[7] <<
" " << matrix[8] <<
"]";
214 template <
typename charT,
typename traits>
215 inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream,
216 const SkImage& image)
219 return stream << static_cast<const void*>(&image) <<
" " <<
Size(image.width(), image.height())
220 <<
"/" << (SkColorTypeBytesPerPixel(image.imageInfo().colorType()) * 8)
221 << (image.isTextureBacked() ?
"G" :
"");
223 template <
typename charT,
typename traits>
224 inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream,
225 const sk_sp<SkImage>& image)
227 if (image ==
nullptr)
228 return stream <<
"(null)";
229 return stream << *image;
232 #endif // INCLUDED_VCL_INC_SKIA_UTILS_H
GrDirectContext * getSharedGrDirectContext()
VCL_DLLPUBLIC sk_sp< SkImage > makeCheckedImageSnapshot(sk_sp< SkSurface > surface)
Size imageSize(const sk_sp< SkImage > &image)
VCL_DLLPUBLIC const SkSurfaceProps * surfaceProps()
VCL_DLLPUBLIC void setPixelGeometry(SkPixelGeometry pixelGeometry)
sk_sp< SkImage > findCachedImage(const OString &key)
DeviceVendor GetVendorFromId(uint32_t id)
Returns vendor for the given vendor ID, or VendorAll if not known.
constexpr tools::Long Width() const
VCL_DLLPUBLIC bool matrixNeedsHighQuality(const SkMatrix &matrix)
VCL_DLLPUBLIC sk_sp< SkImage > createSkImage(const SkBitmap &bitmap)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
constexpr int downscaleRatioThreshold
tools::Long maxImageCacheSize()
void disableRenderMethod(RenderMethod method)
DriverBlocklist::DeviceVendor getVendor()
void prefillSurface(const sk_sp< SkSurface > &surface)
VCL_DLLPUBLIC void dump(const SkBitmap &bitmap, const char *file)
Reference< XOutputStream > stream
VCL_DLLPUBLIC uint32_t vendorId
constexpr tools::Long Height() const
VCL_DLLPUBLIC sk_sp< SkSurface > createSkSurface(int width, int height, SkColorType type=kN32_SkColorType, SkAlphaType alpha=kPremul_SkAlphaType)
void removeCachedImage(sk_sp< SkImage > image)
SkSamplingOptions makeSamplingOptions(BmpScaleFlag scaling, const SkMatrix &matrix)
void addCachedImage(const OString &key, sk_sp< SkImage > image)
VCL_DLLPUBLIC void prepareSkia(std::unique_ptr< sk_app::WindowContext >(*createVulkanWindowContext)(bool))