OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "config.h" | 27 #include "config.h" |
28 #include "platform/graphics/GraphicsContext.h" | 28 #include "platform/graphics/GraphicsContext.h" |
29 | 29 |
30 #include "platform/TraceEvent.h" | 30 #include "platform/TraceEvent.h" |
31 #include "platform/geometry/IntRect.h" | 31 #include "platform/geometry/IntRect.h" |
32 #include "platform/geometry/RoundedRect.h" | 32 #include "platform/geometry/RoundedRect.h" |
33 #include "platform/graphics/BitmapImage.h" | 33 #include "platform/graphics/BitmapImage.h" |
34 #include "platform/graphics/DisplayList.h" | 34 #include "platform/graphics/DisplayList.h" |
35 #include "platform/graphics/Gradient.h" | 35 #include "platform/graphics/Gradient.h" |
36 #include "platform/graphics/ImageBuffer.h" | 36 #include "platform/graphics/ImageBuffer.h" |
| 37 #include "platform/graphics/skia/SkiaUtils.h" |
37 #include "platform/text/BidiResolver.h" | 38 #include "platform/text/BidiResolver.h" |
38 #include "platform/text/TextRunIterator.h" | 39 #include "platform/text/TextRunIterator.h" |
39 #include "platform/weborigin/KURL.h" | 40 #include "platform/weborigin/KURL.h" |
40 #include "third_party/skia/include/core/SkAnnotation.h" | 41 #include "third_party/skia/include/core/SkAnnotation.h" |
41 #include "third_party/skia/include/core/SkClipStack.h" | 42 #include "third_party/skia/include/core/SkClipStack.h" |
42 #include "third_party/skia/include/core/SkColorFilter.h" | 43 #include "third_party/skia/include/core/SkColorFilter.h" |
43 #include "third_party/skia/include/core/SkData.h" | 44 #include "third_party/skia/include/core/SkData.h" |
44 #include "third_party/skia/include/core/SkDevice.h" | 45 #include "third_party/skia/include/core/SkDevice.h" |
45 #include "third_party/skia/include/core/SkPicture.h" | 46 #include "third_party/skia/include/core/SkPicture.h" |
46 #include "third_party/skia/include/core/SkRRect.h" | 47 #include "third_party/skia/include/core/SkRRect.h" |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 return shouldSmoothFonts(); | 391 return shouldSmoothFonts(); |
391 } | 392 } |
392 | 393 |
393 void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation
, WebBlendMode blendMode) | 394 void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation
, WebBlendMode blendMode) |
394 { | 395 { |
395 if (contextDisabled()) | 396 if (contextDisabled()) |
396 return; | 397 return; |
397 mutableState()->setCompositeOperation(compositeOperation, blendMode); | 398 mutableState()->setCompositeOperation(compositeOperation, blendMode); |
398 } | 399 } |
399 | 400 |
400 SkColorFilter* GraphicsContext::colorFilter() | 401 SkColorFilter* GraphicsContext::colorFilter() const |
401 { | 402 { |
402 return immutableState()->colorFilter(); | 403 return immutableState()->colorFilter(); |
403 } | 404 } |
404 | 405 |
405 void GraphicsContext::setColorFilter(ColorFilter colorFilter) | 406 void GraphicsContext::setColorFilter(ColorFilter colorFilter) |
406 { | 407 { |
407 GraphicsContextState* stateToSet = mutableState(); | 408 GraphicsContextState* stateToSet = mutableState(); |
408 | 409 |
409 // We only support one active color filter at the moment. If (when) this bec
omes a problem, | 410 // We only support one active color filter at the moment. If (when) this bec
omes a problem, |
410 // we should switch to using color filter chains (Skia work in progress). | 411 // we should switch to using color filter chains (Skia work in progress). |
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1849 #endif | 1850 #endif |
1850 | 1851 |
1851 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 1852 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
1852 { | 1853 { |
1853 if (m_trackTextRegion) { | 1854 if (m_trackTextRegion) { |
1854 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); | 1855 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); |
1855 m_textRegion.join(textRect); | 1856 m_textRegion.join(textRect); |
1856 } | 1857 } |
1857 } | 1858 } |
1858 | 1859 |
| 1860 void GraphicsContext::preparePaintForDrawRectToRect( |
| 1861 SkPaint* paint, |
| 1862 const SkRect& srcRect, |
| 1863 const SkRect& destRect, |
| 1864 CompositeOperator compositeOp, |
| 1865 blink::WebBlendMode blendMode, |
| 1866 bool isLazyDecoded, |
| 1867 bool isDataComplete) const |
| 1868 { |
| 1869 paint->setXfermode(WebCoreCompositeToSkiaComposite(compositeOp, blendMode).g
et()); |
| 1870 paint->setColorFilter(this->colorFilter()); |
| 1871 paint->setAlpha(this->getNormalizedAlpha()); |
| 1872 paint->setLooper(this->drawLooper()); |
| 1873 paint->setAntiAlias(shouldDrawAntiAliased(this, destRect)); |
| 1874 |
| 1875 InterpolationQuality resampling; |
| 1876 if (this->isAccelerated()) { |
| 1877 resampling = InterpolationLow; |
| 1878 } else if (this->printing()) { |
| 1879 resampling = InterpolationNone; |
| 1880 } else if (isLazyDecoded) { |
| 1881 resampling = InterpolationHigh; |
| 1882 } else { |
| 1883 // Take into account scale applied to the canvas when computing sampling
mode (e.g. CSS scale or page scale). |
| 1884 SkRect destRectTarget = destRect; |
| 1885 SkMatrix totalMatrix = this->getTotalMatrix(); |
| 1886 if (!(totalMatrix.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPersp
ective_Mask))) |
| 1887 totalMatrix.mapRect(&destRectTarget, destRect); |
| 1888 |
| 1889 resampling = computeInterpolationQuality(totalMatrix, |
| 1890 SkScalarToFloat(srcRect.width()), SkScalarToFloat(srcRect.height()), |
| 1891 SkScalarToFloat(destRectTarget.width()), SkScalarToFloat(destRectTar
get.height()), |
| 1892 isDataComplete); |
| 1893 } |
| 1894 |
| 1895 if (resampling == InterpolationNone) { |
| 1896 // FIXME: This is to not break tests (it results in the filter bitmap fl
ag |
| 1897 // being set to true). We need to decide if we respect InterpolationNone |
| 1898 // being returned from computeInterpolationQuality. |
| 1899 resampling = InterpolationLow; |
| 1900 } |
| 1901 resampling = limitInterpolationQuality(this, resampling); |
| 1902 |
| 1903 bool useBicubicFilter = resampling == InterpolationHigh; |
| 1904 paint->setFilterLevel(convertToSkiaFilterLevel(useBicubicFilter, resampling)
); |
1859 } | 1905 } |
| 1906 |
| 1907 } |
OLD | NEW |