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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 bool SkBitmapDevice::filterImage(const SkImageFilter* filter, const SkBitmap& sr
c, | 166 bool SkBitmapDevice::filterImage(const SkImageFilter* filter, const SkBitmap& sr
c, |
167 const SkImageFilter::Context& ctx, SkBitmap* re
sult, | 167 const SkImageFilter::Context& ctx, SkBitmap* re
sult, |
168 SkIPoint* offset) { | 168 SkIPoint* offset) { |
169 return false; | 169 return false; |
170 } | 170 } |
171 | 171 |
172 bool SkBitmapDevice::allowImageFilter(const SkImageFilter*) { | 172 bool SkBitmapDevice::allowImageFilter(const SkImageFilter*) { |
173 return true; | 173 return true; |
174 } | 174 } |
175 | 175 |
176 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG | |
177 bool SkBitmapDevice::onReadPixels(const SkBitmap& bitmap, | |
178 int x, int y, | |
179 SkCanvas::Config8888 config8888) { | |
180 SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config()); | |
181 SkASSERT(!bitmap.isNull()); | |
182 SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::Ma
keXYWH(x, y, | |
183 bitmap
.width(), | |
184 bitmap
.height()))); | |
185 | |
186 SkIRect srcRect = SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height()); | |
187 const SkBitmap& src = this->accessBitmap(false); | |
188 | |
189 SkBitmap subset; | |
190 if (!src.extractSubset(&subset, srcRect)) { | |
191 return false; | |
192 } | |
193 if (kPMColor_SkColorType != subset.colorType()) { | |
194 // It'd be preferable to do this directly to bitmap. | |
195 subset.copyTo(&subset, kPMColor_SkColorType); | |
196 } | |
197 SkAutoLockPixels alp(bitmap); | |
198 uint32_t* bmpPixels = reinterpret_cast<uint32_t*>(bitmap.getPixels()); | |
199 SkCopyBitmapToConfig8888(bmpPixels, bitmap.rowBytes(), config8888, subset); | |
200 return true; | |
201 } | |
202 #endif | |
203 | |
204 void* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) { | 176 void* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) { |
205 if (fBitmap.getPixels()) { | 177 if (fBitmap.getPixels()) { |
206 *info = fBitmap.info(); | 178 *info = fBitmap.info(); |
207 *rowBytes = fBitmap.rowBytes(); | 179 *rowBytes = fBitmap.rowBytes(); |
208 return fBitmap.getPixels(); | 180 return fBitmap.getPixels(); |
209 } | 181 } |
210 return NULL; | 182 return NULL; |
211 } | 183 } |
212 | 184 |
213 static void rect_memcpy(void* dst, size_t dstRB, const void* src, size_t srcRB,
size_t bytesPerRow, | 185 static void rect_memcpy(void* dst, size_t dstRB, const void* src, size_t srcRB,
size_t bytesPerRow, |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 paint.getStyle() != SkPaint::kFill_Style || | 491 paint.getStyle() != SkPaint::kFill_Style || |
520 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { | 492 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { |
521 // turn off lcd | 493 // turn off lcd |
522 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; | 494 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; |
523 flags->fHinting = paint.getHinting(); | 495 flags->fHinting = paint.getHinting(); |
524 return true; | 496 return true; |
525 } | 497 } |
526 // we're cool with the paint as is | 498 // we're cool with the paint as is |
527 return false; | 499 return false; |
528 } | 500 } |
OLD | NEW |