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

Unified Diff: bench/PremulAndUnpremulAlphaOpsBench.cpp

Issue 199413013: add new readPixels with direct memory parameters (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/bench.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/PremulAndUnpremulAlphaOpsBench.cpp
diff --git a/bench/PremulAndUnpremulAlphaOpsBench.cpp b/bench/PremulAndUnpremulAlphaOpsBench.cpp
deleted file mode 100644
index 4afa43fe6ebfee0c87ba1ce3f03dea70e25dd9d0..0000000000000000000000000000000000000000
--- a/bench/PremulAndUnpremulAlphaOpsBench.cpp
+++ /dev/null
@@ -1,71 +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 "SkBenchmark.h"
-#include "SkCanvas.h"
-#include "SkConfig8888.h"
-#include "SkString.h"
-#include "sk_tool_utils.h"
-
-class PremulAndUnpremulAlphaOpsBench : public SkBenchmark {
bsalomon 2014/03/17 18:19:47 Removing this benchmark scares me a little bit. Th
reed1 2014/03/17 18:47:09 Restored and updated
-public:
- PremulAndUnpremulAlphaOpsBench(SkCanvas::Config8888 config) {
- fUnPremulConfig = config;
- fName.printf("premul_and_unpremul_alpha_%s",
- (config == SkCanvas::kRGBA_Unpremul_Config8888) ?
- "RGBA8888" : "Native8888");
- }
-
-protected:
- virtual const char* onGetName() SK_OVERRIDE {
- return fName.c_str();
- }
-
- virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
- canvas->clear(SK_ColorBLACK);
- SkISize size = canvas->getDeviceSize();
-
- SkBitmap bmp1;
- bmp1.setConfig(SkBitmap::kARGB_8888_Config, size.width(),
- size.height());
- bmp1.allocPixels();
- SkAutoLockPixels alp(bmp1);
- uint32_t* pixels = reinterpret_cast<uint32_t*>(bmp1.getPixels());
- for (int h = 0; h < size.height(); ++h) {
- for (int w = 0; w < size.width(); ++w)
- pixels[h * size.width() + w] = SkPackConfig8888(fUnPremulConfig,
- h & 0xFF, w & 0xFF, w & 0xFF, w & 0xFF);
- }
-
- SkBitmap bmp2;
- bmp2.setConfig(SkBitmap::kARGB_8888_Config, size.width(),
- size.height());
-
- SkColorType ct;
- SkAlphaType at;
- sk_tool_utils::config8888_to_imagetypes(fUnPremulConfig, &ct, &at);
- if (bmp1.isOpaque()) {
- at = kOpaque_SkAlphaType;
- }
-
- for (int loop = 0; loop < loops; ++loop) {
- // Unpremul -> Premul
- sk_tool_utils::write_pixels(canvas, bmp1, 0, 0, ct, at);
- // Premul -> Unpremul
- canvas->readPixels(&bmp2, 0, 0, fUnPremulConfig);
- }
- }
-
-private:
- SkCanvas::Config8888 fUnPremulConfig;
- SkString fName;
- typedef SkBenchmark INHERITED;
-};
-
-
-DEF_BENCH(return new PremulAndUnpremulAlphaOpsBench(SkCanvas::kRGBA_Unpremul_Config8888));
-DEF_BENCH(return new PremulAndUnpremulAlphaOpsBench(SkCanvas::kNative_Unpremul_Config8888));
« no previous file with comments | « no previous file | gyp/bench.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698