2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
12 class WritePixelsBench : public Benchmark {
14 WritePixelsBench(SkColorType ct, SkAlphaType at)
20 case kRGBA_8888_SkColorType:
21 fName.append("_RGBA");
23 case kBGRA_8888_SkColorType:
24 fName.append("_BGRA");
31 case kPremul_SkAlphaType:
34 case kUnpremul_SkAlphaType:
44 const char* onGetName() SK_OVERRIDE {
48 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
49 SkISize size = canvas->getDeviceSize();
51 canvas->clear(0xFFFF0000);
54 bmp.allocN32Pixels(size.width(), size.height());
55 canvas->readPixels(&bmp, 0, 0);
57 SkImageInfo info = SkImageInfo::Make(bmp.width(), bmp.height(), fColorType, fAlphaType);
59 for (int loop = 0; loop < loops; ++loop) {
60 canvas->writePixels(info, bmp.getPixels(), bmp.rowBytes(), 0, 0);
65 SkColorType fColorType;
66 SkAlphaType fAlphaType;
69 typedef Benchmark INHERITED;
72 //////////////////////////////////////////////////////////////////////////////
74 DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (kRGBA_8888_SkColorType, kPremul_SkAlphaType)); )
75 DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (kRGBA_8888_SkColorType, kUnpremul_SkAlphaType)); )