| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 /** Tests for ARGBImageEncoder. */ | 8 /** Tests for ARGBImageEncoder. */ |
| 9 | 9 |
| 10 #include "Test.h" | 10 #include "Test.h" |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
| 13 #include "SkImageEncoder.h" | 13 #include "SkImageEncoder.h" |
| 14 #include "SkStream.h" | 14 #include "SkStream.h" |
| 15 | 15 |
| 16 namespace skiatest { | 16 namespace skiatest { |
| 17 | 17 |
| 18 class BitmapTransformerTestClass : public Test { | 18 class BitmapTransformerTestClass : public Test { |
| 19 public: | 19 public: |
| 20 static Test* Factory(void*) { return SkNEW(BitmapTransformerTestClass); } | 20 static Test* Factory(void*) { return SkNEW(BitmapTransformerTestClass); } |
| 21 protected: | 21 protected: |
| 22 virtual void onGetName(SkString* name) SK_OVERRIDE { name->set("ARGBImageEnc
oder"); } | 22 virtual void onGetName(SkString* name) SK_OVERRIDE { name->set("ARGBImageEnc
oder"); } |
| 23 virtual void onRun(Reporter* reporter) SK_OVERRIDE; | 23 virtual void onRun(Reporter* reporter) SK_OVERRIDE; |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 static SkBitmap::Config configs[] = { | 26 static SkBitmap::Config configs[] = { |
| 27 SkBitmap::kRGB_565_Config, | 27 SkBitmap::kRGB_565_Config, |
| 28 SkBitmap::kARGB_4444_Config, | |
| 29 SkBitmap::kARGB_8888_Config, | 28 SkBitmap::kARGB_8888_Config, |
| 30 }; | 29 }; |
| 31 | 30 |
| 32 void BitmapTransformerTestClass::onRun(Reporter* reporter) { | 31 void BitmapTransformerTestClass::onRun(Reporter* reporter) { |
| 33 // Bytes we expect to get: | 32 // Bytes we expect to get: |
| 34 const int kWidth = 3; | 33 const int kWidth = 3; |
| 35 const int kHeight = 5; | 34 const int kHeight = 5; |
| 36 const unsigned char comparisonBuffer[] = { | 35 const unsigned char comparisonBuffer[] = { |
| 37 // kHeight rows, each with kWidth pixels, premultiplied ARGB for each pi
xel | 36 // kHeight rows, each with kWidth pixels, premultiplied ARGB for each pi
xel |
| 38 0xff,0xff,0x00,0x00, 0xff,0xff,0x00,0x00, 0xff,0xff,0x00,0x00, // red | 37 0xff,0xff,0x00,0x00, 0xff,0xff,0x00,0x00, 0xff,0xff,0x00,0x00, // red |
| (...skipping 30 matching lines...) Expand all Loading... |
| 69 | 68 |
| 70 // Confirm we got the expected results. | 69 // Confirm we got the expected results. |
| 71 REPORTER_ASSERT(reporter, bufferSize == sizeof(comparisonBuffer)); | 70 REPORTER_ASSERT(reporter, bufferSize == sizeof(comparisonBuffer)); |
| 72 REPORTER_ASSERT(reporter, memcmp(pixelBuffer, comparisonBuffer, bufferSi
ze) == 0); | 71 REPORTER_ASSERT(reporter, memcmp(pixelBuffer, comparisonBuffer, bufferSi
ze) == 0); |
| 73 } | 72 } |
| 74 } | 73 } |
| 75 | 74 |
| 76 static TestRegistry gReg(BitmapTransformerTestClass::Factory); | 75 static TestRegistry gReg(BitmapTransformerTestClass::Factory); |
| 77 | 76 |
| 78 } | 77 } |
| OLD | NEW |