skia2/gm/repeated_bitmap.cpp
halcanary 7a14b310d6 SkPDF: Implement drawImage*() properly
drawImage calls now properly embeds the original jpeg.

NOTE: drawBitmap*() calls no longer embed JPEG files when
possible (this is in advance of eliminating bitmaps backed
by encoded data).  Chromium has already moved from
drawBitmap to drawImage.

Comparisons:

control:
    total PDF drawImage/drawBitmap calls: 8010
    total PDF jpeg images: 0
    total PDF regular images: 3581

experiament:
    total PDF drawImage/drawBitmap calls: 8014
    total PDF jpeg images: 271
    total PDF regular images: 3311
    total PDF regular images: 3582 (271 + 3311)

When comparing rendered output there were perceptual
differences in the following four GMs: colorcube, emboss,
colormatrix, and tablecolorfilter.  All of these differences
were improvements (that is, closer to the 8888 rendering)
due fixing a bug with colorfilters and forgetting to call
notifyPixelsChanged.

No SKPs had perceptual differences.

Total PDF size dropped from 133964 kB to 126276 kB, a 5.7%
improvement (mostly due to restoring use of JPG images in
SKPs).

BUG=skia:4370

Review URL: https://codereview.chromium.org/1372783003
2015-10-01 07:28:13 -07:00

46 lines
1.5 KiB
C++

/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Resources.h"
#include "SkImage.h"
#include "gm.h"
#include "sk_tool_utils.h"
static void draw_rotated_image(SkCanvas* canvas, const SkImage* image) {
sk_tool_utils::draw_checkerboard(canvas, SkColorSetRGB(156, 154, 156),
SK_ColorWHITE, 12);
if (!image) {
return;
}
SkRect rect = SkRect::MakeLTRB(-68.0f, -68.0f, 68.0f, 68.0f);
SkPaint paint;
paint.setColor(SkColorSetRGB(49, 48, 49));
SkScalar scale = SkTMin(128.0f / image->width(),
128.0f / image->height());
SkScalar point[2] = {-0.5f * image->width(), -0.5f * image->height()};
for (int j = 0; j < 4; ++j) {
for (int i = 0; i < 4; ++i) {
SkAutoCanvasRestore autoCanvasRestore(canvas, true);
canvas->translate(96.0f + 192.0f * i, 96.0f + 192.0f * j);
canvas->rotate(18.0f * (i + 4 * j));
canvas->drawRect(rect, paint);
canvas->scale(scale, scale);
canvas->drawImage(image, point[0], point[1]);
}
}
}
DEF_SIMPLE_GM(repeated_bitmap, canvas, 576, 576) {
SkAutoTUnref<SkImage> image(GetResourceAsImage("randPixels.png"));
draw_rotated_image(canvas, image);
}
DEF_SIMPLE_GM(repeated_bitmap_jpg, canvas, 576, 576) {
SkAutoTUnref<SkImage> image(GetResourceAsImage("color_wheel.jpg"));
draw_rotated_image(canvas, image);
}