diff options
author | halcanary <halcanary@google.com> | 2015-02-18 11:29:56 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-18 11:29:57 -0800 |
commit | 1b5c604d9d344537941b11b136348edfc39f236c (patch) | |
tree | 72110f65007d2e0af1cc525376488ed360b6a07d /gm | |
parent | 0babd3c61987428a5c532f65be9d98c7ac583e0d (diff) |
PDF: Add (low-memory) SkPDFBitmap class
Also: Add SkDeflateWStream and associated unit tests.
SkPDFBitmap is a replacement for SkPDFImage. As of now, it only
supports 8888 bitmaps (the most common case).
SkPDFBitmap takes very little extra memory (aside from refing the
bitmap's pixels), and its emitObject() does not cache any data.
The SkPDFBitmap::Create function will check the canon for duplicates.
This can reduce the size of the output PDF.
Motivation: this gives another ~40% decrease in PDF memory overhead
TODO: Support other ColorTypes and scrap SkPDFImage.
BUG=skia:3030
Review URL: https://codereview.chromium.org/918813002
Diffstat (limited to 'gm')
-rw-r--r-- | gm/repeated_bitmap.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gm/repeated_bitmap.cpp b/gm/repeated_bitmap.cpp new file mode 100644 index 0000000000..fa5fe0c136 --- /dev/null +++ b/gm/repeated_bitmap.cpp @@ -0,0 +1,31 @@ +/* + * 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 "gm.h" +#include "sk_tool_utils.h" +#include "Resources.h" + +DEF_SIMPLE_GM(repeated_bitmap, canvas, 576, 576) { + sk_tool_utils::draw_checkerboard(canvas, 0xFF999999, SK_ColorWHITE, 12); + SkRect rect = SkRect::MakeLTRB(-4.25f, -4.25f, 4.25f, 4.25f); + SkPaint paint; + paint.setColor(0xFF333333); + SkBitmap bm; + if (GetResourceAsBitmap("randPixels.png", &bm)) { + for (int j = 0; j < 4; ++j) { + for (int i = 0; i < 4; ++i) { + SkAutoCanvasRestore autoCanvasRestore(canvas, true); + canvas->scale(12.0f, 12.0f); + canvas->translate(6.0f + 12.0f * SkIntToScalar(i), + 6.0f + 12.0f * SkIntToScalar(j)); + canvas->rotate(18.0f * (i + 4 * j)); + canvas->drawRect(rect, paint); + canvas->drawBitmap(bm, -4.0f, -4.0f); + } + } + } +} |