Add fixes & test for isConfigTexturable and isConfigRenderable
[platform/upstream/libSkiaSharp.git] / gm / copyTo4444.cpp
1 /*
2  * Copyright 2013 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7
8 #include "gm.h"
9 #include "sk_tool_utils.h"
10
11 #include "Resources.h"
12 #include "SkCanvas.h"
13 #include "SkOSFile.h"
14
15 namespace skiagm {
16
17 /**
18  *  Test copying an image from 8888 to 4444.
19  */
20 class CopyTo4444GM : public GM {
21 public:
22     CopyTo4444GM() {}
23
24 protected:
25     virtual SkString onShortName() {
26         return SkString("copyTo4444");
27     }
28
29     virtual SkISize onISize() {
30         return SkISize::Make(1024, 512);
31     }
32
33     virtual void onDraw(SkCanvas* canvas) {
34         SkBitmap bm, bm4444;
35         if (!GetResourceAsBitmap("mandrill_512.png", &bm)) {
36             SkDebugf("Could not decode the file. Did you forget to set the "
37                      "resourcePath?\n");
38             return;
39         }
40         canvas->drawBitmap(bm, 0, 0);
41         SkAssertResult(sk_tool_utils::copy_to(&bm4444, kARGB_4444_SkColorType, bm));
42         canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0);
43     }
44
45 private:
46     typedef GM INHERITED;
47 };
48
49 //////////////////////////////////////////////////////////////////////////////
50
51 static GM* MyFactory(void*) { return new CopyTo4444GM; }
52 static GMRegistry reg(MyFactory);
53
54 }