aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/bitmappremul.cpp
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-15 14:51:04 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-15 14:51:04 +0000
commit12bf9b35d2704c089411539a0bbe8b42d3e3a220 (patch)
treef82945011c1f26941cbf2ac0b7bf3bb98ebd9592 /gm/bitmappremul.cpp
parenta474a1d9d43deb4ec7e53b1606681ccb90ca677b (diff)
Revert "Unpremultiply SkBitmaps for PDF output"
This reverts commit 16a6c9d28c8ef6f827d50ef258005fa5ec971bd9. Seems to be breaking all of the windows debug bots in GM. git-svn-id: http://skia.googlecode.com/svn/trunk@10737 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/bitmappremul.cpp')
-rw-r--r--gm/bitmappremul.cpp131
1 files changed, 0 insertions, 131 deletions
diff --git a/gm/bitmappremul.cpp b/gm/bitmappremul.cpp
deleted file mode 100644
index 9f0c1e8cb9..0000000000
--- a/gm/bitmappremul.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2013 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 "SkBitmap.h"
-#include "SkCanvas.h"
-#include "SkColorPriv.h"
-
-/**
- * This GM checks that bitmap pixels are unpremultiplied before being exported
- * to other formats. If unpremultiplication is implemented properly, this
- * GM should come out completely white. If not, this GM looks like a row of two
- * greyscale gradients above a row of grey lines.
- * This tests both the ARGB4444 and ARGB8888 bitmap configurations.
- */
-
-static const int SLIDE_SIZE = 256;
-static const int PIXEL_SIZE_8888 = SLIDE_SIZE / 256;
-static const int PIXEL_SIZE_4444 = SLIDE_SIZE / 16;
-
-static SkBitmap init_bitmap(SkBitmap::Config config) {
- SkBitmap bitmap;
- bitmap.setConfig(config, SLIDE_SIZE, SLIDE_SIZE);
- bitmap.allocPixels();
- bitmap.eraseColor(SK_ColorWHITE);
- return bitmap;
-}
-
-static SkBitmap make_argb8888_gradient() {
- SkBitmap bitmap = init_bitmap(SkBitmap::kARGB_8888_Config);
- uint8_t rowColor = 0;
- for (int y = 0; y < SLIDE_SIZE; y++) {
- uint32_t* dst = bitmap.getAddr32(0, y);
- for (int x = 0; x < SLIDE_SIZE; x++) {
- dst[x] = SkPackARGB32(rowColor, rowColor,
- rowColor, rowColor);
- }
- if (y % PIXEL_SIZE_8888 == PIXEL_SIZE_8888 - 1) {
- rowColor++;
- }
- }
- return bitmap;
-}
-
-static SkBitmap make_argb4444_gradient() {
- SkBitmap bitmap = init_bitmap(SkBitmap::kARGB_4444_Config);
- uint8_t rowColor = 0;
- for (int y = 0; y < SLIDE_SIZE; y++) {
- uint16_t* dst = bitmap.getAddr16(0, y);
- for (int x = 0; x < SLIDE_SIZE; x++) {
- dst[x] = SkPackARGB4444(rowColor, rowColor,
- rowColor, rowColor);
- }
- if (y % PIXEL_SIZE_4444 == PIXEL_SIZE_4444 - 1) {
- rowColor++;
- }
- }
- return bitmap;
-}
-
-static SkBitmap make_argb8888_stripes() {
- SkBitmap bitmap = init_bitmap(SkBitmap::kARGB_8888_Config);
- uint8_t rowColor = 0;
- for (int y = 0; y < SLIDE_SIZE; y++) {
- uint32_t* dst = bitmap.getAddr32(0, y);
- for (int x = 0; x < SLIDE_SIZE; x++) {
- dst[x] = SkPackARGB32(rowColor, rowColor,
- rowColor, rowColor);
- }
- if (rowColor == 0) {
- rowColor = 255;
- } else {
- rowColor = 0;
- }
- }
- return bitmap;
-}
-
-static SkBitmap make_argb4444_stripes() {
- SkBitmap bitmap = init_bitmap(SkBitmap::kARGB_4444_Config);
- uint8_t rowColor = 0;;
- for (int y = 0; y < SLIDE_SIZE; y++) {
- uint16_t* dst = bitmap.getAddr16(0, y);
- for (int x = 0; x < SLIDE_SIZE; x++) {
- dst[x] = SkPackARGB4444(rowColor, rowColor,
- rowColor, rowColor);
- }
- if (rowColor == 0) {
- rowColor = 15;
- } else {
- rowColor = 0;
- }
- }
- return bitmap;
-}
-
-namespace skiagm {
-
-class BitmapPremulGM : public GM {
-public:
- BitmapPremulGM() {
- this->setBGColor(0xFFFFFFFF);
- }
-
-protected:
- SkString onShortName() SK_OVERRIDE {
- return SkString("bitmap_premul");
- }
-
- virtual SkISize onISize() SK_OVERRIDE {
- return SkISize::Make(512, 512);
- }
-
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- SkScalar slideSize = SLIDE_SIZE;
- canvas->drawBitmap(make_argb8888_gradient(), 0, 0);
- canvas->drawBitmap(make_argb4444_gradient(), slideSize, 0);
- canvas->drawBitmap(make_argb8888_stripes(), 0, slideSize);
- canvas->drawBitmap(make_argb4444_stripes(), slideSize, slideSize);
- }
-
-private:
- typedef GM INHERITED;
-};
-
-DEF_GM( return new BitmapPremulGM; )
-}