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

Side by Side Diff: bench/PremulAndUnpremulAlphaOpsBench.cpp

Issue 15402003: Improve the performance of SkConvertConfig8888Pixels using Array lookup (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: change some code to follow the style Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | gyp/bench.gypi » ('j') | src/core/SkConfig8888.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2013 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9 #include "SkBenchmark.h"
10 #include "SkCanvas.h"
11 #include "SkConfig8888.h"
12
13 class PremulAndUnpremulAlphaOpsBench : public SkBenchmark {
14 public:
15 PremulAndUnpremulAlphaOpsBench(void* param, SkCanvas::Config8888 config, con st char* name)
16 : INHERITED(param) {
17 unPremulConfig = config;
18 benchName = name;
19 }
20
21 protected:
22 virtual const char* onGetName() SK_OVERRIDE {
23 return benchName;
24 }
25
26 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
27 canvas->clear(SK_ColorBLACK);
28 SkISize size = canvas->getDeviceSize();
29
30 static const int kLoopCount = SkBENCHLOOP(10);
31 for (int loop = 0; loop < kLoopCount; ++loop) {
32 SkBitmap bmp1;
33 bmp1.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.heigh t());
34 bmp1.allocPixels();
bsalomon 2013/06/10 13:48:22 Can't all this setup of bmp1 be done outside the l
Jun Jiang 2013/06/11 14:46:20 Yes, the setup of bmp1 can be done outside of the
35 SkAutoLockPixels alp(bmp1);
36 uint32_t* pixels = reinterpret_cast<uint32_t*>(bmp1.getPixels());
37 for (int h = 0; h < size.height(); ++h) {
38 for (int w = 0; w < size.width(); ++w)
39 pixels[h * size.width() + w] = SkPackConfig8888(unPremulConf ig, h & 0xFF, w & 0xFF, w & 0xFF, w & 0xFF);
40 }
41 // Unpremul -> Premul
42 canvas->writePixels(bmp1, 0, 0, unPremulConfig);
43
44 SkBitmap bmp2;
45 bmp2.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.heigh t());
46 // Premul -> Unpremul
47 canvas->readPixels(&bmp2, 0, 0, unPremulConfig);
48 }
49 }
50
51 private:
52 SkCanvas::Config8888 unPremulConfig;
53 const char* benchName;
54 typedef SkBenchmark INHERITED;
55 };
56
57 static SkBenchmark* fact0(void* p) { return new PremulAndUnpremulAlphaOpsBench(p , SkCanvas::kRGBA_Unpremul_Config8888, "premul_and_unpremul_alpha_RGBA8888"); }
58 static SkBenchmark* fact1(void* p) { return new PremulAndUnpremulAlphaOpsBench(p , SkCanvas::kNative_Unpremul_Config8888, "premul_and_unpremul_alpha_Native8888") ; }
59
60 static BenchRegistry gReg0(fact0);
61 static BenchRegistry gReg1(fact1);
OLDNEW
« no previous file with comments | « no previous file | gyp/bench.gypi » ('j') | src/core/SkConfig8888.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698