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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 break; | 49 break; |
50 default: | 50 default: |
51 return false; | 51 return false; |
52 } | 52 } |
53 | 53 |
54 if (newAlphaType) { | 54 if (newAlphaType) { |
55 *newAlphaType = canonicalAlphaType; | 55 *newAlphaType = canonicalAlphaType; |
56 } | 56 } |
57 return true; | 57 return true; |
58 } | 58 } |
59 | 59 |
robertphillips
2014/09/16 14:15:18
Why this change?
reed1
2014/09/16 18:16:01
Historical edit/unedit. Fixed.
| |
60 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) : fBitmap(bitmap) { | 60 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) : fBitmap(bitmap) |
61 { | |
61 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); | 62 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); |
62 } | 63 } |
63 | 64 |
64 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) | 65 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) |
65 : SkBaseDevice(deviceProperties) | 66 : SkBaseDevice(deviceProperties) |
66 , fBitmap(bitmap) | 67 , fBitmap(bitmap) |
67 { | 68 { |
68 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); | 69 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); |
69 } | 70 } |
70 | 71 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 return NULL; | 367 return NULL; |
367 } | 368 } |
368 | 369 |
369 SkImageFilter::Cache* SkBitmapDevice::getImageFilterCache() { | 370 SkImageFilter::Cache* SkBitmapDevice::getImageFilterCache() { |
370 SkImageFilter::Cache* cache = SkImageFilter::Cache::Get(); | 371 SkImageFilter::Cache* cache = SkImageFilter::Cache::Get(); |
371 cache->ref(); | 372 cache->ref(); |
372 return cache; | 373 return cache; |
373 } | 374 } |
374 | 375 |
375 /////////////////////////////////////////////////////////////////////////////// | 376 /////////////////////////////////////////////////////////////////////////////// |
376 | 377 |
robertphillips
2014/09/16 14:15:18
Rename to supports_lcd and switch sense?
reed1
2014/09/16 18:16:01
Done.
| |
378 static bool disable_lcd(const SkBitmap& target) { | |
379 return kN32_SkColorType != target.colorType(); | |
380 } | |
381 | |
377 bool SkBitmapDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) { | 382 bool SkBitmapDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) { |
378 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { | 383 uint32_t clearMask = 0; |
379 // we're cool with the paint as is | 384 |
380 return false; | 385 if (paint.isLCDRenderText() && paint.isAntiAlias() && disable_lcd(fBitmap)) { |
386 clearMask |= SkPaint::kLCDRenderText_Flag; | |
381 } | 387 } |
382 | 388 |
383 if (kN32_SkColorType != fBitmap.colorType() || | 389 if (clearMask) { |
384 paint.getRasterizer() || | 390 flags->fFlags = paint.getFlags() & ~clearMask; |
385 paint.getPathEffect() || | |
386 paint.isFakeBoldText() || | |
387 paint.getStyle() != SkPaint::kFill_Style || | |
388 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { | |
389 // turn off lcd | |
390 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; | |
391 flags->fHinting = paint.getHinting(); | 391 flags->fHinting = paint.getHinting(); |
392 return true; | 392 return true; |
393 } | 393 } |
394 // we're cool with the paint as is | 394 // we're cool with the paint as is |
395 return false; | 395 return false; |
396 } | 396 } |
OLD | NEW |