aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/sk_tool_utils.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2016-12-20 11:09:31 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-20 16:39:05 +0000
commit2b25d348fe41c65a7926dffcebb914732c70521b (patch)
treed638aedc5dc0a8f97960bd7d12d857e29838ac5d /tools/sk_tool_utils.cpp
parent33667da26dfa376f508ee7dec3b3dd89ef641129 (diff)
Tag string bitmaps (for GMs) as sRGB
These are often used as inputs when testing image filters, and we need tagged inputs to test the color pipeline. To avoid changing legacy mode results, rasterize the bitmaps in legacy, but tag the output. BUG=skia: Change-Id: I55e2c0e0061b3f50b1caa18c19ba4fcf92cdf902 Reviewed-on: https://skia-review.googlesource.com/6280 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools/sk_tool_utils.cpp')
-rw-r--r--tools/sk_tool_utils.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp
index fcc8d4c725..3e38cc4594 100644
--- a/tools/sk_tool_utils.cpp
+++ b/tools/sk_tool_utils.cpp
@@ -14,6 +14,7 @@
#include "SkCommonFlags.h"
#include "SkFontMgr.h"
#include "SkFontStyle.h"
+#include "SkPixelRef.h"
#include "SkPoint3.h"
#include "SkShader.h"
#include "SkTestScalerContext.h"
@@ -239,7 +240,12 @@ SkBitmap create_string_bitmap(int w, int h, SkColor c, int x, int y,
canvas.clear(0x00000000);
canvas.drawText(str, strlen(str), SkIntToScalar(x), SkIntToScalar(y), paint);
- return bitmap;
+ // Tag data as sRGB (without doing any color space conversion). Color-space aware configs
+ // will process this correctly but legacy configs will render as if this returned N32.
+ SkBitmap result;
+ result.setInfo(SkImageInfo::MakeS32(w, h, kPremul_SkAlphaType));
+ result.setPixelRef(sk_ref_sp(bitmap.pixelRef()), 0, 0);
+ return result;
}
void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPaint& origPaint,