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" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 } | 92 } |
93 | 93 |
94 SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr, const SkSurfaceProps* props) | 94 SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr, const SkSurfaceProps* props) |
95 : INHERITED(pr->info().width(), pr->info().height(), props) | 95 : INHERITED(pr->info().width(), pr->info().height(), props) |
96 { | 96 { |
97 const SkImageInfo& info = pr->info(); | 97 const SkImageInfo& info = pr->info(); |
98 | 98 |
99 fBitmap.setInfo(info, info.minRowBytes()); | 99 fBitmap.setInfo(info, info.minRowBytes()); |
100 fBitmap.setPixelRef(pr); | 100 fBitmap.setPixelRef(pr); |
101 fWeOwnThePixels = true; | 101 fWeOwnThePixels = true; |
102 | |
103 if (!info.isOpaque()) { | |
104 fBitmap.eraseColor(SK_ColorTRANSPARENT); | |
105 } | |
106 } | 102 } |
107 | 103 |
108 SkCanvas* SkSurface_Raster::onNewCanvas() { return new SkCanvas(fBitmap, this->p rops()); } | 104 SkCanvas* SkSurface_Raster::onNewCanvas() { return new SkCanvas(fBitmap, this->p rops()); } |
109 | 105 |
110 SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) { | 106 SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) { |
111 return SkSurface::NewRaster(info, &this->props()); | 107 return SkSurface::NewRaster(info, &this->props()); |
112 } | 108 } |
113 | 109 |
114 void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, | 110 void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, |
115 const SkPaint* paint) { | 111 const SkPaint* paint) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 if (nullptr == releaseProc) { | 161 if (nullptr == releaseProc) { |
166 context = nullptr; | 162 context = nullptr; |
167 } | 163 } |
168 if (!SkSurface_Raster::Valid(info, rb)) { | 164 if (!SkSurface_Raster::Valid(info, rb)) { |
169 return nullptr; | 165 return nullptr; |
170 } | 166 } |
171 if (nullptr == pixels) { | 167 if (nullptr == pixels) { |
172 return nullptr; | 168 return nullptr; |
173 } | 169 } |
174 | 170 |
175 return new SkSurface_Raster(info, pixels, rb, releaseProc, context, props); | 171 return new SkSurface_Raster(info, pixels, rb, releaseProc, context, props); |
reed1
2015/12/31 13:17:49
When the constructor is called from here, do we kn
mtklein
2015/12/31 21:35:47
There are two constructors. This CL only changes
| |
176 } | 172 } |
177 | 173 |
178 SkSurface* SkSurface::NewRasterDirect(const SkImageInfo& info, void* pixels, siz e_t rowBytes, | 174 SkSurface* SkSurface::NewRasterDirect(const SkImageInfo& info, void* pixels, siz e_t rowBytes, |
179 const SkSurfaceProps* props) { | 175 const SkSurfaceProps* props) { |
180 return NewRasterDirectReleaseProc(info, pixels, rowBytes, nullptr, nullptr, props); | 176 return NewRasterDirectReleaseProc(info, pixels, rowBytes, nullptr, nullptr, props); |
181 } | 177 } |
182 | 178 |
183 SkSurface* SkSurface::NewRaster(const SkImageInfo& info, const SkSurfaceProps* p rops) { | 179 SkSurface* SkSurface::NewRaster(const SkImageInfo& info, const SkSurfaceProps* p rops) { |
184 if (!SkSurface_Raster::Valid(info)) { | 180 if (!SkSurface_Raster::Valid(info)) { |
185 return nullptr; | 181 return nullptr; |
186 } | 182 } |
187 | 183 |
188 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, nullptr)) ; | 184 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, 0, nullptr)); |
189 if (nullptr == pr.get()) { | 185 if (nullptr == pr.get()) { |
190 return nullptr; | 186 return nullptr; |
191 } | 187 } |
192 return new SkSurface_Raster(pr, props); | 188 return new SkSurface_Raster(pr, props); |
193 } | 189 } |
OLD | NEW |