Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: src/image/SkImage_Picture.cpp

Issue 233943002: remove picture-backed surfaces (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/image/SkImagePriv.h ('k') | src/image/SkSurface_Picture.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 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
8 #include "SkImage_Base.h"
9 #include "SkImagePriv.h"
10 #include "SkPicture.h"
11
12 class SkImage_Picture : public SkImage_Base {
13 public:
14 SkImage_Picture(SkPicture*);
15 virtual ~SkImage_Picture();
16
17 virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) SK_OVERRI DE;
18 virtual void onDrawRectToRect(SkCanvas*, const SkRect*, const SkRect&, const SkPaint*) SK_OVERRIDE;
19
20 SkPicture* getPicture() { return fPicture; }
21
22 private:
23 SkPicture* fPicture;
24
25 typedef SkImage_Base INHERITED;
26 };
27
28 ///////////////////////////////////////////////////////////////////////////////
29
30 SkImage_Picture::SkImage_Picture(SkPicture* pict) : INHERITED(pict->width(), pic t->height()) {
31 pict->endRecording();
32 pict->ref();
33 fPicture = pict;
34 }
35
36 SkImage_Picture::~SkImage_Picture() {
37 fPicture->unref();
38 }
39
40 void SkImage_Picture::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y,
41 const SkPaint* paint) {
42 SkImagePrivDrawPicture(canvas, fPicture, x, y, paint);
43 }
44
45 void SkImage_Picture::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, cons t SkRect& dst,
46 const SkPaint* paint) {
47 SkImagePrivDrawPicture(canvas, fPicture, src, dst, paint);
48 }
49
50 SkImage* SkNewImageFromPicture(const SkPicture* srcPicture) {
51 /**
52 * We want to snapshot the playback status of the picture, w/o affecting
53 * its ability to continue recording (if needed).
54 *
55 * Optimally this will shared as much data/buffers as it can with
56 * srcPicture, and srcPicture will perform a copy-on-write as needed if it
57 * needs to mutate them later on.
58 */
59 SkAutoTUnref<SkPicture> playback(SkNEW_ARGS(SkPicture, (*srcPicture)));
60
61 return SkNEW_ARGS(SkImage_Picture, (playback));
62 }
63
64 SkPicture* SkPictureImageGetPicture(SkImage* pictureImage) {
65 return static_cast<SkImage_Picture*>(pictureImage)->getPicture();
66 }
OLDNEW
« no previous file with comments | « src/image/SkImagePriv.h ('k') | src/image/SkSurface_Picture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698