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: tools/VisualBench/WrappedBenchmark.h

Issue 1906573003: Revert of Hide SkCanvas::LayerIter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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
« no previous file with comments | « tests/CanvasTest.cpp ('k') | 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
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef WrappedBenchmark_DEFINED 8 #ifndef WrappedBenchmark_DEFINED
9 #define WrappedBenchmark_DEFINED 9 #define WrappedBenchmark_DEFINED
10 10
11 #include "Benchmark.h" 11 #include "Benchmark.h"
12 #include "SkDevice.h"
12 #include "SkSurface.h" 13 #include "SkSurface.h"
13 #include "GrContext.h" 14 #include "GrContext.h"
14 #include "GrRenderTarget.h" 15 #include "GrRenderTarget.h"
15 16
16 // Wrap some other benchmark to allow specialization to either 17 // Wrap some other benchmark to allow specialization to either
17 // cpu or gpu backends. The derived class will override 'setupOffScreen' 18 // cpu or gpu backends. The derived class will override 'setupOffScreen'
18 // to create an offscreen surface in which the actual rendering will occur. 19 // to create an offscreen surface in which the actual rendering will occur.
19 class WrappedBenchmark : public Benchmark { 20 class WrappedBenchmark : public Benchmark {
20 public: 21 public:
21 // Takes ownership of caller's ref on `bench`. 22 // Takes ownership of caller's ref on `bench`.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void setupOffScreen(SkCanvas* canvas) override { 106 void setupOffScreen(SkCanvas* canvas) override {
106 fOffScreen = SkSurface::MakeRenderTarget(canvas->getGrContext(), 107 fOffScreen = SkSurface::MakeRenderTarget(canvas->getGrContext(),
107 SkBudgeted::kNo, 108 SkBudgeted::kNo,
108 canvas->imageInfo(), 109 canvas->imageInfo(),
109 fNumSamples, 110 fNumSamples,
110 &this->surfaceProps()); 111 &this->surfaceProps());
111 } 112 }
112 113
113 void onBlitToScreen(SkCanvas* canvas, int w, int h) override { 114 void onBlitToScreen(SkCanvas* canvas, int w, int h) override {
114 // We call copySurface directly on the underlying GPU surfaces for a mor e efficient blit. 115 // We call copySurface directly on the underlying GPU surfaces for a mor e efficient blit.
115 GrRenderTarget* dst = canvas->internal_private_accessTopLayerRenderTarge t(); 116 GrRenderTarget* dst, *src;
116 SkASSERT(dst);
117 117
118 GrRenderTarget* src = fOffScreen->getCanvas()->internal_private_accessTo pLayerRenderTarget(); 118 SkCanvas::LayerIter canvasIter(canvas, false);
119 SkASSERT(src); 119 SkAssertResult((dst = canvasIter.device()->accessRenderTarget()));
120
121 SkCanvas::LayerIter offscreenIter(fOffScreen->getCanvas(), false);
122 SkAssertResult((src = offscreenIter.device()->accessRenderTarget()));
120 123
121 SkASSERT(dst->getContext() == src->getContext()); 124 SkASSERT(dst->getContext() == src->getContext());
122 125
123 dst->getContext()->copySurface(dst, src, SkIRect::MakeWH(w, h), SkIPoint ::Make(0, 0)); 126 dst->getContext()->copySurface(dst, src, SkIRect::MakeWH(w, h), SkIPoint ::Make(0, 0));
127
128 #ifdef SK_DEBUG
129 // This method should not be called while layers are saved.
130 canvasIter.next();
131 SkASSERT(canvasIter.done());
132
133 offscreenIter.next();
134 SkASSERT(offscreenIter.done());
135 #endif
124 } 136 }
125 137
126 int fNumSamples; 138 int fNumSamples;
127 typedef WrappedBenchmark INHERITED; 139 typedef WrappedBenchmark INHERITED;
128 }; 140 };
129 141
130 #endif //WrappedBenchmark_DEFINED 142 #endif //WrappedBenchmark_DEFINED
OLDNEW
« no previous file with comments | « tests/CanvasTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698