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

Unified Diff: src/core/SkCanvas.cpp

Issue 1685203002: lots of sRGB and F16 blits (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: xfermodes gm now works in srgb and f16 using saveLayer Created 4 years, 10 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/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 653f4b117f4fa45b6a475a618a1e1337b0e47c36..9cb24c13645d321904f7a8a12927a4aa2d18a15a 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1167,6 +1167,17 @@ static void draw_filter_into_device(SkBaseDevice* src, const SkImageFilter* filt
c.drawBitmap(srcBM, x, y, &p);
}
+static SkImageInfo make_layer_info(const SkImageInfo& prev, int w, int h, bool isOpaque) {
+ SkAlphaType alphaType = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
+ if (prev.bytesPerPixel() < 4) {
+ // promote to 32bits
+ return SkImageInfo::MakeN32(w, h, alphaType);
+ } else {
+ // keep the same characteristics as the prev
+ return SkImageInfo::Make(w, h, prev.colorType(), alphaType, prev.profileType());
+ }
+}
+
void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy strategy) {
const SkRect* bounds = rec.fBounds;
const SkPaint* paint = rec.fPaint;
@@ -1202,8 +1213,6 @@ void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy stra
geo = kUnknown_SkPixelGeometry;
}
}
- SkImageInfo info = SkImageInfo::MakeN32(ir.width(), ir.height(),
- isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
SkBaseDevice* device = this->getTopDevice();
if (nullptr == device) {
@@ -1211,6 +1220,8 @@ void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy stra
return;
}
+ SkImageInfo info = make_layer_info(device->imageInfo(), ir.width(), ir.height(), isOpaque);
+
bool forceSpriteOnRestore = false;
{
const bool preserveLCDText = kOpaque_SkAlphaType == info.alphaType() ||

Powered by Google App Engine
This is Rietveld 408576698