Flutter Engine
The Flutter Engine
RecordingBench.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2014 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
9
11#include "include/core/SkData.h"
13
15 // Flatten the source picture in case it's trivially nested (useless for timing).
17 pic->playback(rec.beginRecording(pic->cullRect(), nullptr /*,
18 SkPictureRecorder::kPlaybackDrawPicture_RecordFlag*/));
20}
21
23 return fName.c_str();
24}
25
28}
29
33}
34
35///////////////////////////////////////////////////////////////////////////////////////////////////
36
37RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useBBH)
38 : INHERITED(name, pic)
39 , fUseBBH(useBBH)
40{}
41
43 SkRTreeFactory factory;
44 SkPictureRecorder recorder;
45 while (loops --> 0) {
46 fSrc->playback(recorder.beginRecording(fSrc->cullRect(), fUseBBH ? &factory : nullptr));
47 (void)recorder.finishRecordingAsPicture();
48 }
49}
50
51///////////////////////////////////////////////////////////////////////////////////////////////////
53
55 : fName(name)
56 , fEncodedPicture(std::move(data))
57{}
58
60 return fName.c_str();
61}
62
65}
66
68 return SkISize::Make(128, 128);
69}
70
72 for (int i = 0; i < loops; ++i) {
73 SkPicture::MakeFromData(fEncodedPicture.get());
74 }
75}
const char * backend
const char * fName
#define SkScalarCeilToInt(x)
Definition: SkScalar.h:36
const char * onGetName() override
SkISize onGetSize() override
DeserializePictureBench(const char *name, sk_sp< SkData > encodedPicture)
void onDraw(int loops, SkCanvas *) override
bool isSuitableFor(Backend) override
SkISize onGetSize() override
sk_sp< const SkPicture > fSrc
PictureCentricBench(const char *name, const SkPicture *)
const char * onGetName() override
bool isSuitableFor(Backend) override
RecordingBench(const char *name, const SkPicture *, bool useBBH)
void onDraw(int loops, SkCanvas *) override
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
virtual SkRect cullRect() const =0
static sk_sp< SkPicture > MakeFromData(const SkData *data, const SkDeserialProcs *procs=nullptr)
Definition: SkPicture.cpp:160
virtual void playback(SkCanvas *canvas, AbortCallback *callback=nullptr) const =0
const char * c_str() const
Definition: SkString.h:133
T * get() const
Definition: SkRefCnt.h:303
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
Definition: ref_ptr.h:256
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63