2016-05-13 18:40:07 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkPictureAnalyzer_DEFINED
|
|
|
|
#define SkPictureAnalyzer_DEFINED
|
|
|
|
|
2016-09-20 15:42:38 +00:00
|
|
|
#include "SkCanvas.h"
|
2016-05-13 18:40:07 +00:00
|
|
|
#include "SkRefCnt.h"
|
2016-05-25 18:31:04 +00:00
|
|
|
#include "SkRegion.h"
|
2016-05-13 18:40:07 +00:00
|
|
|
#include "SkTypes.h"
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
#include "GrContext.h"
|
|
|
|
|
2016-05-25 18:31:04 +00:00
|
|
|
class SkPath;
|
2016-05-13 18:40:07 +00:00
|
|
|
class SkPicture;
|
|
|
|
|
|
|
|
/** \class SkPictureGpuAnalyzer
|
|
|
|
|
|
|
|
Gathers GPU-related statistics for one or more SkPictures.
|
|
|
|
*/
|
|
|
|
class SK_API SkPictureGpuAnalyzer final : public SkNoncopyable {
|
|
|
|
public:
|
|
|
|
explicit SkPictureGpuAnalyzer(sk_sp<GrContextThreadSafeProxy> = nullptr);
|
|
|
|
explicit SkPictureGpuAnalyzer(const sk_sp<SkPicture>& picture,
|
|
|
|
sk_sp<GrContextThreadSafeProxy> = nullptr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process the given picture and accumulate its stats.
|
|
|
|
*/
|
2016-05-25 18:31:04 +00:00
|
|
|
void analyzePicture(const SkPicture*);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process an explicit clipPath op.
|
|
|
|
*/
|
2016-09-20 15:42:38 +00:00
|
|
|
void analyzeClipPath(const SkPath&, SkCanvas::ClipOp, bool doAntiAlias);
|
2016-05-13 18:40:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset all accumulated stats.
|
|
|
|
*/
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the analyzed pictures are suitable for rendering on the GPU.
|
|
|
|
*/
|
|
|
|
bool suitableForGpuRasterization(const char** whyNot = nullptr) const;
|
|
|
|
|
2016-06-09 19:43:30 +00:00
|
|
|
/**
|
|
|
|
* Returns the number of commands which are slow to draw on the GPU, capped at the predicate
|
|
|
|
* max.
|
|
|
|
*/
|
|
|
|
uint32_t numSlowGpuCommands() { return fNumSlowPaths; }
|
|
|
|
|
2016-05-13 18:40:07 +00:00
|
|
|
private:
|
|
|
|
uint32_t fNumSlowPaths;
|
|
|
|
|
|
|
|
typedef SkNoncopyable INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SK_SUPPORT_GPU
|
|
|
|
|
|
|
|
#endif // SkPictureAnalyzer_DEFINED
|