Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: src/core/SkBitmapDevice.cpp

Issue 551463004: introduce Props to surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: handle dither and aa at the canvas level Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
60 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) : fBitmap(bitmap) { 60 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps* pro ps)
61 : fBitmap(bitmap)
62 , fProps(props ? *props : SkSurfaceProps())
63 {
61 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); 64 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL));
62 } 65 }
63 66
64 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) 67 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties)
65 : SkBaseDevice(deviceProperties) 68 : SkBaseDevice(deviceProperties)
66 , fBitmap(bitmap) 69 , fBitmap(bitmap)
67 { 70 {
68 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); 71 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL));
69 } 72 }
70 73
74 SkBitmapDevice* SkBitmapDevice::Create(const SkBitmap& bitmap, const SkSurfacePr ops* props) {
75 // validate bitmap?
76 return SkNEW_ARGS(SkBitmapDevice, (bitmap, props));
77 }
78
71 SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo, 79 SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
72 const SkDeviceProperties* props) { 80 const SkDeviceProperties* props) {
73 SkAlphaType newAT = origInfo.alphaType(); 81 SkAlphaType newAT = origInfo.alphaType();
74 if (!valid_for_bitmap_device(origInfo, &newAT)) { 82 if (!valid_for_bitmap_device(origInfo, &newAT)) {
75 return NULL; 83 return NULL;
76 } 84 }
77 85
78 const SkImageInfo info = origInfo.makeAlphaType(newAT); 86 const SkImageInfo info = origInfo.makeAlphaType(newAT);
79 SkBitmap bitmap; 87 SkBitmap bitmap;
80 88
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 375 }
368 376
369 SkImageFilter::Cache* SkBitmapDevice::getImageFilterCache() { 377 SkImageFilter::Cache* SkBitmapDevice::getImageFilterCache() {
370 SkImageFilter::Cache* cache = SkImageFilter::Cache::Get(); 378 SkImageFilter::Cache* cache = SkImageFilter::Cache::Get();
371 cache->ref(); 379 cache->ref();
372 return cache; 380 return cache;
373 } 381 }
374 382
375 /////////////////////////////////////////////////////////////////////////////// 383 ///////////////////////////////////////////////////////////////////////////////
376 384
385 static bool disable_lcd(const SkBitmap& target) {
386 return kN32_SkColorType != target.colorType();
bungeman-skia 2014/09/15 20:47:13 comment that we do this because we don't have a bl
387 }
388
377 bool SkBitmapDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) { 389 bool SkBitmapDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) {
378 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { 390 uint32_t clearMask = 0;
379 // we're cool with the paint as is 391
380 return false; 392 if (paint.isLCDRenderText() && paint.isAntiAlias() && disable_lcd(fBitmap)) {
393 clearMask |= SkPaint::kLCDRenderText_Flag;
381 } 394 }
382 395
383 if (kN32_SkColorType != fBitmap.colorType() || 396 if (clearMask) {
384 paint.getRasterizer() || 397 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(); 398 flags->fHinting = paint.getHinting();
392 return true; 399 return true;
393 } 400 }
394 // we're cool with the paint as is 401 // we're cool with the paint as is
395 return false; 402 return false;
396 } 403 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698