d0f824cfbd
Reason for revert: broke all Windows bots Original issue's description: > setConfig -> setInfo > > BUG=skia: > > Committed: http://code.google.com/p/skia/source/detail?r=14978 R=robertphillips@google.com, reed@google.com TBR=reed@google.com, robertphillips@google.com NOTREECHECKS=true NOTRY=true BUG=skia: Author: epoger@google.com Review URL: https://codereview.chromium.org/302053002 git-svn-id: http://skia.googlecode.com/svn/trunk@14979 2bbb7eff-a529-9590-31e7-b0007b416f81
58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
/*
|
|
* Copyright 2012 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "SamplePipeControllers.h"
|
|
#include "SkBitmap.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkGPipe.h"
|
|
#include "SkPaint.h"
|
|
#include "SkShader.h"
|
|
#include "Test.h"
|
|
|
|
// Ensures that the pipe gracefully handles drawing an invalid bitmap.
|
|
static void testDrawingBadBitmap(SkCanvas* pipeCanvas) {
|
|
SkBitmap badBitmap;
|
|
badBitmap.setConfig(SkImageInfo::Make(5, 5, kUnknown_SkColorType,
|
|
kPremul_SkAlphaType));
|
|
pipeCanvas->drawBitmap(badBitmap, 0, 0);
|
|
}
|
|
|
|
// Ensure that pipe gracefully handles attempting to draw after endRecording is called on the
|
|
// SkGPipeWriter.
|
|
static void testDrawingAfterEndRecording(SkCanvas* canvas) {
|
|
PipeController pc(canvas);
|
|
SkGPipeWriter writer;
|
|
SkCanvas* pipeCanvas = writer.startRecording(&pc, SkGPipeWriter::kCrossProcess_Flag);
|
|
writer.endRecording();
|
|
|
|
SkBitmap bm;
|
|
bm.allocN32Pixels(2, 2);
|
|
bm.eraseColor(SK_ColorTRANSPARENT);
|
|
|
|
SkShader* shader = SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode,
|
|
SkShader::kClamp_TileMode);
|
|
SkPaint paint;
|
|
paint.setShader(shader)->unref();
|
|
pipeCanvas->drawPaint(paint);
|
|
|
|
pipeCanvas->drawBitmap(bm, 0, 0);
|
|
}
|
|
|
|
DEF_TEST(Pipe, reporter) {
|
|
SkBitmap bitmap;
|
|
bitmap.setConfig(SkImageInfo::MakeN32Premul(64, 64));
|
|
SkCanvas canvas(bitmap);
|
|
|
|
PipeController pipeController(&canvas);
|
|
SkGPipeWriter writer;
|
|
SkCanvas* pipeCanvas = writer.startRecording(&pipeController);
|
|
testDrawingBadBitmap(pipeCanvas);
|
|
writer.endRecording();
|
|
|
|
testDrawingAfterEndRecording(&canvas);
|
|
}
|