drawBitmap is deprecated
Change-Id: I94908f210fc0638ba9f4bac4e5ba2b68ac3be4d4 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/358236 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
d396cd50ff
commit
fa582c8f81
@ -249,7 +249,7 @@ DEF_SIMPLE_GM(all_variants_8888, canvas, 4 * SCALE + 30, 2 * SCALE + 10) {
|
||||
for (auto colorType : {kRGBA_8888_SkColorType, kBGRA_8888_SkColorType}) {
|
||||
SkBitmap bm;
|
||||
make_color_test_bitmap_variant(colorType, alphaType, colorSpace, &bm);
|
||||
canvas->drawBitmap(bm, 0.0f, 0.0f);
|
||||
canvas->drawImage(bm.asImage(), 0.0f, 0.0f);
|
||||
canvas->translate(SCALE + 10, 0.0f);
|
||||
}
|
||||
canvas->restore();
|
||||
|
@ -132,7 +132,7 @@ class BitmapCopyGM : public skiagm::GM {
|
||||
// Draw destination bitmap
|
||||
canvas->translate(0, vertOffset);
|
||||
x = (width - 40) / SkScalar(2);
|
||||
canvas->drawBitmap(fDst[i], x, 0, &paint);
|
||||
canvas->drawImage(fDst[i].asImage(), x, 0, SkSamplingOptions(), &paint);
|
||||
canvas->restore();
|
||||
|
||||
canvas->translate(horizOffset, 0);
|
||||
|
@ -37,22 +37,20 @@ static void make_bm(SkBitmap* bm) {
|
||||
*bm->getAddr32(1, 1) = colorsPM[3];
|
||||
}
|
||||
|
||||
static SkScalar draw_bm(SkCanvas* canvas, const SkBitmap& bm,
|
||||
SkScalar x, SkScalar y, SkPaint* paint) {
|
||||
canvas->drawBitmap(bm, x, y, paint);
|
||||
return SkIntToScalar(bm.width()) * 5/4;
|
||||
static SkScalar draw_bm(SkCanvas* canvas, sk_sp<SkImage> img, SkScalar x, SkScalar y,
|
||||
const SkSamplingOptions& sampling, SkPaint* paint) {
|
||||
canvas->drawImage(img, x, y, sampling, paint);
|
||||
return SkIntToScalar(img->width()) * 5/4;
|
||||
}
|
||||
|
||||
static SkScalar draw_set(SkCanvas* c, const SkBitmap& bm, SkScalar x,
|
||||
SkPaint* p) {
|
||||
x += draw_bm(c, bm, x, 0, p);
|
||||
p->setFilterQuality(kLow_SkFilterQuality);
|
||||
x += draw_bm(c, bm, x, 0, p);
|
||||
static SkScalar draw_set(SkCanvas* c, sk_sp<SkImage> img, SkScalar x, SkPaint* p) {
|
||||
x += draw_bm(c, img, x, 0, SkSamplingOptions(), p);
|
||||
x += draw_bm(c, img, x, 0, SkSamplingOptions(SkFilterMode::kLinear), p);
|
||||
p->setDither(true);
|
||||
return x + draw_bm(c, bm, x, 0, p);
|
||||
return x + draw_bm(c, img, x, 0, SkSamplingOptions(SkFilterMode::kLinear), p);
|
||||
}
|
||||
|
||||
static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) {
|
||||
static SkScalar draw_row(SkCanvas* canvas, sk_sp<SkImage> img) {
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
|
||||
SkPaint paint;
|
||||
@ -62,29 +60,33 @@ static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) {
|
||||
const int scale = 32;
|
||||
|
||||
SkFont font(ToolUtils::create_portable_typeface());
|
||||
const char* name = ToolUtils::colortype_name(bm.colorType());
|
||||
canvas->drawString(name, x, SkIntToScalar(bm.height())*scale*5/8,
|
||||
font, paint);
|
||||
const char* name = ToolUtils::colortype_name(img->colorType());
|
||||
canvas->drawString(name, x, SkIntToScalar(img->height())*scale*5/8, font, paint);
|
||||
canvas->translate(SkIntToScalar(48), 0);
|
||||
|
||||
canvas->scale(SkIntToScalar(scale), SkIntToScalar(scale));
|
||||
|
||||
x += draw_set(canvas, bm, 0, &paint);
|
||||
x += draw_set(canvas, img, 0, &paint);
|
||||
paint.reset();
|
||||
paint.setAlphaf(0.5f);
|
||||
draw_set(canvas, bm, x, &paint);
|
||||
draw_set(canvas, img, x, &paint);
|
||||
return x * scale / 3;
|
||||
}
|
||||
|
||||
class FilterGM : public skiagm::GM {
|
||||
void onOnceBeforeDraw() override {
|
||||
make_bm(&fBM32);
|
||||
ToolUtils::copy_to(&fBM4444, kARGB_4444_SkColorType, fBM32);
|
||||
ToolUtils::copy_to(&fBM16, kRGB_565_SkColorType, fBM32);
|
||||
SkBitmap bm32, bm4444, bm565;
|
||||
make_bm(&bm32);
|
||||
ToolUtils::copy_to(&bm4444, kARGB_4444_SkColorType, bm32);
|
||||
ToolUtils::copy_to(&bm565, kRGB_565_SkColorType, bm32);
|
||||
|
||||
fImg32 = bm32.asImage();
|
||||
fImg4444 = bm4444.asImage();
|
||||
fImg565 = bm565.asImage();
|
||||
}
|
||||
|
||||
public:
|
||||
SkBitmap fBM4444, fBM16, fBM32;
|
||||
sk_sp<SkImage> fImg32, fImg4444, fImg565;
|
||||
|
||||
FilterGM() {
|
||||
this->setBGColor(0xFFDDDDDD);
|
||||
@ -104,11 +106,11 @@ protected:
|
||||
SkScalar y = SkIntToScalar(10);
|
||||
|
||||
canvas->translate(x, y);
|
||||
y = draw_row(canvas, fBM4444);
|
||||
y = draw_row(canvas, fImg4444);
|
||||
canvas->translate(0, y);
|
||||
y = draw_row(canvas, fBM16);
|
||||
y = draw_row(canvas, fImg565);
|
||||
canvas->translate(0, y);
|
||||
draw_row(canvas, fBM32);
|
||||
draw_row(canvas, fImg32);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -152,7 +152,8 @@ protected:
|
||||
SkRect srcR = { 0.5f, 0.5f, 2.5f, 2.5f };
|
||||
SkRect dstR = { 100, 100, 300, 200 };
|
||||
|
||||
canvas->drawBitmapRect(bitmap, srcR, dstR, nullptr, SkCanvas::kStrict_SrcRectConstraint);
|
||||
canvas->drawImageRect(bitmap.asImage(), srcR, dstR, SkSamplingOptions(),
|
||||
nullptr, SkCanvas::kStrict_SrcRectConstraint);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -160,23 +161,26 @@ private:
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
static void make_big_bitmap(SkBitmap* bitmap) {
|
||||
static sk_sp<SkImage> make_big_bitmap() {
|
||||
|
||||
constexpr int gXSize = 4096;
|
||||
constexpr int gYSize = 4096;
|
||||
constexpr int gBorderWidth = 10;
|
||||
|
||||
bitmap->allocN32Pixels(gXSize, gYSize);
|
||||
SkBitmap bitmap;
|
||||
bitmap.allocN32Pixels(gXSize, gYSize);
|
||||
for (int y = 0; y < gYSize; ++y) {
|
||||
for (int x = 0; x < gXSize; ++x) {
|
||||
if (x <= gBorderWidth || x >= gXSize-gBorderWidth ||
|
||||
y <= gBorderWidth || y >= gYSize-gBorderWidth) {
|
||||
*bitmap->getAddr32(x, y) = SkPreMultiplyColor(0x88FFFFFF);
|
||||
*bitmap.getAddr32(x, y) = SkPreMultiplyColor(0x88FFFFFF);
|
||||
} else {
|
||||
*bitmap->getAddr32(x, y) = SkPreMultiplyColor(0x88FF0000);
|
||||
*bitmap.getAddr32(x, y) = SkPreMultiplyColor(0x88FF0000);
|
||||
}
|
||||
}
|
||||
}
|
||||
bitmap.setImmutable();
|
||||
return bitmap.asImage();
|
||||
}
|
||||
|
||||
// This GM attempts to reveal any issues we may have when the GPU has to
|
||||
@ -185,7 +189,7 @@ static void make_big_bitmap(SkBitmap* bitmap) {
|
||||
// tile placement.
|
||||
class DrawBitmapRect4 : public skiagm::GM {
|
||||
bool fUseIRect;
|
||||
SkBitmap fBigBitmap;
|
||||
sk_sp<SkImage> fBigImage;
|
||||
|
||||
public:
|
||||
DrawBitmapRect4(bool useIRect) : fUseIRect(useIRect) {
|
||||
@ -204,13 +208,14 @@ protected:
|
||||
}
|
||||
|
||||
void onOnceBeforeDraw() override {
|
||||
make_big_bitmap(&fBigBitmap);
|
||||
fBigImage = make_big_bitmap();
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkPaint paint;
|
||||
paint.setAlpha(128);
|
||||
paint.setBlendMode(SkBlendMode::kXor);
|
||||
SkSamplingOptions sampling;
|
||||
|
||||
SkRect srcR1 = { 0.0f, 0.0f, 4096.0f, 2040.0f };
|
||||
SkRect dstR1 = { 10.1f, 10.1f, 629.9f, 400.9f };
|
||||
@ -219,13 +224,15 @@ protected:
|
||||
SkRect dstR2 = { 10, 410, 30, 430 };
|
||||
|
||||
if (!fUseIRect) {
|
||||
canvas->drawBitmapRect(fBigBitmap, srcR1, dstR1, &paint,
|
||||
canvas->drawImageRect(fBigImage, srcR1, dstR1, sampling, &paint,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
canvas->drawBitmapRect(fBigBitmap, srcR2, dstR2, &paint,
|
||||
canvas->drawImageRect(fBigImage, srcR2, dstR2, sampling, &paint,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
} else {
|
||||
canvas->drawBitmapRect(fBigBitmap, srcR1.roundOut(), dstR1, &paint);
|
||||
canvas->drawBitmapRect(fBigBitmap, srcR2.roundOut(), dstR2, &paint);
|
||||
canvas->drawImageRect(fBigImage, SkRect::Make(srcR1.roundOut()), dstR1, sampling,
|
||||
&paint, SkCanvas::kStrict_SrcRectConstraint);
|
||||
canvas->drawImageRect(fBigImage, SkRect::Make(srcR2.roundOut()), dstR2, sampling,
|
||||
&paint, SkCanvas::kStrict_SrcRectConstraint);
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,7 +276,7 @@ protected:
|
||||
|
||||
// the drawRect shows the same problem as clipRect(r) followed by drawcolor(red)
|
||||
canvas->drawRect(r, paint);
|
||||
canvas->drawBitmapRect(fBM, r, nullptr);
|
||||
canvas->drawImageRect(fBM.asImage(), r, SkSamplingOptions());
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -8,21 +8,24 @@
|
||||
#include "gm/gm.h"
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
|
||||
static void make_bm(SkBitmap* bm) {
|
||||
bm->allocN32Pixels(60, 60);
|
||||
bm->eraseColor(0);
|
||||
static sk_sp<SkImage> make_bm() {
|
||||
SkBitmap bm;
|
||||
bm.allocN32Pixels(60, 60);
|
||||
bm.eraseColor(0);
|
||||
|
||||
SkCanvas canvas(*bm);
|
||||
SkCanvas canvas(bm);
|
||||
SkPaint paint;
|
||||
canvas.drawPath(SkPath::Polygon({{6,6}, {6,54}, {30,54}}, false), paint);
|
||||
|
||||
paint.setStyle(SkPaint::kStroke_Style);
|
||||
canvas.drawRect(SkRect::MakeLTRB(0.5f, 0.5f, 59.5f, 59.5f), paint);
|
||||
return bm.asImage();
|
||||
}
|
||||
|
||||
// This creates a close, but imperfect concatenation of
|
||||
@ -34,17 +37,16 @@ static void make_bm(SkBitmap* bm) {
|
||||
// the image correctly.
|
||||
//
|
||||
DEF_SIMPLE_GM(bitmaprecttest, canvas, 320, 240) {
|
||||
SkBitmap bm;
|
||||
make_bm(&bm);
|
||||
auto image = make_bm();
|
||||
|
||||
canvas->drawBitmap(bm, 150, 45, nullptr);
|
||||
canvas->drawImage(image, 150, 45);
|
||||
|
||||
SkScalar scale = 0.472560018f;
|
||||
canvas->save();
|
||||
canvas->scale(scale, scale);
|
||||
canvas->drawBitmapRect(bm, SkRect::MakeXYWH(100, 100, 128, 128), nullptr);
|
||||
canvas->drawImageRect(image, SkRect::MakeXYWH(100, 100, 128, 128), SkSamplingOptions());
|
||||
canvas->restore();
|
||||
|
||||
canvas->scale(-1, 1);
|
||||
canvas->drawBitmap(bm, -310, 45, nullptr);
|
||||
canvas->drawImage(image, -310, 45);
|
||||
}
|
||||
|
@ -37,13 +37,13 @@ protected:
|
||||
SkBitmap colorBmp;
|
||||
colorBmp.allocN32Pixels(20, 20, true);
|
||||
colorBmp.eraseColor(0xFFFF0000);
|
||||
canvas.drawBitmap(colorBmp, 0, 0);
|
||||
canvas.drawImage(colorBmp.asImage(), 0, 0);
|
||||
colorBmp.eraseColor(ToolUtils::color_to_565(0xFF008200));
|
||||
canvas.drawBitmap(colorBmp, 20, 0);
|
||||
canvas.drawImage(colorBmp.asImage(), 20, 0);
|
||||
colorBmp.eraseColor(ToolUtils::color_to_565(0xFFFF9000));
|
||||
canvas.drawBitmap(colorBmp, 0, 20);
|
||||
canvas.drawImage(colorBmp.asImage(), 0, 20);
|
||||
colorBmp.eraseColor(ToolUtils::color_to_565(0xFF2000FF));
|
||||
canvas.drawBitmap(colorBmp, 20, 20);
|
||||
canvas.drawImage(colorBmp.asImage(), 20, 20);
|
||||
}
|
||||
|
||||
SkString onShortName() override { return SkString("bmp_filter_quality_repeat"); }
|
||||
|
@ -33,11 +33,11 @@ class CopyTo4444GM : public skiagm::GM {
|
||||
*errorMsg = "Could not decode the file. Did you forget to set the resourcePath?";
|
||||
return DrawResult::kFail;
|
||||
}
|
||||
canvas->drawBitmap(bm, 0, 0);
|
||||
canvas->drawImage(bm.asImage(), 0, 0);
|
||||
|
||||
// This should dither or we will see artifacts in the background of the image.
|
||||
SkAssertResult(ToolUtils::copy_to(&bm4444, kARGB_4444_SkColorType, bm));
|
||||
canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0);
|
||||
canvas->drawImage(bm4444.asImage(), SkIntToScalar(bm.width()), 0);
|
||||
return DrawResult::kOk;
|
||||
}
|
||||
};
|
||||
|
@ -14,12 +14,12 @@
|
||||
|
||||
// https://bug.skia.org/4374
|
||||
DEF_SIMPLE_GM(draw_bitmap_rect_skbug4734, canvas, 64, 64) {
|
||||
SkBitmap source;
|
||||
if (GetResourceAsBitmap("images/randPixels.png", &source)) {
|
||||
SkRect rect = SkRect::Make(source.bounds());
|
||||
if (auto img = GetResourceAsImage("images/randPixels.png")) {
|
||||
SkRect rect = SkRect::Make(img->bounds());
|
||||
rect.inset(0.5, 1.5);
|
||||
SkRect dst;
|
||||
SkMatrix::Scale(8, 8).mapRect(&dst, rect);
|
||||
canvas->drawBitmapRect(source, rect, dst, nullptr);
|
||||
canvas->drawImageRect(img, rect, dst, SkSamplingOptions(), nullptr,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
}
|
||||
}
|
||||
|
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gm/gm.h"
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkSize.h"
|
||||
#include "include/core/SkString.h"
|
||||
|
||||
namespace skiagm {
|
||||
|
||||
static void create_bitmap(SkBitmap* bitmap) {
|
||||
const int W = 100;
|
||||
const int H = 100;
|
||||
bitmap->allocN32Pixels(W, H);
|
||||
|
||||
SkCanvas canvas(*bitmap);
|
||||
canvas.drawColor(SK_ColorRED);
|
||||
SkPaint paint;
|
||||
paint.setColor(SK_ColorBLUE);
|
||||
canvas.drawCircle(SkIntToScalar(W)/2, SkIntToScalar(H)/2, SkIntToScalar(W)/2, paint);
|
||||
}
|
||||
|
||||
class ExtractBitmapGM : public GM {
|
||||
public:
|
||||
ExtractBitmapGM() {}
|
||||
|
||||
protected:
|
||||
SkString onShortName() override {
|
||||
return SkString("extractbitmap");
|
||||
}
|
||||
|
||||
SkISize onISize() override {
|
||||
return SkISize::Make(600, 600);
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkBitmap bitmap;
|
||||
create_bitmap(&bitmap);
|
||||
int x = bitmap.width() / 2;
|
||||
int y = bitmap.height() / 2;
|
||||
|
||||
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
|
||||
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
|
||||
{
|
||||
// Do some subset drawing. This will test that an SkGPipe properly
|
||||
// handles the case where bitmaps share a pixelref
|
||||
// Draw the bottom right fourth of the bitmap over the top left
|
||||
SkBitmap subset;
|
||||
bitmap.extractSubset(&subset, SkIRect::MakeXYWH(x, y, x, y));
|
||||
canvas->drawBitmap(subset, 0, 0);
|
||||
// Draw the top left corner over the bottom right
|
||||
bitmap.extractSubset(&subset, SkIRect::MakeWH(x, y));
|
||||
canvas->drawBitmap(subset, SkIntToScalar(x), SkIntToScalar(y));
|
||||
// Draw a subset which has the same height and pixelref offset but a
|
||||
// different width
|
||||
bitmap.extractSubset(&subset, SkIRect::MakeWH(x, bitmap.height()));
|
||||
SkAutoCanvasRestore autoRestore(canvas, true);
|
||||
canvas->translate(0, SkIntToScalar(bitmap.height() + 20));
|
||||
canvas->drawBitmap(subset, 0, 0);
|
||||
// Now draw a subet which has the same width and pixelref offset but
|
||||
// a different height
|
||||
bitmap.extractSubset(&subset, SkIRect::MakeWH(bitmap.height(), y));
|
||||
canvas->translate(0, SkIntToScalar(bitmap.height() + 20));
|
||||
canvas->drawBitmap(subset, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
using INHERITED = GM;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEF_GM( return new ExtractBitmapGM; )
|
||||
|
||||
} // namespace skiagm
|
@ -28,22 +28,20 @@ static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
|
||||
}
|
||||
|
||||
static void draw_cell(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx,
|
||||
SkFilterQuality lvl) {
|
||||
SkPaint paint;
|
||||
paint.setFilterQuality(lvl);
|
||||
|
||||
const SkSamplingOptions& sampling) {
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
|
||||
canvas->translate(dx, 0);
|
||||
canvas->concat(mat);
|
||||
canvas->drawBitmap(bm, 0, 0, &paint);
|
||||
canvas->drawImage(bm.asImage(), 0, 0, sampling);
|
||||
}
|
||||
|
||||
static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx) {
|
||||
draw_cell(canvas, bm, mat, 0 * dx, kNone_SkFilterQuality);
|
||||
draw_cell(canvas, bm, mat, 1 * dx, kLow_SkFilterQuality);
|
||||
draw_cell(canvas, bm, mat, 2 * dx, kMedium_SkFilterQuality);
|
||||
draw_cell(canvas, bm, mat, 3 * dx, kHigh_SkFilterQuality);
|
||||
draw_cell(canvas, bm, mat, 0 * dx, SkSamplingOptions());
|
||||
draw_cell(canvas, bm, mat, 1 * dx, SkSamplingOptions(SkFilterMode::kLinear));
|
||||
draw_cell(canvas, bm, mat, 2 * dx, SkSamplingOptions(SkFilterMode::kLinear,
|
||||
SkMipmapMode::kLinear));
|
||||
draw_cell(canvas, bm, mat, 3 * dx, SkSamplingOptions({1.0f/3, 1.0f/3}));
|
||||
}
|
||||
|
||||
class FilterIndiaBoxGM : public skiagm::GM {
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkFilterQuality.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkImageFilter.h"
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
@ -21,7 +22,7 @@ static void draw(SkCanvas* canvas, const SkRect& rect, const SkBitmap& bitmap,
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(SkImageFilter::MakeMatrixFilter(matrix, filter, nullptr));
|
||||
canvas->saveLayer(&rect, &paint);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0, SkSamplingOptions(filter));
|
||||
canvas->restore();
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkColorFilter.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
@ -43,24 +44,25 @@ struct OverdrawColorFilter : public skiagm::GM {
|
||||
|
||||
SkPaint paint;
|
||||
paint.setColorFilter(SkOverdrawColorFilter::MakeWithSkColors(colors));
|
||||
SkSamplingOptions sampling;
|
||||
|
||||
SkImageInfo info = SkImageInfo::MakeA8(100, 100);
|
||||
SkBitmap bitmap;
|
||||
bitmap.allocPixels(info);
|
||||
set_bitmap(&bitmap, 0);
|
||||
canvas->drawBitmap(bitmap, 0, 0, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0, sampling, &paint);
|
||||
set_bitmap(&bitmap, 1);
|
||||
canvas->drawBitmap(bitmap, 0, 100, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 100, sampling, &paint);
|
||||
set_bitmap(&bitmap, 2);
|
||||
canvas->drawBitmap(bitmap, 0, 200, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 200, sampling, &paint);
|
||||
set_bitmap(&bitmap, 3);
|
||||
canvas->drawBitmap(bitmap, 0, 300, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 300, sampling, &paint);
|
||||
set_bitmap(&bitmap, 4);
|
||||
canvas->drawBitmap(bitmap, 100, 0, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 100, 0, sampling, &paint);
|
||||
set_bitmap(&bitmap, 5);
|
||||
canvas->drawBitmap(bitmap, 100, 100, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 100, 100, sampling, &paint);
|
||||
set_bitmap(&bitmap, 6);
|
||||
canvas->drawBitmap(bitmap, 100, 200, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 100, 200, sampling, &paint);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user