summaryrefslogtreecommitdiffstats
path: root/chromium/skia/ext/analysis_canvas.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/skia/ext/analysis_canvas.h')
-rw-r--r--chromium/skia/ext/analysis_canvas.h209
1 files changed, 84 insertions, 125 deletions
diff --git a/chromium/skia/ext/analysis_canvas.h b/chromium/skia/ext/analysis_canvas.h
index 909a19826d8..b3e5275c043 100644
--- a/chromium/skia/ext/analysis_canvas.h
+++ b/chromium/skia/ext/analysis_canvas.h
@@ -6,156 +6,115 @@
#define SKIA_EXT_ANALYSIS_CANVAS_H_
#include "base/compiler_specific.h"
-#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPicture.h"
namespace skia {
-class AnalysisDevice;
-
// 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.
-// To use: create a SkBitmap with kNo_Config, create an AnalysisDevice
-// using that bitmap, and create an AnalysisCanvas using the device.
-// Play a picture into the canvas, and then check result.
+// To use: play a picture into the canvas, and then check result.
class SK_API AnalysisCanvas : public SkCanvas, public SkDrawPictureCallback {
public:
- AnalysisCanvas(AnalysisDevice*);
+ AnalysisCanvas(int width, int height);
virtual ~AnalysisCanvas();
// Returns true when a SkColor can be used to represent result.
bool GetColorIfSolid(SkColor* color) const;
bool HasText() const;
+ void SetForceNotSolid(bool flag);
+ void SetForceNotTransparent(bool flag);
+
// SkDrawPictureCallback override.
virtual bool abortDrawing() OVERRIDE;
// SkCanvas overrides.
- virtual bool clipRect(const SkRect& rect,
- SkRegion::Op op = SkRegion::kIntersect_Op,
- bool do_anti_alias = false) OVERRIDE;
- virtual bool clipPath(const SkPath& path,
- SkRegion::Op op = SkRegion::kIntersect_Op,
- bool do_anti_alias = false) OVERRIDE;
- virtual bool clipRRect(const SkRRect& rrect,
- SkRegion::Op op = SkRegion::kIntersect_Op,
- bool do_anti_alias = false) OVERRIDE;
-
- virtual int saveLayer(const SkRect* bounds,
- const SkPaint* paint,
- SkCanvas::SaveFlags flags) OVERRIDE;
- virtual int save(SaveFlags flags = kMatrixClip_SaveFlag) OVERRIDE;
-
- virtual void restore() OVERRIDE;
-
- private:
- typedef SkCanvas INHERITED;
-
- int saved_stack_size_;
- int force_not_solid_stack_level_;
- int force_not_transparent_stack_level_;
-};
-
-// TODO(robertphillips): Once Skia's SkBaseDevice API is refactored to
-// remove the bitmap-specific entry points, it might make sense for this
-// to be derived from SkBaseDevice (rather than SkBitmapDevice)
-class SK_API AnalysisDevice : public SkBitmapDevice {
- public:
- AnalysisDevice(const SkBitmap& bitmap);
- virtual ~AnalysisDevice();
-
- bool GetColorIfSolid(SkColor* color) const;
- bool HasText() const;
-
- void SetForceNotSolid(bool flag);
- void SetForceNotTransparent(bool flag);
-
- protected:
- // SkBaseDevice overrides.
- virtual void clear(SkColor color) OVERRIDE;
- virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE;
- virtual void drawPoints(const SkDraw& draw,
- SkCanvas::PointMode mode,
+ virtual void clear(SkColor) OVERRIDE;
+ virtual void drawPaint(const SkPaint& paint) OVERRIDE;
+ virtual void drawPoints(PointMode,
size_t count,
- const SkPoint points[],
- const SkPaint& paint) OVERRIDE;
- virtual void drawRect(const SkDraw& draw,
- const SkRect& rect,
- const SkPaint& paint) OVERRIDE;
- virtual void drawRRect(const SkDraw& draw,
- const SkRRect& rr,
- const SkPaint& paint) OVERRIDE;
- virtual void drawOval(const SkDraw& draw,
- const SkRect& oval,
- const SkPaint& paint) OVERRIDE;
- virtual void drawPath(const SkDraw& draw,
- const SkPath& path,
- const SkPaint& paint,
- const SkMatrix* pre_path_matrix = NULL,
- bool path_is_mutable = false) OVERRIDE;
- virtual void drawBitmap(const SkDraw& draw,
- const SkBitmap& bitmap,
- const SkMatrix& matrix,
- const SkPaint& paint) OVERRIDE;
- virtual void drawSprite(const SkDraw& draw,
- const SkBitmap& bitmap,
- int x,
- int y,
- const SkPaint& paint) OVERRIDE;
- virtual void drawBitmapRect(const SkDraw& draw,
- const SkBitmap& bitmap,
- const SkRect* src_or_null,
+ const SkPoint pts[],
+ const SkPaint&) OVERRIDE;
+ virtual void drawOval(const SkRect&, const SkPaint&) OVERRIDE;
+ virtual void drawRect(const SkRect&, const SkPaint&) OVERRIDE;
+ virtual void drawRRect(const SkRRect&, const SkPaint&) OVERRIDE;
+ virtual void drawPath(const SkPath& path, const SkPaint&) OVERRIDE;
+ virtual void drawBitmap(const SkBitmap&,
+ SkScalar left,
+ SkScalar top,
+ const SkPaint* paint = NULL) OVERRIDE;
+ virtual void drawBitmapRectToRect(const SkBitmap&,
+ const SkRect* src,
+ const SkRect& dst,
+ const SkPaint* paint,
+ DrawBitmapRectFlags flags) OVERRIDE;
+ virtual void drawBitmapMatrix(const SkBitmap&,
+ const SkMatrix&,
+ const SkPaint* paint = NULL) OVERRIDE;
+ virtual void drawBitmapNine(const SkBitmap& bitmap,
+ const SkIRect& center,
const SkRect& dst,
- const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags) OVERRIDE;
- virtual void drawText(const SkDraw& draw,
- const void* text,
- size_t len,
- SkScalar x,
- SkScalar y,
- const SkPaint& paint) OVERRIDE;
- virtual void drawPosText(const SkDraw& draw,
- const void* text,
- size_t len,
- const SkScalar pos[],
- SkScalar const_y,
- int scalars_per_pos,
- const SkPaint& paint) OVERRIDE;
- virtual void drawTextOnPath(const SkDraw& draw,
- const void* text,
- size_t len,
- const SkPath& path,
- const SkMatrix* matrix,
- const SkPaint& paint) OVERRIDE;
-#ifdef SK_BUILD_FOR_ANDROID
- virtual void drawPosTextOnPath(const SkDraw& draw,
- const void* text,
- size_t len,
- const SkPoint pos[],
- const SkPaint& paint,
- const SkPath& path,
- const SkMatrix* matrix) OVERRIDE;
-#endif
- virtual void drawVertices(const SkDraw& draw,
- SkCanvas::VertexMode vertex_mode,
- int vertex_count,
- const SkPoint verts[],
+ const SkPaint* paint = NULL) OVERRIDE;
+ virtual void drawSprite(const SkBitmap&, int left, int top,
+ const SkPaint* paint = NULL) OVERRIDE;
+ virtual void drawVertices(VertexMode,
+ int vertexCount,
+ const SkPoint vertices[],
const SkPoint texs[],
const SkColor colors[],
- SkXfermode* xmode,
+ SkXfermode*,
const uint16_t indices[],
- int index_count,
- const SkPaint& paint) OVERRIDE;
- virtual void drawDevice(const SkDraw& draw,
- SkBaseDevice* device,
- int x,
- int y,
- const SkPaint& paint) OVERRIDE;
-
- private:
- typedef SkBitmapDevice INHERITED;
+ int indexCount,
+ const SkPaint&) OVERRIDE;
+
+ protected:
+ virtual void willSave() OVERRIDE;
+ virtual SaveLayerStrategy willSaveLayer(const SkRect*,
+ const SkPaint*,
+ SaveFlags) OVERRIDE;
+ virtual void willRestore() OVERRIDE;
+
+ virtual void onClipRect(const SkRect& rect,
+ SkRegion::Op op,
+ ClipEdgeStyle edge_style) OVERRIDE;
+ virtual void onClipRRect(const SkRRect& rrect,
+ SkRegion::Op op,
+ ClipEdgeStyle edge_style) OVERRIDE;
+ virtual void onClipPath(const SkPath& path,
+ SkRegion::Op op,
+ ClipEdgeStyle edge_style) OVERRIDE;
+
+ virtual void onDrawText(const void* text,
+ size_t byteLength,
+ SkScalar x,
+ SkScalar y,
+ const SkPaint&) OVERRIDE;
+ virtual void onDrawPosText(const void* text,
+ size_t byteLength,
+ const SkPoint pos[],
+ const SkPaint&) OVERRIDE;
+ virtual void onDrawPosTextH(const void* text,
+ size_t byteLength,
+ const SkScalar xpos[],
+ SkScalar constY,
+ const SkPaint&) OVERRIDE;
+ virtual void onDrawTextOnPath(const void* text,
+ size_t byteLength,
+ const SkPath& path,
+ const SkMatrix* matrix,
+ const SkPaint&) OVERRIDE;
+ virtual void onDrawDRRect(const SkRRect& outer,
+ const SkRRect& inner,
+ const SkPaint&) OVERRIDE;
+
+private:
+ typedef SkCanvas INHERITED;
+
+ int saved_stack_size_;
+ int force_not_solid_stack_level_;
+ int force_not_transparent_stack_level_;
bool is_forced_not_solid_;
bool is_forced_not_transparent_;