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

Side by Side Diff: bench/DeferredSurfaceCopyBench.cpp

Issue 1269093002: remove SkDeferredCanvas (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 | dm/DM.cpp » ('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 #include "Benchmark.h"
10 #include "SkDeferredCanvas.h"
11 #include "SkDevice.h"
12 #include "SkImage.h"
13 #include "SkSurface.h"
14 #if SK_SUPPORT_GPU
15 #include "GrRenderTarget.h"
16 #endif
17
18 class DeferredSurfaceCopyBench : public Benchmark {
19 enum {
20 kSurfaceWidth = 1000,
21 kSurfaceHeight = 1000,
22 };
23 public:
24 DeferredSurfaceCopyBench(bool discardableContents) {
25 fDiscardableContents = discardableContents;
26 }
27
28 protected:
29 const char* onGetName() override {
30 return fDiscardableContents ? "DeferredSurfaceCopy_discardable" :
31 "DeferredSurfaceCopy_nonDiscardable";
32 }
33
34 void onDraw(const int loops, SkCanvas* canvas) override {
35 // The canvas is not actually used for this test except to provide
36 // configuration information: gpu, multisampling, size, etc?
37 SkImageInfo info = SkImageInfo::MakeN32Premul(kSurfaceWidth, kSurfaceHei ght);
38 const SkRect fullCanvasRect = SkRect::MakeWH(
39 SkIntToScalar(kSurfaceWidth), SkIntToScalar(kSurfaceHeight));
40 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
41
42 // newSurface() can return NULL for several reasons, so we need to check
43 if (NULL == surface.get()) {
44 SkDebugf("DeferredSurfaceCopyBench newSurface failed, bench results are meaningless\n");
45 return; // should we signal the caller that we hit an error?
46 }
47
48 SkAutoTUnref<SkDeferredCanvas> drawingCanvas(SkDeferredCanvas::Create(su rface));
49
50 for (int iteration = 0; iteration < loops; iteration++) {
51 drawingCanvas->clear(0);
52 SkAutoTUnref<SkImage> image(drawingCanvas->newImageSnapshot());
53 SkPaint paint;
54 if (!fDiscardableContents) {
55 // If paint is not opaque, prior canvas contents are
56 // not discardable because they are needed for compositing.
57 paint.setAlpha(127);
58 }
59 drawingCanvas->drawRect(fullCanvasRect, paint);
60 // Trigger copy on write, which should be faster in the discardable case.
61 drawingCanvas->flush();
62 }
63 }
64
65 private:
66 bool fDiscardableContents;
67
68 typedef Benchmark INHERITED;
69 };
70
71 //////////////////////////////////////////////////////////////////////////////
72
73 DEF_BENCH( return new DeferredSurfaceCopyBench(false); )
74 DEF_BENCH( return new DeferredSurfaceCopyBench(true); )
OLDNEW
« no previous file with comments | « no previous file | dm/DM.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698