Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: src/core/SkSpecialImage.cpp

Issue 2349373004: Create special surfaces according to original device (not always in N32) (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkSpecialImage.cpp
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 240d46921947e450a8f6592ac75c060e6fffb340..a547024e23cb8509b74cc5895f235739606413e8 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -52,7 +52,7 @@ public:
virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0;
- virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const = 0;
+ virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkIRect& size, SkAlphaType at) const = 0;
virtual sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const = 0;
@@ -151,8 +151,8 @@ sk_sp<GrTexture> SkSpecialImage::asTextureRef(GrContext* context) const {
}
#endif
-sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(const SkImageInfo& info) const {
- return as_SIB(this)->onMakeSurface(info);
+sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(const SkIRect& size, SkAlphaType at) const {
+ return as_SIB(this)->onMakeSurface(size, at);
}
sk_sp<SkSurface> SkSpecialImage::makeTightSurface(const SkImageInfo& info) const {
@@ -252,7 +252,12 @@ public:
}
#endif
- sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const override {
+ sk_sp<SkSpecialSurface> onMakeSurface(const SkIRect& size, SkAlphaType at) const override {
+ SkColorSpace* colorSpace = fBitmap.colorSpace();
+ SkColorType colorType = colorSpace && colorSpace->gammaIsLinear()
+ ? kRGBA_F16_SkColorType : kN32_SkColorType;
+ SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at,
+ sk_ref_sp(colorSpace));
return SkSpecialSurface::MakeRaster(info, nullptr);
}
@@ -382,16 +387,14 @@ public:
return fColorSpace.get();
}
- sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const override {
+ sk_sp<SkSpecialSurface> onMakeSurface(const SkIRect& size, SkAlphaType at) const override {
if (!fTexture->getContext()) {
return nullptr;
}
- GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *fTexture->getContext()->caps());
-
- return SkSpecialSurface::MakeRenderTarget(fTexture->getContext(),
- info.width(), info.height(),
- config, sk_ref_sp(info.colorSpace()));
+ return SkSpecialSurface::MakeRenderTarget(
+ fTexture->getContext(), size.width(), size.height(),
+ GrRenderableConfigForColorSpace(fColorSpace.get()), fColorSpace);
}
sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {

Powered by Google App Engine
This is Rietveld 408576698