drawBitmap is deprecated
Bug: skia:11216 Change-Id: I4affb8e00ff7e7b3e8d873ddfd653f397ca8d928 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360979 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
330cfa44ac
commit
ecdd979bc0
@ -14,6 +14,6 @@ void draw(SkCanvas* canvas) {
|
||||
bitmap.eraseColor(SK_ColorRED);
|
||||
canvas->scale(50, 50);
|
||||
canvas->rotate(8);
|
||||
canvas->drawBitmap(bitmap, 2, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 2, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -14,6 +14,6 @@ void draw(SkCanvas* canvas) {
|
||||
bitmap.eraseColor(SK_ColorRED);
|
||||
canvas->scale(50, 50);
|
||||
canvas->rotate(8);
|
||||
canvas->drawBitmap(bitmap, 2, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 2, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -17,12 +17,14 @@ void draw(SkCanvas* canvas) {
|
||||
bitmap.installPixels(imageInfo, (void*) pixels, sizeof(pixels[0]));
|
||||
SkPaint paint;
|
||||
paint.setColor(SK_ColorRED);
|
||||
canvas->drawBitmapRect(bitmap, SkRect::MakeWH(8, 8), SkRect::MakeWH(32, 32), &paint);
|
||||
canvas->drawImageRect(bitmap.asImage(), SkRect::MakeWH(8, 8), SkRect::MakeWH(32, 32),
|
||||
SkSamplingOptions(), &paint, SkCanvas::kStrict_SrcRectConstraint);
|
||||
size_t offset = imageInfo.computeOffset(2, 3, sizeof(pixels[0]));
|
||||
pixels[0][offset] = 0x7F;
|
||||
offset = imageInfo.computeOffset(5, 3, sizeof(pixels[0]));
|
||||
pixels[0][offset] = 0x7F;
|
||||
bitmap.installPixels(imageInfo, (void*) pixels, sizeof(pixels[0]));
|
||||
canvas->drawBitmapRect(bitmap, SkRect::MakeWH(8, 8), SkRect::MakeWH(128, 128), &paint);
|
||||
canvas->drawImageRect(bitmap.asImage(), SkRect::MakeWH(8, 8), SkRect::MakeWH(128, 128),
|
||||
SkSamplingOptions(), &paint, SkCanvas::kStrict_SrcRectConstraint);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -1,29 +0,0 @@
|
||||
// Copyright 2019 Google LLC.
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
#include "tools/fiddle/examples.h"
|
||||
// HASH=e72db006f1bea26feceaef8727ff9818
|
||||
REG_FIDDLE(ImageInfo_makeAlphaType, 256, 256, false, 3) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
const int width = 256;
|
||||
const int height = 128;
|
||||
SkColor pixels[height][width];
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
int red = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarSin((x * 4 + y) * 0.03f)));
|
||||
int blue = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarCos((x * 3 + y) * 0.04f)));
|
||||
int green = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarSin((x * 2 + y) * 0.05f)));
|
||||
int alpha = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarCos((x * 1 + y) * 0.006f)));
|
||||
pixels[y][x] =
|
||||
SkColorSetARGB(alpha, red * alpha / 255, green * alpha / 255, blue * alpha / 255);
|
||||
}
|
||||
}
|
||||
SkBitmap bitmap;
|
||||
SkImageInfo info = SkImageInfo::Make(width, height, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
bitmap.installPixels(info, (void*) pixels, sizeof(SkColor) * width);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
SkImageInfo unpremulInfo = info.makeAlphaType(kUnpremul_SkAlphaType);
|
||||
bitmap.installPixels(unpremulInfo, (void*) pixels, sizeof(SkColor) * width);
|
||||
canvas->drawBitmap(bitmap, 0, 128);
|
||||
}
|
||||
} // END FIDDLE
|
@ -1,29 +0,0 @@
|
||||
// Copyright 2019 Google LLC.
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
#include "tools/fiddle/examples.h"
|
||||
// HASH=3ac267b08b12dc83c95f91d8dd5d70ee
|
||||
REG_FIDDLE(ImageInfo_makeColorType, 256, 256, false, 0) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
const int width = 256;
|
||||
const int height = 128;
|
||||
SkColor pixels[height][width];
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
int red = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarSin((x * 4 + y) * 0.03f)));
|
||||
int blue = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarCos((x * 3 + y) * 0.04f)));
|
||||
int green = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarSin((x * 2 + y) * 0.05f)));
|
||||
int alpha = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarCos((x * 1 + y) * 0.006f)));
|
||||
pixels[y][x] =
|
||||
SkColorSetARGB(alpha, red * alpha / 255, green * alpha / 255, blue * alpha / 255);
|
||||
}
|
||||
}
|
||||
SkBitmap bitmap;
|
||||
SkImageInfo info = SkImageInfo::Make(width, height, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
bitmap.installPixels(info, (void*) pixels, sizeof(SkColor) * width);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
SkImageInfo rgbaInfo = info.makeColorType(kRGBA_8888_SkColorType);
|
||||
bitmap.installPixels(rgbaInfo, (void*) pixels, sizeof(SkColor) * width);
|
||||
canvas->drawBitmap(bitmap, 0, 128);
|
||||
}
|
||||
} // END FIDDLE
|
@ -6,13 +6,15 @@ REG_FIDDLE(ImageInfo_makeWH, 256, 144, false, 3) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkImageInfo canvasImageInfo = canvas->imageInfo();
|
||||
SkRect canvasBounds = SkRect::Make(canvasImageInfo.bounds());
|
||||
canvas->drawBitmapRect(source, source.bounds(), canvasBounds, nullptr);
|
||||
canvas->drawImageRect(image, SkRect::Make(source.bounds()), canvasBounds, SkSamplingOptions(),
|
||||
nullptr, SkCanvas::kStrict_SrcRectConstraint);
|
||||
SkImageInfo insetImageInfo =
|
||||
canvasImageInfo.makeWH(canvasBounds.width() / 2, canvasBounds.height() / 2);
|
||||
SkBitmap inset;
|
||||
inset.allocPixels(insetImageInfo);
|
||||
SkCanvas offscreen(inset);
|
||||
offscreen.drawBitmapRect(source, source.bounds(), SkRect::Make(inset.bounds()), nullptr);
|
||||
canvas->drawBitmap(inset, canvasBounds.width() / 4, canvasBounds.height() / 4);
|
||||
offscreen.drawImageRect(image, SkRect::Make(source.bounds()), SkRect::Make(inset.bounds()),
|
||||
SkSamplingOptions(), nullptr, SkCanvas::kStrict_SrcRectConstraint);
|
||||
canvas->drawImage(inset.asImage(), canvasBounds.width() / 4, canvasBounds.height() / 4);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -16,7 +16,7 @@ void draw(SkCanvas* canvas) {
|
||||
sk_sp<SkImage> image = SkImage::MakeRasterCopy(pixmap);
|
||||
*pixmap.writable_addr8(2, 2) = 0x00;
|
||||
canvas->scale(10, 10);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
canvas->drawImage(image, 10, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -16,7 +16,7 @@ void draw(SkCanvas* canvas) {
|
||||
SkPixmap dstPixmap(info, &dstPixels.front(), width * 4);
|
||||
SkBitmap bitmap;
|
||||
bitmap.installPixels(dstPixmap);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
}
|
||||
canvas->translate(48, 0);
|
||||
}
|
||||
|
@ -21,6 +21,6 @@ void draw(SkCanvas* canvas) {
|
||||
SkBitmap bitmap;
|
||||
bitmap.installPixels(SkImageInfo::MakeN32Premul(image->width(), image->height()),
|
||||
&srcPixels.front(), rowBytes);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -6,10 +6,10 @@ REG_FIDDLE(Matrix_063, 256, 256, false, 3) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkMatrix matrix;
|
||||
SkPoint bitmapBounds[4], perspect[4] = {{50, 10}, {180, 40}, {236, 176}, {10, 206}};
|
||||
SkRect::Make(source.bounds()).toQuad(bitmapBounds);
|
||||
SkRect::Make(image->bounds()).toQuad(bitmapBounds);
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.postScale(1, 0.5f);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -6,11 +6,11 @@ REG_FIDDLE(Matrix_Concat, 256, 64, false, 4) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkMatrix matrix, matrix2;
|
||||
SkPoint bitmapBounds[4], perspect[4] = {{50, 10}, {180, 40}, {236, 176}, {10, 206}};
|
||||
SkRect::Make(source.bounds()).toQuad(bitmapBounds);
|
||||
SkRect::Make(image->bounds()).toQuad(bitmapBounds);
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix2.setPolyToPoly(perspect, bitmapBounds, 4);
|
||||
SkMatrix concat = SkMatrix::Concat(matrix, matrix2);
|
||||
canvas->concat(concat);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -5,6 +5,6 @@
|
||||
REG_FIDDLE(Matrix_MakeScale, 256, 256, false, 4) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
canvas->concat(SkMatrix::Scale(4, 3));
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -1,10 +0,0 @@
|
||||
// Copyright 2019 Google LLC.
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
#include "tools/fiddle/examples.h"
|
||||
// HASH=2956aeb50fa862cdb13995e1e56a4bc8
|
||||
REG_FIDDLE(Matrix_MakeScale_2, 256, 256, false, 4) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
canvas->concat(SkMatrix::Scale(4, 4));
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
@ -6,7 +6,7 @@ REG_FIDDLE(Matrix_MakeTrans, 256, 256, false, 4) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkMatrix matrix = SkMatrix::Translate(64, 48);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
canvas->concat(matrix);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ void draw(SkCanvas* canvas) {
|
||||
}
|
||||
}
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -10,6 +10,6 @@ void draw(SkCanvas* canvas) {
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.postConcat(matrix);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -10,6 +10,6 @@ void draw(SkCanvas* canvas) {
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.postRotate(45, source.width() / 2, source.height() / 2);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -10,6 +10,6 @@ void draw(SkCanvas* canvas) {
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.postRotate(45);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -10,6 +10,6 @@ void draw(SkCanvas* canvas) {
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.postScale(.75f, 1.5f, source.width() / 2, source.height() / 2);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -10,6 +10,6 @@ void draw(SkCanvas* canvas) {
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.postScale(.75f, 1.5f);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -6,10 +6,10 @@ REG_FIDDLE(Matrix_postSkew, 256, 256, false, 3) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkMatrix matrix;
|
||||
SkPoint bitmapBounds[4], perspect[4] = {{50, 10}, {180, 40}, {236, 176}, {10, 206}};
|
||||
SkRect::Make(source.bounds()).toQuad(bitmapBounds);
|
||||
SkRect::Make(image->bounds()).toQuad(bitmapBounds);
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.postSkew(.5f, 0, source.width() / 2, source.height() / 2);
|
||||
matrix.postSkew(.5f, 0, image->width() / 2, image->height() / 2);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -6,10 +6,10 @@ REG_FIDDLE(Matrix_postSkew_2, 256, 256, false, 3) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkMatrix matrix;
|
||||
SkPoint bitmapBounds[4], perspect[4] = {{50, 10}, {180, 40}, {236, 176}, {10, 206}};
|
||||
SkRect::Make(source.bounds()).toQuad(bitmapBounds);
|
||||
SkRect::Make(image->bounds()).toQuad(bitmapBounds);
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.postSkew(.5f, 0);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -11,6 +11,6 @@ void draw(SkCanvas* canvas) {
|
||||
matrix2.setPolyToPoly(perspect, bitmapBounds, 4);
|
||||
matrix.preConcat(matrix2);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -6,10 +6,10 @@ REG_FIDDLE(Matrix_preRotate, 256, 256, false, 3) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkMatrix matrix;
|
||||
SkPoint bitmapBounds[4], perspect[4] = {{50, 10}, {180, 40}, {236, 176}, {10, 206}};
|
||||
SkRect::Make(source.bounds()).toQuad(bitmapBounds);
|
||||
SkRect::Make(image->bounds()).toQuad(bitmapBounds);
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.preRotate(45, source.width() / 2, source.height() / 2);
|
||||
matrix.preRotate(45, image->width() / 2, image->height() / 2);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -6,10 +6,10 @@ REG_FIDDLE(Matrix_preRotate_2, 256, 256, false, 3) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkMatrix matrix;
|
||||
SkPoint bitmapBounds[4], perspect[4] = {{50, 10}, {180, 40}, {236, 176}, {10, 206}};
|
||||
SkRect::Make(source.bounds()).toQuad(bitmapBounds);
|
||||
SkRect::Make(image->bounds()).toQuad(bitmapBounds);
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.preRotate(45);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -6,10 +6,10 @@ REG_FIDDLE(Matrix_preScale, 256, 256, false, 3) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkMatrix matrix;
|
||||
SkPoint bitmapBounds[4], perspect[4] = {{50, 10}, {180, 40}, {236, 176}, {10, 206}};
|
||||
SkRect::Make(source.bounds()).toQuad(bitmapBounds);
|
||||
SkRect::Make(image->bounds()).toQuad(bitmapBounds);
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.preScale(.75f, 1.5f, source.width() / 2, source.height() / 2);
|
||||
matrix.preScale(.75f, 1.5f, image->width() / 2, image->height() / 2);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -6,10 +6,10 @@ REG_FIDDLE(Matrix_preScale_2, 256, 256, false, 3) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkMatrix matrix;
|
||||
SkPoint bitmapBounds[4], perspect[4] = {{50, 10}, {180, 40}, {236, 176}, {10, 206}};
|
||||
SkRect::Make(source.bounds()).toQuad(bitmapBounds);
|
||||
SkRect::Make(image->bounds()).toQuad(bitmapBounds);
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.preScale(.75f, 1.5f);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -6,10 +6,10 @@ REG_FIDDLE(Matrix_preSkew, 256, 256, false, 3) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkMatrix matrix;
|
||||
SkPoint bitmapBounds[4], perspect[4] = {{50, 10}, {180, 40}, {236, 176}, {10, 206}};
|
||||
SkRect::Make(source.bounds()).toQuad(bitmapBounds);
|
||||
SkRect::Make(image->bounds()).toQuad(bitmapBounds);
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.preSkew(.5f, 0, source.width() / 2, source.height() / 2);
|
||||
matrix.preSkew(.5f, 0, image->width() / 2, image->height() / 2);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -6,10 +6,10 @@ REG_FIDDLE(Matrix_preSkew_2, 256, 256, false, 3) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkMatrix matrix;
|
||||
SkPoint bitmapBounds[4], perspect[4] = {{50, 10}, {180, 40}, {236, 176}, {10, 206}};
|
||||
SkRect::Make(source.bounds()).toQuad(bitmapBounds);
|
||||
SkRect::Make(image->bounds()).toQuad(bitmapBounds);
|
||||
matrix.setPolyToPoly(bitmapBounds, perspect, 4);
|
||||
matrix.preSkew(.5f, 0);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -8,6 +8,6 @@ void draw(SkCanvas* canvas) {
|
||||
SkScalar buffer[9] = {4, 0, 3, 0, 5, 4, 0, 0, 1};
|
||||
m.set9(buffer);
|
||||
canvas->concat(m);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -11,6 +11,6 @@ void draw(SkCanvas* canvas) {
|
||||
matrix2.setPolyToPoly(perspect, bitmapBounds, 4);
|
||||
matrix.setConcat(matrix, matrix2);
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
|
||||
matrix.setPerspX(perspX);
|
||||
canvas->save();
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
canvas->restore();
|
||||
canvas->translate(64, 64);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
|
||||
matrix.setPerspY(perspX);
|
||||
canvas->save();
|
||||
canvas->concat(matrix);
|
||||
canvas->drawBitmap(source, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
canvas->restore();
|
||||
canvas->translate(64, 64);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ void draw(SkCanvas* canvas) {
|
||||
canvas->drawLine(10, 10, 60, 60, paint);
|
||||
canvas->drawRect({80, 10, 130, 60}, paint);
|
||||
canvas->drawRegion(region, paint);
|
||||
canvas->drawBitmap(bitmap, 200, 10, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 200, 10, &paint);
|
||||
canvas->translate(0, 80);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ void draw(SkCanvas* canvas) {
|
||||
SkBitmap bitmap;
|
||||
canvas->scale(20, 20);
|
||||
bitmap.installPixels(pixmap);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -11,6 +11,6 @@ void draw(SkCanvas* canvas) {
|
||||
SkBitmap bitmap;
|
||||
canvas->scale(20, 20);
|
||||
bitmap.installPixels(pixmap);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -14,6 +14,6 @@ void draw(SkCanvas* canvas) {
|
||||
SkBitmap bitmap;
|
||||
canvas->scale(20, 20);
|
||||
bitmap.installPixels(pixmap);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(image, 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) {
|
||||
if (pixmap.extractSubset(&inset, {128, 128, 512, 512})) {
|
||||
SkBitmap bitmap;
|
||||
bitmap.installPixels(inset);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
}
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -19,13 +19,13 @@ void draw(SkCanvas* canvas) {
|
||||
bitmap.installPixels(srcPixmap);
|
||||
SkCanvas srcCanvas(bitmap);
|
||||
srcCanvas.drawRect(SkRect::MakeWH(width, height), paint);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
std::vector<int32_t> dstPixels;
|
||||
dstPixels.resize(height * width * 2);
|
||||
SkImageInfo dstInfo = srcInfo.makeColorType(kARGB_4444_SkColorType);
|
||||
srcPixmap.readPixels(dstInfo, &dstPixels.front(), width * 2);
|
||||
SkPixmap dstPixmap(dstInfo, &dstPixels.front(), width * 2);
|
||||
bitmap.installPixels(dstPixmap);
|
||||
canvas->drawBitmap(bitmap, 0, 128);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 128);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -18,7 +18,7 @@ void draw(SkCanvas* canvas) {
|
||||
SkPixmap dstmap(info, &dstPixels.front(), rowBytes);
|
||||
bitmap.installPixels(dstmap);
|
||||
canvas->translate(32, 32);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
}
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -18,7 +18,7 @@ void draw(SkCanvas* canvas) {
|
||||
SkBitmap bitmap;
|
||||
bitmap.installPixels(dstmap);
|
||||
canvas->translate(32, 32);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
}
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -18,7 +18,7 @@ void draw(SkCanvas* canvas) {
|
||||
SkBitmap bitmap;
|
||||
bitmap.installPixels(dstmap);
|
||||
canvas->translate(32, 32);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
}
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -15,7 +15,7 @@ void draw(SkCanvas* canvas) {
|
||||
image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
|
||||
SkBitmap bitmap;
|
||||
bitmap.installPixels(pixmap);
|
||||
canvas->drawBitmap(bitmap, x, 0);
|
||||
canvas->drawImage(bitmap.asImage(), x, 0);
|
||||
x += 128;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ void draw(SkCanvas* canvas) {
|
||||
SkBitmap bitmap;
|
||||
bitmap.installPixels(dstmap);
|
||||
canvas->translate(32, 32);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
}
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -14,9 +14,9 @@ void draw(SkCanvas* canvas) {
|
||||
SkBitmap bitmap;
|
||||
bitmap.installPixels(pixmap);
|
||||
canvas->scale(10, 10);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
*pixmap.writable_addr16(2, 2) = 0x000F;
|
||||
bitmap.installPixels(pixmap);
|
||||
canvas->drawBitmap(bitmap, 10, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 10, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -19,6 +19,6 @@ void draw(SkCanvas* canvas) {
|
||||
}
|
||||
SkBitmap bitmap;
|
||||
bitmap.installPixels(pixmap);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -12,9 +12,9 @@ void draw(SkCanvas* canvas) {
|
||||
SkBitmap bitmap;
|
||||
canvas->scale(10, 10);
|
||||
bitmap.installPixels(pixmap);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
*pixmap.writable_addr64(1, 1) |= 0x00ff000000000000LL;
|
||||
bitmap.installPixels(pixmap);
|
||||
canvas->drawBitmap(bitmap, 10, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 10, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -14,9 +14,9 @@ void draw(SkCanvas* canvas) {
|
||||
SkBitmap bitmap;
|
||||
bitmap.installPixels(pixmap);
|
||||
canvas->scale(10, 10);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
*pixmap.writable_addr8(2, 2) = 0;
|
||||
// bitmap.installPixels(pixmap); // uncomment to fix on GPU
|
||||
canvas->drawBitmap(bitmap, 10, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 10, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -14,12 +14,12 @@ void draw(SkCanvas* canvas) {
|
||||
SkBitmap bitmap;
|
||||
canvas->scale(20, 20);
|
||||
bitmap.installPixels(pixmap);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
uint16_t* pixel2 = pixmap.writable_addrF16(0, 1);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
pixel2[i] = storage[0][i];
|
||||
}
|
||||
bitmap.installPixels(pixmap);
|
||||
canvas->drawBitmap(bitmap, 4, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 4, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) {
|
||||
if (big->peekPixels(&pixmap)) {
|
||||
SkBitmap bigBits;
|
||||
bigBits.installPixels(pixmap);
|
||||
canvas->drawBitmap(bigBits, 0, 0);
|
||||
canvas->drawImage(bigBits.asImage(), 0, 0);
|
||||
}
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -12,12 +12,12 @@ void draw(SkCanvas* canvas) {
|
||||
if (big->peekPixels(&pixmap)) {
|
||||
SkBitmap bigBits;
|
||||
bigBits.installPixels(pixmap);
|
||||
canvas->drawBitmap(bigBits, 0, 0);
|
||||
canvas->drawImage(bigBits.asImage(), 0, 0);
|
||||
}
|
||||
if (lil->peekPixels(&pixmap)) {
|
||||
SkBitmap lilBits;
|
||||
lilBits.installPixels(pixmap);
|
||||
canvas->drawBitmap(lilBits, 64, 64);
|
||||
canvas->drawImage(lilBits.asImage(), 64, 64);
|
||||
}
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -18,6 +18,6 @@ void draw(SkCanvas* canvas) {
|
||||
surf->readPixels(bitmap, x, y);
|
||||
}
|
||||
}
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -17,7 +17,9 @@ void draw(SkCanvas* canvas) {
|
||||
paint.setMaskFilter(SkMaskFilter::MakeBlur(kSolid_SkBlurStyle, 3));
|
||||
for (auto color : {SK_ColorRED, SK_ColorBLUE, 0xFF007F00}) {
|
||||
paint.setColor(color);
|
||||
canvas->drawBitmapRect(bitmap, SkRect::MakeWH(8, 8), SkRect::MakeWH(32, 32), &paint);
|
||||
canvas->drawImageRect(bitmap.asImage(), SkRect::MakeWH(8, 8), SkRect::MakeWH(32, 32),
|
||||
SkSamplingOptions(), &paint,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
canvas->translate(48, 0);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ void draw(SkCanvas* canvas) {
|
||||
}
|
||||
}
|
||||
canvas->scale(8, 8);
|
||||
canvas->drawBitmap(bm16, 0, 0);
|
||||
canvas->drawImage(bm16.asImage(), 0, 0);
|
||||
}
|
||||
|
||||
} // END FIDDLE
|
||||
|
@ -13,6 +13,6 @@ void draw(SkCanvas* canvas) {
|
||||
SkPaint paint;
|
||||
paint.setColor(0xFF00FF00);
|
||||
canvas->clear(0xFF000000);
|
||||
canvas->drawBitmap(bitmap, 0, 0, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0, SkSamplingOptions(), &paint);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -10,9 +10,9 @@ void draw(SkCanvas* canvas) {
|
||||
bitmap.allocPixels(imageInfo);
|
||||
SkCanvas offscreen(bitmap);
|
||||
offscreen.clear(SK_ColorGREEN);
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0);
|
||||
offscreen.clear(SK_ColorGRAY);
|
||||
canvas->drawBitmap(bitmap, 2, 2);
|
||||
canvas->drawImage(bitmap.asImage(), 2, 2);
|
||||
auto pack8888 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint32_t {
|
||||
return (a << 24) | (b << 16) | (g << 8) | (r << 0);
|
||||
};
|
||||
@ -22,11 +22,11 @@ void draw(SkCanvas* canvas) {
|
||||
pack8888(0xFF, 0x0, 0x0, 0x099), pack8888(0xFF, 0x0, 0x0, 0x055)};
|
||||
SkPixmap redPixmap(imageInfo, &red8888, 8);
|
||||
if (bitmap.writePixels(redPixmap, 0, 0)) {
|
||||
canvas->drawBitmap(bitmap, 4, 4);
|
||||
canvas->drawImage(bitmap.asImage(), 4, 4);
|
||||
}
|
||||
SkPixmap bluePixmap(imageInfo, &blue8888, 8);
|
||||
if (bitmap.writePixels(bluePixmap, 0, 0)) {
|
||||
canvas->drawBitmap(bitmap, 6, 6);
|
||||
canvas->drawImage(bitmap.asImage(), 6, 6);
|
||||
}
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -1,19 +0,0 @@
|
||||
// Copyright 2020 Google LLC.
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
#include "tools/fiddle/examples.h"
|
||||
REG_FIDDLE(kLow_SkFilterQuality, 192, 192, false, 0) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
static const uint32_t pixels[9] = {
|
||||
0xFFFF0000, 0xFFFFFFFF, 0xFF00FF00, 0xFFFFFFFF, 0xFF000000,
|
||||
0xFFFFFFFF, 0xFF808080, 0xFFFFFFFF, 0xFF0000FF,
|
||||
};
|
||||
SkBitmap bm;
|
||||
bm.installPixels(SkImageInfo::MakeN32Premul(3, 3), (void*)pixels, 12);
|
||||
bm.setImmutable();
|
||||
SkPaint paint;
|
||||
paint.setFilterQuality(kLow_SkFilterQuality);
|
||||
// paint.setMaskFilter(SkBlurMaskFilter::Make(
|
||||
// kNormal_SkBlurStyle, 3.375, SkBlurMaskFilter::kHighQuality_BlurFlag));
|
||||
canvas->drawBitmapRect(bm, {64, 64, 128, 128}, &paint);
|
||||
}
|
||||
} // END FIDDLE
|
@ -18,7 +18,7 @@ void draw(SkCanvas* canvas) {
|
||||
SkIPoint offset;
|
||||
bitmap.extractAlpha(&alpha, &paint, nullptr, &offset);
|
||||
paint.setColor(SK_ColorRED);
|
||||
canvas->drawBitmap(bitmap, 0, -offset.fY, &paint);
|
||||
canvas->drawBitmap(alpha, 100 + offset.fX, 0, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 0, -offset.fY, SkSamplingOptions(), &paint);
|
||||
canvas->drawImage(alpha.asImage(), 100 + offset.fX, 0, SkSamplingOptions(), &paint);
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -14,7 +14,7 @@ void draw(SkCanvas* canvas) {
|
||||
offscreen.drawString("e", 20, 70, font, paint);
|
||||
paint.setImageFilter(SkImageFilters::PointLitDiffuse(
|
||||
SkPoint3::Make(80, 100, 10), SK_ColorWHITE, 1, 2, nullptr, nullptr));
|
||||
canvas->drawBitmap(bitmap, 0, 0, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0, SkSamplingOptions(), &paint);
|
||||
}
|
||||
|
||||
} // END FIDDLE
|
||||
|
@ -21,7 +21,7 @@ void draw(SkCanvas* canvas) {
|
||||
int y = shuffle[(N * i) + j] / N;
|
||||
SkBitmap subset;
|
||||
source.extractSubset(&subset, SkIRect::MakeXYWH(w * x, h * y, w, h));
|
||||
canvas->drawBitmap(subset, w * i, h * j);
|
||||
canvas->drawImage(subset.asImage(), w * i, h * j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -348,9 +348,7 @@
|
||||
#include "../../docs/examples/ImageInfo_height.cpp"
|
||||
#include "../../docs/examples/ImageInfo_isEmpty.cpp"
|
||||
#include "../../docs/examples/ImageInfo_isOpaque.cpp"
|
||||
#include "../../docs/examples/ImageInfo_makeAlphaType.cpp"
|
||||
#include "../../docs/examples/ImageInfo_makeColorSpace.cpp"
|
||||
#include "../../docs/examples/ImageInfo_makeColorType.cpp"
|
||||
#include "../../docs/examples/ImageInfo_makeWH.cpp"
|
||||
#include "../../docs/examples/ImageInfo_minRowBytes.cpp"
|
||||
#include "../../docs/examples/ImageInfo_minRowBytes64.cpp"
|
||||
@ -414,7 +412,6 @@
|
||||
#include "../../docs/examples/Matrix_MakeAll.cpp"
|
||||
#include "../../docs/examples/Matrix_MakeRectToRect.cpp"
|
||||
#include "../../docs/examples/Matrix_MakeScale.cpp"
|
||||
#include "../../docs/examples/Matrix_MakeScale_2.cpp"
|
||||
#include "../../docs/examples/Matrix_MakeTrans.cpp"
|
||||
#include "../../docs/examples/Matrix_ScaleToFit.cpp"
|
||||
#include "../../docs/examples/Matrix_SetAffineIdentity.cpp"
|
||||
@ -1130,7 +1127,6 @@
|
||||
#include "../../docs/examples/incomplete.cpp"
|
||||
#include "../../docs/examples/inlinepixmapconstructor.cpp"
|
||||
#include "../../docs/examples/issue640176.cpp"
|
||||
#include "../../docs/examples/kLow_SkFilterQuality.cpp"
|
||||
#include "../../docs/examples/l_system_plant.cpp"
|
||||
#include "../../docs/examples/maddash.cpp"
|
||||
#include "../../docs/examples/makeRasterImage_fail.cpp"
|
||||
|
Loading…
Reference in New Issue
Block a user