Always create a raster (cached) image

This avoids bugs in Viewer when starting in GL or Vulkan, then trying to
reuse the image that points to a (possibly deleted) context when
switching backends.

Bug: skia:
Change-Id: I4628aba5298bb733b8f4bb562cdbc872779d2829
Reviewed-on: https://skia-review.googlesource.com/90882
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Osman 2018-01-04 15:28:39 -05:00 committed by Skia Commit-Bot
parent 7edde238f7
commit 876c841f9b

View File

@ -13,11 +13,10 @@
#include "SkRandom.h"
#include "SkShader.h"
#include "SkSurface.h"
#include "sk_tool_utils.h"
static sk_sp<SkImage> makebm(SkCanvas* caller, int w, int h) {
static sk_sp<SkImage> makebm(int w, int h) {
SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
auto surface(sk_tool_utils::makeSurface(caller, info));
auto surface(SkSurface::MakeRaster(info));
SkCanvas* canvas = surface->getCanvas();
const SkScalar wScalar = SkIntToScalar(w);
@ -79,7 +78,7 @@ protected:
void onDraw(SkCanvas* canvas) override {
if (nullptr == fImage) {
fImage = makebm(canvas, gSurfaceSize, gSurfaceSize);
fImage = makebm(gSurfaceSize, gSurfaceSize);
}
const SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)};