Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2790)

Unified Diff: gm/all_bitmap_configs.cpp

Issue 950633003: PDF: remove last use of SkPDFImage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-02-21 (Saturday) 10:55:02 EST Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | src/pdf/SkPDFBitmap.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/all_bitmap_configs.cpp
diff --git a/gm/all_bitmap_configs.cpp b/gm/all_bitmap_configs.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1a37395a6745217e798887e0ab81c6a09ab9b8ef
--- /dev/null
+++ b/gm/all_bitmap_configs.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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 "sk_tool_utils.h"
+#include "SkSurface.h"
+#include "Resources.h"
+#include "gm.h"
+
+DEF_SIMPLE_GM(all_bitmap_configs, canvas, 128, 640) {
+ SkPaint p;
+ p.setColor(SK_ColorBLACK);
+ sk_tool_utils::set_portable_typeface(&p);
+
+ sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8);
+
+ SkBitmap bitmap;
+ if (GetResourceAsBitmap("color_wheel.png", &bitmap)) {
+ bitmap.setImmutable();
+ SkASSERT(bitmap.colorType() == kN32_SkColorType);
+ canvas->drawBitmap(bitmap, 0.0f, 0.0f);
+ const char kN32[] = "Native 32";
+ canvas->drawText(kN32, strlen(kN32), 0, 12, p);
+
+ SkAutoTUnref<SkSurface> surf565(SkSurface::NewRaster(SkImageInfo::Make(
mtklein 2015/02/23 14:26:52 Why not use SkBitmap::copyTo() here too?
hal.canary 2015/03/20 01:09:45 Done.
+ 128, 128, kRGB_565_SkColorType, kOpaque_SkAlphaType)));
+ SkCanvas* canvas565 = surf565->getCanvas();
+ canvas565->drawColor(SK_ColorLTGRAY);
+ canvas565->drawBitmap(bitmap, 0.0f, 0.0f);
+ surf565->draw(canvas, 0.0f, 128.0f, NULL);
+ const char kRGB565[] = "RGB 565";
+ canvas->drawText(kRGB565, strlen(kRGB565), 0, 140, p);
+
+ SkBitmap copy4444;
+ bitmap.copyTo(&copy4444, kARGB_4444_SkColorType);
+ copy4444.setImmutable();
+ SkASSERT(copy4444.colorType() == kARGB_4444_SkColorType);
+ canvas->drawBitmap(copy4444, 0.0f, 256.0f);
+ const char kARGB4444[] = "ARGB 4444";
+ canvas->drawText(kARGB4444, strlen(kARGB4444), 0, 268, p);
+ }
+
+ SkBitmap bitmapIndexed;
+ if (GetResourceAsBitmap("color_wheel.gif", &bitmapIndexed)) {
+ bitmapIndexed.setImmutable();
+ SkASSERT(bitmapIndexed.colorType() == kIndex_8_SkColorType);
+ canvas->drawBitmap(bitmapIndexed, 0.0f, 384.0f);
+ const char kIndex8[] = "Index 8";
+ canvas->drawText(kIndex8, strlen(kIndex8), 0, 396, p);
+ }
+
+ SkBitmap bitmapA8;
+ bitmapA8.allocPixels(SkImageInfo::MakeA8(128, 128));
+ SkAutoLockPixels autoLockPixels(bitmapA8);
+ uint8_t spectrum[256];
mtklein 2015/02/23 14:26:52 Seems fine, but we really only need 128, right?
hal.canary 2015/03/20 01:09:45 I'm shifting it over one pixel for each scanline.
+ for (int y = 0; y < 256; ++y) {
+ spectrum[y] = y;
+ }
+ for (int y = 0; y < 128; ++y) {
+ memcpy(bitmapA8.getAddr8(0, y), &spectrum[y], 128);
+ }
+ bitmapA8.setImmutable();
+ SkASSERT(bitmapA8.colorType() == kAlpha_8_SkColorType);
+ canvas->drawBitmap(bitmapA8, 0.0f, 512.0f);
+ const char kAlpha8[] = "Alpha 8";
+ canvas->drawText(kAlpha8, strlen(kAlpha8), 0, 524, p);
+}
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | src/pdf/SkPDFBitmap.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698