aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/dstreadshuffle.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-03-17 10:41:39 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-17 15:26:02 +0000
commitd02b6f331bca054b0654e213ea6a7ddd94257bf7 (patch)
tree0d4b7e1330b4bdfffd14f2697ba0f828f68f3cae /gm/dstreadshuffle.cpp
parent2fb3662364829555628196d4913971f933185d81 (diff)
Make dstreadshuffle not crash in with --preAbandonGpuContext and look better in 565
BUG=skia:6386 Change-Id: I90578f57ba7076d65e6d8ebe61ec325ebba8e35d Reviewed-on: https://skia-review.googlesource.com/9828 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'gm/dstreadshuffle.cpp')
-rw-r--r--gm/dstreadshuffle.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/gm/dstreadshuffle.cpp b/gm/dstreadshuffle.cpp
index aea71ec6b1..371515334c 100644
--- a/gm/dstreadshuffle.cpp
+++ b/gm/dstreadshuffle.cpp
@@ -18,7 +18,7 @@ namespace skiagm {
*/
class DstReadShuffle : public GM {
public:
- DstReadShuffle() { this->setBGColor(SK_ColorLTGRAY); }
+ DstReadShuffle() { this->setBGColor(kBackground); }
protected:
enum ShapeType {
@@ -97,7 +97,11 @@ protected:
}
static void DrawHairlines(SkCanvas* canvas) {
- canvas->clear(SK_ColorTRANSPARENT);
+ if (canvas->imageInfo().alphaType() == kOpaque_SkAlphaType) {
+ canvas->clear(kBackground);
+ } else {
+ canvas->clear(SK_ColorTRANSPARENT);
+ }
SkPaint hairPaint;
hairPaint.setStyle(SkPaint::kStroke_Style);
hairPaint.setStrokeWidth(0);
@@ -139,16 +143,27 @@ protected:
// Draw hairlines to a surface and then draw that to the main canvas with a zoom so that
// it is easier to see how they blend.
SkImageInfo info;
- if (SkColorType::kUnknown_SkColorType != canvas->imageInfo().colorType()) {
+ // Recording canvases don't have a color type.
+ if (SkColorType::kUnknown_SkColorType == canvas->imageInfo().colorType()) {
+ info = SkImageInfo::MakeN32Premul(35, 35);
+ } else {
info = SkImageInfo::Make(35, 35,
canvas->imageInfo().colorType(),
canvas->imageInfo().alphaType(),
canvas->imageInfo().refColorSpace());
- } else {
- info = SkImageInfo::MakeN32Premul(35, 35);
}
auto surf = canvas->makeSurface(info);
if (!surf) {
+ // Fall back to raster. Raster supports only one of the 8 bit per-channel RGBA or BGRA
+ // formats. This fall back happens when running with --preAbandonGpuContext.
+ if ((info.colorType() == kRGBA_8888_SkColorType ||
+ info.colorType() == kBGRA_8888_SkColorType) &&
+ info.colorType() != kN32_SkColorType) {
+ info = SkImageInfo::Make(35, 35,
+ kN32_SkColorType,
+ canvas->imageInfo().alphaType(),
+ canvas->imageInfo().refColorSpace());
+ }
surf = SkSurface::MakeRaster(info);
}
canvas->scale(5.f, 5.f);
@@ -158,6 +173,7 @@ protected:
}
private:
+ static constexpr SkColor kBackground = SK_ColorLTGRAY;
SkPath fConcavePath;
SkPath fConvexPath;
typedef GM INHERITED;