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

Side by Side Diff: bench/DeferredSurfaceCopyBench.cpp

Issue 14297008: Benchmark to measure SkSurface copy on write performance (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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') | 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 /*
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 #if SK_SUPPORT_GPU
10 #include "GrRenderTarget.h"
11 #endif
12 #include "SkBenchmark.h"
13 #include "SkDeferredCanvas.h"
14 #include "SkDevice.h"
15 #include "SkImage.h"
16 #include "SkSurface.h"
17
18 class DeferredSurfaceCopyBench : public SkBenchmark {
19 enum {
20 N = SkBENCHLOOP(25),
21 };
22 public:
23 DeferredSurfaceCopyBench(void* param, bool discardableContents) : SkBenchmar k(param) {
24 fDiscardableContents = discardableContents;
25
26 }
27
28 protected:
29 virtual const char* onGetName() SK_OVERRIDE {
30 return fDiscardableContents ? "DeferredSurfaceCopy_discardable" :
31 "DeferredSurfaceCopy_nonDiscardable";
32 }
33
34 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
35 // The canvas is not actually used for this test except to provide
36 // configuration information: gpu, multisampling, size, etc?
37 SkDevice *referenceDevice = canvas->getDevice();
38 SkImage::Info info;
39 info.fWidth = referenceDevice->width();
reed1 2013/04/16 20:37:24 Is it important to match this size? Seems like the
Justin Novosad 2013/04/16 20:50:48 Done.
40 info.fHeight = referenceDevice->height();
41 info.fColorType = SkImage::kPMColor_ColorType;
42 info.fAlphaType = SkImage::kPremul_AlphaType;
43 SkSurface *surface;
44 #if SK_SUPPORT_GPU
45 GrRenderTarget* rt = reinterpret_cast<GrRenderTarget*>(referenceDevice-> accessRenderTarget());
46 if (NULL != rt) {
47 surface = SkSurface::NewRenderTarget(rt->getContext(), info, rt->num Samples());
48 } else
49 #endif
50 {
51 surface = SkSurface::NewRaster(info);
52 }
53 SkDeferredCanvas drawingCanvas(surface);
54 surface->unref();
55
56 for (int iteration = 0; iteration < N; iteration++) {
57 drawingCanvas.clear(0);
58 SkImage* image = drawingCanvas.newImageSnapshot();
reed1 2013/04/16 20:37:24 I think you can collaps these two lines down to ju
Justin Novosad 2013/04/16 20:50:48 Done.
59 SkAutoTUnref<SkImage> aur(image);
60 SkPaint paint;
61 if (!fDiscardableContents) {
62 // If paint is not opaque, prior canvas contents are
63 // not discardable because they are needed for compositing.
64 paint.setAlpha(127);
65 }
66 drawingCanvas.drawPaint(paint);
reed1 2013/04/16 20:37:24 this is a non-trival call, in terms of time, if th
Justin Novosad 2013/04/16 20:50:48 To make contents recognized as discardable I need
67 // Trigger copy on write, which should be faster in the discardable case.
68 drawingCanvas.flush();
69 }
70 }
71
72 private:
73 bool fDiscardableContents;
74
75 typedef SkBenchmark INHERITED;
76 };
77
78 //////////////////////////////////////////////////////////////////////////////
79
80 static SkBenchmark* Fact0(void* p) { return new DeferredSurfaceCopyBench(p, fals e); }
81 static SkBenchmark* Fact1(void* p) { return new DeferredSurfaceCopyBench(p, true ); }
82
83 static BenchRegistry gReg0(Fact0);
84 static BenchRegistry gReg1(Fact1);
OLDNEW
« 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