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 "SkDeviceProperties.h" | 10 #include "SkDeviceProperties.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 SkASSERT(bm.height() == fBitmap.height()); | 113 SkASSERT(bm.height() == fBitmap.height()); |
114 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) | 114 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) |
115 fBitmap.lockPixels(); | 115 fBitmap.lockPixels(); |
116 } | 116 } |
117 | 117 |
118 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa
int*) { | 118 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa
int*) { |
119 SkDeviceProperties leaky(cinfo.fPixelGeometry); | 119 SkDeviceProperties leaky(cinfo.fPixelGeometry); |
120 return SkBitmapDevice::Create(cinfo.fInfo, &leaky); | 120 return SkBitmapDevice::Create(cinfo.fInfo, &leaky); |
121 } | 121 } |
122 | 122 |
123 void SkBitmapDevice::lockPixels() { | |
124 if (fBitmap.lockPixelsAreWritable()) { | |
125 fBitmap.lockPixels(); | |
126 } | |
127 } | |
128 | |
129 void SkBitmapDevice::unlockPixels() { | |
130 if (fBitmap.lockPixelsAreWritable()) { | |
131 fBitmap.unlockPixels(); | |
132 } | |
133 } | |
134 | |
135 const SkBitmap& SkBitmapDevice::onAccessBitmap() { | 123 const SkBitmap& SkBitmapDevice::onAccessBitmap() { |
136 return fBitmap; | 124 return fBitmap; |
137 } | 125 } |
138 | 126 |
139 void* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) { | 127 void* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) { |
140 if (fBitmap.getPixels()) { | 128 if (fBitmap.getPixels()) { |
141 *info = fBitmap.info(); | 129 *info = fBitmap.info(); |
142 *rowBytes = fBitmap.rowBytes(); | 130 *rowBytes = fBitmap.rowBytes(); |
143 return fBitmap.getPixels(); | 131 return fBitmap.getPixels(); |
144 } | 132 } |
(...skipping 20 matching lines...) Expand all Loading... |
165 return true; | 153 return true; |
166 } | 154 } |
167 return false; | 155 return false; |
168 } | 156 } |
169 | 157 |
170 bool SkBitmapDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s
ize_t dstRowBytes, | 158 bool SkBitmapDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s
ize_t dstRowBytes, |
171 int x, int y) { | 159 int x, int y) { |
172 return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, x, y); | 160 return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, x, y); |
173 } | 161 } |
174 | 162 |
| 163 void SkBitmapDevice::onAttachToCanvas(SkCanvas* canvas) { |
| 164 INHERITED::onAttachToCanvas(canvas); |
| 165 if (fBitmap.lockPixelsAreWritable()) { |
| 166 fBitmap.lockPixels(); |
| 167 } |
| 168 } |
| 169 |
| 170 void SkBitmapDevice::onDetachFromCanvas() { |
| 171 INHERITED::onDetachFromCanvas(); |
| 172 if (fBitmap.lockPixelsAreWritable()) { |
| 173 fBitmap.unlockPixels(); |
| 174 } |
| 175 } |
| 176 |
175 /////////////////////////////////////////////////////////////////////////////// | 177 /////////////////////////////////////////////////////////////////////////////// |
176 | 178 |
177 void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 179 void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
178 draw.drawPaint(paint); | 180 draw.drawPaint(paint); |
179 } | 181 } |
180 | 182 |
181 void SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, si
ze_t count, | 183 void SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, si
ze_t count, |
182 const SkPoint pts[], const SkPaint& paint) { | 184 const SkPoint pts[], const SkPaint& paint) { |
183 CHECK_FOR_ANNOTATION(paint); | 185 CHECK_FOR_ANNOTATION(paint); |
184 draw.drawPoints(mode, count, pts, paint); | 186 draw.drawPoints(mode, count, pts, paint); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 paint.getRasterizer() || | 383 paint.getRasterizer() || |
382 paint.getPathEffect() || | 384 paint.getPathEffect() || |
383 paint.isFakeBoldText() || | 385 paint.isFakeBoldText() || |
384 paint.getStyle() != SkPaint::kFill_Style || | 386 paint.getStyle() != SkPaint::kFill_Style || |
385 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) | 387 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) |
386 { | 388 { |
387 return true; | 389 return true; |
388 } | 390 } |
389 return false; | 391 return false; |
390 } | 392 } |
OLD | NEW |