OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkConfig8888.h" | 9 #include "SkConfig8888.h" |
10 #include "SkDraw.h" | 10 #include "SkDraw.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa
int*) { | 135 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa
int*) { |
136 const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixel
Geometry); | 136 const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixel
Geometry); |
137 return SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); | 137 return SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); |
138 } | 138 } |
139 | 139 |
140 const SkBitmap& SkBitmapDevice::onAccessBitmap() { | 140 const SkBitmap& SkBitmapDevice::onAccessBitmap() { |
141 return fBitmap; | 141 return fBitmap; |
142 } | 142 } |
143 | 143 |
144 bool SkBitmapDevice::onAccessPixels(SkPixmap* pmap) { | 144 bool SkBitmapDevice::onAccessPixels(SkPixmap* pmap) { |
145 if (fBitmap.lockPixelsAreWritable() && this->onPeekPixels(pmap)) { | 145 if (this->onPeekPixels(pmap)) { |
146 fBitmap.notifyPixelsChanged(); | 146 fBitmap.notifyPixelsChanged(); |
147 return true; | 147 return true; |
148 } | 148 } |
149 return false; | 149 return false; |
150 } | 150 } |
151 | 151 |
152 bool SkBitmapDevice::onPeekPixels(SkPixmap* pmap) { | 152 bool SkBitmapDevice::onPeekPixels(SkPixmap* pmap) { |
153 const SkImageInfo info = fBitmap.info(); | 153 const SkImageInfo info = fBitmap.info(); |
154 if (fBitmap.getPixels() && (kUnknown_SkColorType != info.colorType())) { | 154 if (fBitmap.getPixels() && (kUnknown_SkColorType != info.colorType())) { |
155 SkColorTable* ctable = nullptr; | 155 SkColorTable* ctable = nullptr; |
(...skipping 22 matching lines...) Expand all Loading... |
178 return false; | 178 return false; |
179 } | 179 } |
180 | 180 |
181 bool SkBitmapDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s
ize_t dstRowBytes, | 181 bool SkBitmapDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s
ize_t dstRowBytes, |
182 int x, int y) { | 182 int x, int y) { |
183 return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, x, y); | 183 return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, x, y); |
184 } | 184 } |
185 | 185 |
186 void SkBitmapDevice::onAttachToCanvas(SkCanvas* canvas) { | 186 void SkBitmapDevice::onAttachToCanvas(SkCanvas* canvas) { |
187 INHERITED::onAttachToCanvas(canvas); | 187 INHERITED::onAttachToCanvas(canvas); |
188 if (fBitmap.lockPixelsAreWritable()) { | 188 fBitmap.lockPixels(); |
189 fBitmap.lockPixels(); | |
190 } | |
191 } | 189 } |
192 | 190 |
193 void SkBitmapDevice::onDetachFromCanvas() { | 191 void SkBitmapDevice::onDetachFromCanvas() { |
194 INHERITED::onDetachFromCanvas(); | 192 INHERITED::onDetachFromCanvas(); |
195 if (fBitmap.lockPixelsAreWritable()) { | 193 fBitmap.unlockPixels(); |
196 fBitmap.unlockPixels(); | |
197 } | |
198 } | 194 } |
199 | 195 |
200 /////////////////////////////////////////////////////////////////////////////// | 196 /////////////////////////////////////////////////////////////////////////////// |
201 | 197 |
202 void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 198 void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
203 draw.drawPaint(paint); | 199 draw.drawPaint(paint); |
204 } | 200 } |
205 | 201 |
206 void SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, si
ze_t count, | 202 void SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, si
ze_t count, |
207 const SkPoint pts[], const SkPaint& paint) { | 203 const SkPoint pts[], const SkPaint& paint) { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 paint.getRasterizer() || | 428 paint.getRasterizer() || |
433 paint.getPathEffect() || | 429 paint.getPathEffect() || |
434 paint.isFakeBoldText() || | 430 paint.isFakeBoldText() || |
435 paint.getStyle() != SkPaint::kFill_Style || | 431 paint.getStyle() != SkPaint::kFill_Style || |
436 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) | 432 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) |
437 { | 433 { |
438 return true; | 434 return true; |
439 } | 435 } |
440 return false; | 436 return false; |
441 } | 437 } |
OLD | NEW |