diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-30 18:20:12 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-30 18:20:12 +0000 |
commit | 58b21ec7f06cfa8b7d7403a6108c0216345b3510 (patch) | |
tree | 1c98cf3d096708a4d2fce406b6daf6c9e1e4403f /src/image/SkImage_Picture.cpp | |
parent | c9062047cea66575868270b4dcaeb1dab113c8a7 (diff) |
expand internal subclasses into separate files
git-svn-id: http://skia.googlecode.com/svn/trunk@4836 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/image/SkImage_Picture.cpp')
-rw-r--r-- | src/image/SkImage_Picture.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/image/SkImage_Picture.cpp b/src/image/SkImage_Picture.cpp new file mode 100644 index 0000000000..c93c06fab5 --- /dev/null +++ b/src/image/SkImage_Picture.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2012 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkImage_Base.h" +#include "SkImagePriv.h" +#include "SkPicture.h" + +class SkImage_Picture : public SkImage_Base { +public: + SkImage_Picture(SkPicture*); + virtual ~SkImage_Picture(); + + virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) SK_OVERRIDE; + +private: + SkPicture* fPicture; + + typedef SkImage_Base INHERITED; +}; + +/////////////////////////////////////////////////////////////////////////////// + +SkImage_Picture::SkImage_Picture(SkPicture* pict) : INHERITED(pict->width(), pict->height()) { + pict->endRecording(); + pict->ref(); + fPicture = pict; +} + +SkImage_Picture::~SkImage_Picture() { + fPicture->unref(); +} + +void SkImage_Picture::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, + const SkPaint* paint) { + SkImagePrivDrawPicture(canvas, fPicture, x, y, paint); +} + +SkImage* SkNewImageFromPicture(SkPicture* pict) { + return SkNEW_ARGS(SkImage_Picture, (pict)); +} + |