| Index: skia/ext/analysis_canvas.h
|
| diff --git a/skia/ext/analysis_canvas.h b/skia/ext/analysis_canvas.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..983c0df7d3c377a78c44c9487db8c20a3058d6ff
|
| --- /dev/null
|
| +++ b/skia/ext/analysis_canvas.h
|
| @@ -0,0 +1,87 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef SKIA_EXT_ANALYSIS_CANVAS_H_
|
| +#define SKIA_EXT_ANALYSIS_CANVAS_H_
|
| +
|
| +#include "third_party/skia/include/core/SkCanvas.h"
|
| +#include "third_party/skia/include/core/SkDevice.h"
|
| +
|
| +namespace skia {
|
| +
|
| +class SK_API AnalysisDevice : public SkDevice {
|
| + public:
|
| + AnalysisDevice(const SkBitmap& bm);
|
| +};
|
| +
|
| +// Does not render anything, but gathers statistics about a region
|
| +// (specified as a clip rectangle) of an SkPicture as the picture is
|
| +// played back through it.
|
| +class SK_API AnalysisCanvas : public SkCanvas {
|
| + public:
|
| + AnalysisCanvas(SkDevice*, SkRect clip);
|
| + virtual ~AnalysisCanvas();
|
| +
|
| + virtual int save(SkCanvas::SaveFlags = kMatrixClip_SaveFlag) SK_OVERRIDE;
|
| + virtual int saveLayer(const SkRect*, const SkPaint*,
|
| + SkCanvas::SaveFlags = kARGB_ClipLayer_SaveFlag)
|
| + SK_OVERRIDE;
|
| + virtual void restore() SK_OVERRIDE;
|
| + virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE;
|
| + virtual bool clipRRect(const SkRRect&, SkRegion::Op, bool) SK_OVERRIDE;
|
| + virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE;
|
| + virtual bool clipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
|
| + virtual void clear(SkColor) SK_OVERRIDE;
|
| + virtual void drawPaint(const SkPaint&) SK_OVERRIDE;
|
| + virtual void drawPoints(PointMode, size_t, const SkPoint [],
|
| + const SkPaint&) SK_OVERRIDE;
|
| + virtual void drawRect(const SkRect&, const SkPaint&) SK_OVERRIDE;
|
| + virtual void drawOval(const SkRect&, const SkPaint&) SK_OVERRIDE;
|
| + virtual void drawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE;
|
| + virtual void drawPath(const SkPath&, const SkPaint&) SK_OVERRIDE;
|
| + virtual void drawBitmap(const SkBitmap&, SkScalar, SkScalar,
|
| + const SkPaint&) SK_OVERRIDE;
|
| + virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect*,
|
| + const SkRect&, const SkPaint* = NULL)
|
| + SK_OVERRIDE;
|
| + virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&,
|
| + const SkPaint* = NULL) SK_OVERRIDE;
|
| + virtual void drawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&,
|
| + const SkPaint* = NULL) SK_OVERRIDE;
|
| + virtual void drawSprite(const SkBitmap&, int left, int top,
|
| + const SkPaint* = NULL) SK_OVERRIDE;
|
| + virtual void drawText(const void*, size_t, SkScalar, SkScalar,
|
| + const SkPaint&) SK_OVERRIDE;
|
| + virtual void drawPosText(const void*, size_t, const SkPoint [],
|
| + const SkPaint&) SK_OVERRIDE;
|
| + virtual void drawPosTextH(const void*, size_t, const SkScalar [], SkScalar,
|
| + const SkPaint&) SK_OVERRIDE;
|
| + virtual void drawTextOnPath(const void*, size_t, const SkPath&,
|
| + const SkMatrix*, const SkPaint&) SK_OVERRIDE;
|
| + virtual void drawVertices(VertexMode, int, const SkPoint [],
|
| + const SkPoint [], const SkColor [], SkXfermode*,
|
| + const uint16_t [], int, const SkPaint&) SK_OVERRIDE;
|
| + virtual void drawData(const void*, size_t) SK_OVERRIDE;
|
| +
|
| + // Returns true if the estimated cost of drawing is below an
|
| + // arbitrary threshold.
|
| + bool isCheap() const;
|
| +
|
| + // Returns the estimated cost of drawing, in arbitrary units.
|
| + int getEstimatedCost() const;
|
| +
|
| + // Resets the clip and the cost estimate.
|
| + void reset(SkRect clip);
|
| +
|
| + protected:
|
| +
|
| + int estimatedCost_;
|
| + SkRect clip_;
|
| +
|
| +};
|
| +
|
| +} // namespace skia
|
| +
|
| +#endif // SKIA_EXT_ANALYSIS_CANVAS_H_
|
| +
|
|
|