OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkSurface_Base.h" | 8 #include "SkSurface_Base.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkImagePriv.h" | 10 #include "SkImagePriv.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 return SkSurface::NewPicture(info.fWidth, info.fHeight); | 55 return SkSurface::NewPicture(info.fWidth, info.fHeight); |
56 } | 56 } |
57 | 57 |
58 SkImage* SkSurface_Picture::onNewImageSnapshot() { | 58 SkImage* SkSurface_Picture::onNewImageSnapshot() { |
59 if (fPicture) { | 59 if (fPicture) { |
60 return SkNewImageFromPicture(fPicture); | 60 return SkNewImageFromPicture(fPicture); |
61 } else { | 61 } else { |
62 SkImage::Info info; | 62 SkImage::Info info; |
63 info.fWidth = info.fHeight = 0; | 63 info.fWidth = info.fHeight = 0; |
64 info.fColorType = SkImage::kPMColor_ColorType; | 64 info.fColorType = SkImage::kPMColor_ColorType; |
65 info.fAlphaType = SkImage::kOpaque_AlphaType; | 65 info.fAlphaType = kOpaque_SkAlphaType; |
66 return SkImage::NewRasterCopy(info, NULL, 0); | 66 return SkImage::NewRasterCopy(info, NULL, 0); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 void SkSurface_Picture::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, | 70 void SkSurface_Picture::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, |
71 const SkPaint* paint) { | 71 const SkPaint* paint) { |
72 if (!fPicture) { | 72 if (!fPicture) { |
73 return; | 73 return; |
74 } | 74 } |
75 SkImagePrivDrawPicture(canvas, fPicture, x, y, paint); | 75 SkImagePrivDrawPicture(canvas, fPicture, x, y, paint); |
76 } | 76 } |
77 | 77 |
78 void SkSurface_Picture::onCopyOnWrite(ContentChangeMode /*mode*/) { | 78 void SkSurface_Picture::onCopyOnWrite(ContentChangeMode /*mode*/) { |
79 // We always spawn a copy of the recording picture when we | 79 // We always spawn a copy of the recording picture when we |
80 // are asked for a snapshot, so we never need to do anything here. | 80 // are asked for a snapshot, so we never need to do anything here. |
81 } | 81 } |
82 | 82 |
83 /////////////////////////////////////////////////////////////////////////////// | 83 /////////////////////////////////////////////////////////////////////////////// |
84 | 84 |
85 | 85 |
86 SkSurface* SkSurface::NewPicture(int width, int height) { | 86 SkSurface* SkSurface::NewPicture(int width, int height) { |
87 if ((width | height) < 0) { | 87 if ((width | height) < 0) { |
88 return NULL; | 88 return NULL; |
89 } | 89 } |
90 | 90 |
91 return SkNEW_ARGS(SkSurface_Picture, (width, height)); | 91 return SkNEW_ARGS(SkSurface_Picture, (width, height)); |
92 } | 92 } |
OLD | NEW |