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 "SkImagePriv.h" | 9 #include "SkImagePriv.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 | 11 |
| 12 SkSurfaceProps::SkSurfaceProps() |
| 13 : fOrigin(SkIPoint::Make(0, 0)), fDisallowFlags(0), fPixelGeometry(kLegacyLC
D_SkPixelGeometry) |
| 14 {} |
| 15 |
| 16 SkSurfaceProps::SkSurfaceProps(int x, int y, uint32_t flags, SkPixelGeometry pg) |
| 17 : fOrigin(SkIPoint::Make(x, y)), fDisallowFlags(flags), fPixelGeometry(pg) |
| 18 {} |
| 19 |
12 /////////////////////////////////////////////////////////////////////////////// | 20 /////////////////////////////////////////////////////////////////////////////// |
13 | 21 |
14 SkSurface_Base::SkSurface_Base(int width, int height) : INHERITED(width, height)
{ | 22 SkSurface_Base::SkSurface_Base(int width, int height, const Props& props) |
| 23 : INHERITED(width, height, props) |
| 24 { |
15 fCachedCanvas = NULL; | 25 fCachedCanvas = NULL; |
16 fCachedImage = NULL; | 26 fCachedImage = NULL; |
17 } | 27 } |
18 | 28 |
19 SkSurface_Base::SkSurface_Base(const SkImageInfo& info) : INHERITED(info) { | 29 SkSurface_Base::SkSurface_Base(const SkImageInfo& info, const Props& props) |
| 30 : INHERITED(info, props) |
| 31 { |
20 fCachedCanvas = NULL; | 32 fCachedCanvas = NULL; |
21 fCachedImage = NULL; | 33 fCachedImage = NULL; |
22 } | 34 } |
23 | 35 |
24 SkSurface_Base::~SkSurface_Base() { | 36 SkSurface_Base::~SkSurface_Base() { |
25 // in case the canvas outsurvives us, we null the callback | 37 // in case the canvas outsurvives us, we null the callback |
26 if (fCachedCanvas) { | 38 if (fCachedCanvas) { |
27 fCachedCanvas->setSurfaceBase(NULL); | 39 fCachedCanvas->setSurfaceBase(NULL); |
28 } | 40 } |
29 | 41 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 static int32_t gID; | 79 static int32_t gID; |
68 return sk_atomic_inc(&gID) + 1; | 80 return sk_atomic_inc(&gID) + 1; |
69 } | 81 } |
70 | 82 |
71 static SkSurface_Base* asSB(SkSurface* surface) { | 83 static SkSurface_Base* asSB(SkSurface* surface) { |
72 return static_cast<SkSurface_Base*>(surface); | 84 return static_cast<SkSurface_Base*>(surface); |
73 } | 85 } |
74 | 86 |
75 /////////////////////////////////////////////////////////////////////////////// | 87 /////////////////////////////////////////////////////////////////////////////// |
76 | 88 |
77 SkSurface::SkSurface(int width, int height) : fWidth(width), fHeight(height) { | 89 SkSurface::SkSurface(int width, int height, const Props& props) |
| 90 : fProps(props), fWidth(width), fHeight(height) |
| 91 { |
78 SkASSERT(fWidth >= 0); | 92 SkASSERT(fWidth >= 0); |
79 SkASSERT(fHeight >= 0); | 93 SkASSERT(fHeight >= 0); |
80 fGenerationID = 0; | 94 fGenerationID = 0; |
81 } | 95 } |
82 | 96 |
83 SkSurface::SkSurface(const SkImageInfo& info) : fWidth(info.width()), fHeight(in
fo.height()) { | 97 SkSurface::SkSurface(const SkImageInfo& info, const Props& props) |
| 98 : fProps(props), fWidth(info.width()), fHeight(info.height()) |
| 99 { |
84 SkASSERT(fWidth >= 0); | 100 SkASSERT(fWidth >= 0); |
85 SkASSERT(fHeight >= 0); | 101 SkASSERT(fHeight >= 0); |
86 fGenerationID = 0; | 102 fGenerationID = 0; |
87 } | 103 } |
88 | 104 |
89 uint32_t SkSurface::generationID() { | 105 uint32_t SkSurface::generationID() { |
90 if (0 == fGenerationID) { | 106 if (0 == fGenerationID) { |
91 fGenerationID = asSB(this)->newGenerationID(); | 107 fGenerationID = asSB(this)->newGenerationID(); |
92 } | 108 } |
93 return fGenerationID; | 109 return fGenerationID; |
(...skipping 18 matching lines...) Expand all Loading... |
112 } | 128 } |
113 | 129 |
114 void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y, | 130 void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y, |
115 const SkPaint* paint) { | 131 const SkPaint* paint) { |
116 return asSB(this)->onDraw(canvas, x, y, paint); | 132 return asSB(this)->onDraw(canvas, x, y, paint); |
117 } | 133 } |
118 | 134 |
119 const void* SkSurface::peekPixels(SkImageInfo* info, size_t* rowBytes) { | 135 const void* SkSurface::peekPixels(SkImageInfo* info, size_t* rowBytes) { |
120 return this->getCanvas()->peekPixels(info, rowBytes); | 136 return this->getCanvas()->peekPixels(info, rowBytes); |
121 } | 137 } |
OLD | NEW |