153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com/* 253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com * Copyright 2013 Google Inc. 353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com * 453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com * Use of this source code is governed by a BSD-style license that can be 553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com * found in the LICENSE file. 653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com */ 753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com#include "SkBitmapDevice.h" 953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com#include "SkConfig8888.h" 1053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com#include "SkDraw.h" 1153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com#include "SkRasterClip.h" 1253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com#include "SkShader.h" 1376f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com#include "SkSurface.h" 1453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 154469938e92d779dff05e745559e67907bbf21e78reed@google.com#define CHECK_FOR_ANNOTATION(paint) \ 164469938e92d779dff05e745559e67907bbf21e78reed@google.com do { if (paint.getAnnotation()) { return; } } while (0) 1753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 1815a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.orgstatic bool valid_for_bitmap_device(const SkImageInfo& info, 1915a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org SkAlphaType* newAlphaType) { 2015a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org if (info.width() < 0 || info.height() < 0) { 2115a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org return false; 2215a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } 2315a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org 2415a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org // TODO: can we stop supporting kUnknown in SkBitmkapDevice? 2515a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org if (kUnknown_SkColorType == info.colorType()) { 2615a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org if (newAlphaType) { 2715a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org *newAlphaType = kIgnore_SkAlphaType; 2815a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } 2915a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org return true; 3015a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } 31969588f0c9030d5a4942085a4b5a5ea7e8d2bc25skia.committer@gmail.com 3215a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org switch (info.alphaType()) { 3315a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org case kPremul_SkAlphaType: 3415a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org case kOpaque_SkAlphaType: 3515a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org break; 3615a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org default: 3715a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org return false; 3815a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } 3915a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org 4015a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org SkAlphaType canonicalAlphaType = info.alphaType(); 4115a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org 4215a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org switch (info.colorType()) { 4315a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org case kAlpha_8_SkColorType: 4415a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org break; 4515a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org case kRGB_565_SkColorType: 4615a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org canonicalAlphaType = kOpaque_SkAlphaType; 4715a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org break; 4828fcae2ec77eb16a79e155f8d788b20457f1c951commit-bot@chromium.org case kN32_SkColorType: 4915a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org break; 5015a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org default: 5115a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org return false; 5215a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } 5315a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org 5415a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org if (newAlphaType) { 5515a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org *newAlphaType = canonicalAlphaType; 5615a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } 5715a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org return true; 5815a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org} 5915a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org 6015a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.orgSkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) : fBitmap(bitmap) { 6115a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); 6253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 6353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 6453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comSkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) 6553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com : SkBaseDevice(deviceProperties) 6615a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org , fBitmap(bitmap) 6715a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org{ 6815a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); 6953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 7053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 7115a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.orgSkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo, 7215a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org const SkDeviceProperties* props) { 7315a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org SkImageInfo info = origInfo; 7415a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org if (!valid_for_bitmap_device(info, &info.fAlphaType)) { 7515a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org return NULL; 7615a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } 7715a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org 7815a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org SkBitmap bitmap; 7915a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org 8015a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org if (kUnknown_SkColorType == info.colorType()) { 81a3264e53ee3f3c5d6a2c813df7e44b5b96d207f2commit-bot@chromium.org if (!bitmap.setInfo(info)) { 8215a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org return NULL; 8315a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } 8415a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } else { 8515a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org if (!bitmap.allocPixels(info)) { 8615a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org return NULL; 8715a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } 8815a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org if (!bitmap.info().isOpaque()) { 8915a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org bitmap.eraseColor(SK_ColorTRANSPARENT); 9015a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } 9115a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } 9253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 9315a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org if (props) { 9415a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org return SkNEW_ARGS(SkBitmapDevice, (bitmap, *props)); 9515a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } else { 9615a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org return SkNEW_ARGS(SkBitmapDevice, (bitmap)); 9715a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org } 9853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 9953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 100c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.orgSkImageInfo SkBitmapDevice::imageInfo() const { 101c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org return fBitmap.info(); 102c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org} 103c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org 10453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { 10553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkASSERT(bm.width() == fBitmap.width()); 10653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkASSERT(bm.height() == fBitmap.height()); 10753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) 10853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com fBitmap.lockPixels(); 10953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 11053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 11115a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.orgSkBaseDevice* SkBitmapDevice::onCreateDevice(const SkImageInfo& info, Usage usage) { 11215a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org return SkBitmapDevice::Create(info, &this->getDeviceProperties()); 11353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 11453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 11553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::lockPixels() { 11653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (fBitmap.lockPixelsAreWritable()) { 11753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com fBitmap.lockPixels(); 11853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 11953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 12053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 12153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::unlockPixels() { 12253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (fBitmap.lockPixelsAreWritable()) { 12353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com fBitmap.unlockPixels(); 12453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 12553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 12653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 12753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::clear(SkColor color) { 12853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com fBitmap.eraseColor(color); 12953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 13053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 13153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comconst SkBitmap& SkBitmapDevice::onAccessBitmap() { 13253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com return fBitmap; 13353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 13453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 135ae761f7545d8ebf181d220169afac2056b057b8ccommit-bot@chromium.orgbool SkBitmapDevice::canHandleImageFilter(const SkImageFilter*) { 13653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com return false; 13753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 13853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 139ae761f7545d8ebf181d220169afac2056b057b8ccommit-bot@chromium.orgbool SkBitmapDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, 1404cb543d6057b692e1099e9f115155f0bf323a0c8senorblanco@chromium.org const SkImageFilter::Context& ctx, SkBitmap* result, 14153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkIPoint* offset) { 14253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com return false; 14353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 14453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 145ae761f7545d8ebf181d220169afac2056b057b8ccommit-bot@chromium.orgbool SkBitmapDevice::allowImageFilter(const SkImageFilter*) { 14653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com return true; 14753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 14853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 1499c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.comvoid* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) { 1509c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com if (fBitmap.getPixels()) { 1519c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com *info = fBitmap.info(); 1529c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com *rowBytes = fBitmap.rowBytes(); 1539c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com return fBitmap.getPixels(); 1549c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com } 1559c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com return NULL; 1569c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com} 1579c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com 158231f6b81c22001cac4ea87ea412c4d6fd10ffb8acommit-bot@chromium.org#include "SkConfig8888.h" 1597111d463cee893a479280c7af41757e709e33ef5reed@google.com 1604cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.orgbool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPixels, 1614cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org size_t srcRowBytes, int x, int y) { 1620d30c51c6cf45b3a08a3000b6d348c16bdec7f05reed@google.com // since we don't stop creating un-pixeled devices yet, check for no pixels here 1630d30c51c6cf45b3a08a3000b6d348c16bdec7f05reed@google.com if (NULL == fBitmap.getPixels()) { 1640d30c51c6cf45b3a08a3000b6d348c16bdec7f05reed@google.com return false; 1650d30c51c6cf45b3a08a3000b6d348c16bdec7f05reed@google.com } 1660d30c51c6cf45b3a08a3000b6d348c16bdec7f05reed@google.com 1674cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org SkImageInfo dstInfo = fBitmap.info(); 1684cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org dstInfo.fWidth = srcInfo.width(); 1694cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org dstInfo.fHeight = srcInfo.height(); 1704cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org 1714cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org void* dstPixels = fBitmap.getAddr(x, y); 1724cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org size_t dstRowBytes = fBitmap.rowBytes(); 1734cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org 174413546c54f7ab90c8b584a2f7056fabd4f918acfreed if (SkPixelInfo::CopyPixels(dstInfo, dstPixels, dstRowBytes, srcInfo, srcPixels, srcRowBytes)) { 1754cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org fBitmap.notifyPixelsChanged(); 1764cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org return true; 1774cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org } 1784cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org return false; 1794cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org} 18053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 181a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.orgbool SkBitmapDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, 182a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org int x, int y) { 183413546c54f7ab90c8b584a2f7056fabd4f918acfreed return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, x, y); 184a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org} 185a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org 18653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com/////////////////////////////////////////////////////////////////////////////// 18753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 18853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { 18953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com draw.drawPaint(paint); 19053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 19153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 19253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t count, 19353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkPoint pts[], const SkPaint& paint) { 1944469938e92d779dff05e745559e67907bbf21e78reed@google.com CHECK_FOR_ANNOTATION(paint); 19553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com draw.drawPoints(mode, count, pts, paint); 19653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 19753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 19853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint& paint) { 1994469938e92d779dff05e745559e67907bbf21e78reed@google.com CHECK_FOR_ANNOTATION(paint); 20053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com draw.drawRect(r, paint); 20153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 20253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 20353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint& paint) { 2044469938e92d779dff05e745559e67907bbf21e78reed@google.com CHECK_FOR_ANNOTATION(paint); 20553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 20653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkPath path; 20753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com path.addOval(oval); 20853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // call the VIRTUAL version, so any subclasses who do handle drawPath aren't 20953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // required to override drawOval. 21053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com this->drawPath(draw, path, paint, NULL, true); 21153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 21253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 21353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, const SkPaint& paint) { 2144469938e92d779dff05e745559e67907bbf21e78reed@google.com CHECK_FOR_ANNOTATION(paint); 21553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 21650a7600d05d427c64f77d39c8c18d2bf6cabd25brobertphillips@google.com#ifdef SK_IGNORE_BLURRED_RRECT_OPT 21750a7600d05d427c64f77d39c8c18d2bf6cabd25brobertphillips@google.com SkPath path; 21850a7600d05d427c64f77d39c8c18d2bf6cabd25brobertphillips@google.com 21950a7600d05d427c64f77d39c8c18d2bf6cabd25brobertphillips@google.com path.addRRect(rrect); 22050a7600d05d427c64f77d39c8c18d2bf6cabd25brobertphillips@google.com // call the VIRTUAL version, so any subclasses who do handle drawPath aren't 22150a7600d05d427c64f77d39c8c18d2bf6cabd25brobertphillips@google.com // required to override drawRRect. 22250a7600d05d427c64f77d39c8c18d2bf6cabd25brobertphillips@google.com this->drawPath(draw, path, paint, NULL, true); 22350a7600d05d427c64f77d39c8c18d2bf6cabd25brobertphillips@google.com#else 224a8e33a92e27ca1523601226cad83c79a7e00c93bscroggo@google.com draw.drawRRect(rrect, paint); 22550a7600d05d427c64f77d39c8c18d2bf6cabd25brobertphillips@google.com#endif 22653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 22753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 22853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawPath(const SkDraw& draw, const SkPath& path, 22953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkPaint& paint, const SkMatrix* prePathMatrix, 23053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com bool pathIsMutable) { 2314469938e92d779dff05e745559e67907bbf21e78reed@google.com CHECK_FOR_ANNOTATION(paint); 23253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com draw.drawPath(path, paint, prePathMatrix, pathIsMutable); 23353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 23453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 23553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, 23653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkMatrix& matrix, const SkPaint& paint) { 23753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com draw.drawBitmap(bitmap, matrix, paint); 23853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 23953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 24053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, 24153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkRect* src, const SkRect& dst, 24253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkPaint& paint, 24353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkCanvas::DrawBitmapRectFlags flags) { 24453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkMatrix matrix; 24553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkRect bitmapBounds, tmpSrc, tmpDst; 24653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkBitmap tmpBitmap; 24753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 24853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com bitmapBounds.isetWH(bitmap.width(), bitmap.height()); 24953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 25053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // Compute matrix from the two rectangles 25153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (src) { 25253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com tmpSrc = *src; 25353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } else { 25453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com tmpSrc = bitmapBounds; 25553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 25653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit); 25753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 25853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkRect* dstPtr = &dst; 25953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkBitmap* bitmapPtr = &bitmap; 26053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 26153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // clip the tmpSrc to the bounds of the bitmap, and recompute dstRect if 26253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // needed (if the src was clipped). No check needed if src==null. 26353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (src) { 26453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (!bitmapBounds.contains(*src)) { 26553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (!tmpSrc.intersect(bitmapBounds)) { 26653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com return; // nothing to draw 26753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 26853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // recompute dst, based on the smaller tmpSrc 26953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com matrix.mapRect(&tmpDst, tmpSrc); 27053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com dstPtr = &tmpDst; 27153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 27253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 27353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // since we may need to clamp to the borders of the src rect within 27453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // the bitmap, we extract a subset. 27553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkIRect srcIR; 27653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com tmpSrc.roundOut(&srcIR); 27753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (!bitmap.extractSubset(&tmpBitmap, srcIR)) { 27853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com return; 27953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 28053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com bitmapPtr = &tmpBitmap; 28153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 28253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // Since we did an extract, we need to adjust the matrix accordingly 28353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkScalar dx = 0, dy = 0; 28453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (srcIR.fLeft > 0) { 28553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com dx = SkIntToScalar(srcIR.fLeft); 28653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 28753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (srcIR.fTop > 0) { 28853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com dy = SkIntToScalar(srcIR.fTop); 28953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 29053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (dx || dy) { 29153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com matrix.preTranslate(dx, dy); 29253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 29353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 29453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkRect extractedBitmapBounds; 29553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com extractedBitmapBounds.isetWH(bitmapPtr->width(), bitmapPtr->height()); 29653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (extractedBitmapBounds == tmpSrc) { 29753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // no fractional part in src, we can just call drawBitmap 29853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com goto USE_DRAWBITMAP; 29953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 30053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } else { 30153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com USE_DRAWBITMAP: 30253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // We can go faster by just calling drawBitmap, which will concat the 30353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // matrix with the CTM, and try to call drawSprite if it can. If not, 30453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // it will make a shader and call drawRect, as we do below. 30553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com this->drawBitmap(draw, *bitmapPtr, matrix, paint); 30653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com return; 30753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 30853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 30953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // construct a shader, so we can call drawRect with the dst 31053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkShader* s = SkShader::CreateBitmapShader(*bitmapPtr, 31153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkShader::kClamp_TileMode, 3129c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org SkShader::kClamp_TileMode, 3139c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org &matrix); 31453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (NULL == s) { 31553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com return; 31653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 31753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 31853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkPaint paintWithShader(paint); 31953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com paintWithShader.setStyle(SkPaint::kFill_Style); 32053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com paintWithShader.setShader(s)->unref(); 32153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 32253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // Call ourself, in case the subclass wanted to share this setup code 32353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // but handle the drawRect code themselves. 32453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com this->drawRect(draw, *dstPtr, paintWithShader); 32553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 32653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 32753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, 32853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com int x, int y, const SkPaint& paint) { 32953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com draw.drawSprite(bitmap, x, y, paint); 33053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 33153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 33253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawText(const SkDraw& draw, const void* text, size_t len, 33353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com SkScalar x, SkScalar y, const SkPaint& paint) { 33453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com draw.drawText((const char*)text, len, x, y, paint); 33553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 33653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 33753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawPosText(const SkDraw& draw, const void* text, size_t len, 33853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkScalar xpos[], SkScalar y, 33953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com int scalarsPerPos, const SkPaint& paint) { 34053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com draw.drawPosText((const char*)text, len, xpos, y, scalarsPerPos, paint); 34153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 34253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 34353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawTextOnPath(const SkDraw& draw, const void* text, 34453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com size_t len, const SkPath& path, 34553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkMatrix* matrix, 34653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkPaint& paint) { 34753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com draw.drawTextOnPath((const char*)text, len, path, matrix, paint); 34853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 34953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 35053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, 35153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com int vertexCount, 35253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkPoint verts[], const SkPoint textures[], 35353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkColor colors[], SkXfermode* xmode, 35453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const uint16_t indices[], int indexCount, 35553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkPaint& paint) { 35653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com draw.drawVertices(vmode, vertexCount, verts, textures, colors, xmode, 35753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com indices, indexCount, paint); 35853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 35953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 36053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.comvoid SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, 36153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com int x, int y, const SkPaint& paint) { 36253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com const SkBitmap& src = device->accessBitmap(false); 36353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com draw.drawSprite(src, x, y, paint); 36453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 36553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 36676f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.comSkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info) { 36776f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com return SkSurface::NewRaster(info); 36876f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com} 36976f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com 370c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.orgconst void* SkBitmapDevice::peekPixels(SkImageInfo* info, size_t* rowBytes) { 371466f5f3e44e703ca58b43ac1c4ac3bfa0e1ff024commit-bot@chromium.org const SkImageInfo bmInfo = fBitmap.info(); 372466f5f3e44e703ca58b43ac1c4ac3bfa0e1ff024commit-bot@chromium.org if (fBitmap.getPixels() && (kUnknown_SkColorType != bmInfo.colorType())) { 373466f5f3e44e703ca58b43ac1c4ac3bfa0e1ff024commit-bot@chromium.org if (info) { 374466f5f3e44e703ca58b43ac1c4ac3bfa0e1ff024commit-bot@chromium.org *info = bmInfo; 375466f5f3e44e703ca58b43ac1c4ac3bfa0e1ff024commit-bot@chromium.org } 376c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org if (rowBytes) { 377c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org *rowBytes = fBitmap.rowBytes(); 378c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org } 379c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org return fBitmap.getPixels(); 380c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org } 381c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org return NULL; 382c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org} 383c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org 38453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com/////////////////////////////////////////////////////////////////////////////// 38553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 38653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.combool SkBitmapDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) { 38753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { 38853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // we're cool with the paint as is 38953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com return false; 39053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 39153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com 392cba73780bbd12fd254229517aec04fcbf0b64b52commit-bot@chromium.org if (kN32_SkColorType != fBitmap.colorType() || 39353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com paint.getRasterizer() || 39453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com paint.getPathEffect() || 39553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com paint.isFakeBoldText() || 39653238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com paint.getStyle() != SkPaint::kFill_Style || 39753238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { 39853238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // turn off lcd 39953238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; 40053238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com flags->fHinting = paint.getHinting(); 40153238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com return true; 40253238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com } 40353238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com // we're cool with the paint as is 40453238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com return false; 40553238bc96051d1774b7f72d3ebfd35a7dd4c04dfrobertphillips@google.com} 406