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

Side by Side Diff: bench/ImageBench.cpp

Issue 1261663004: add bench for gpu-image -> cpu-surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 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 "Benchmark.h"
9 #include "SkCanvas.h"
10 #include "SkImage.h"
11 #include "SkSurface.h"
12
13 class GPU2RasterImageBench : public Benchmark {
14 public:
15 GPU2RasterImageBench() {
16 fName.set("gpu2raster_image");
17 }
18
19 bool isSuitableFor(Backend backend) override {
20 return kGPU_Backend == backend;
21 }
22
23 protected:
24 const char* onGetName() override {
25 return fName.c_str();
26 }
27
28 void onPerCanvasPreDraw(SkCanvas* canvas) override {
29 // create a gpu-backed Image
30 SkImageInfo info = SkImageInfo::MakeN32Premul(500, 500);
31 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
32 canvas->drawColor(SK_ColorRED);
33 fGpuImage.reset(surface->newImageSnapshot());
34
35 // create a cpu-backed Surface
36 fRasterSurface.reset(SkSurface::NewRaster(info));
37 }
38
39 void onDraw(const int loops, SkCanvas*) override {
40 // Time drawing a gpu-image into a raster-surface
41 for (int i = 0; i < loops; i++) {
42 for (int inner = 0; inner < 10; ++inner) {
43 fRasterSurface->getCanvas()->drawImage(fGpuImage, 0, 0);
44 }
45 }
46 }
47
48 private:
49 SkString fName;
50 SkAutoTUnref<SkImage> fGpuImage;
51 SkAutoTUnref<SkSurface> fRasterSurface;
52
53 typedef Benchmark INHERITED;
54 };
55
56
57 DEF_BENCH( return new GPU2RasterImageBench; )
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698