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

Side by Side Diff: Source/platform/graphics/GraphicsContext.cpp

Issue 416543002: Move logic from NativeImageSkia to GraphicsContext and SkiaUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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 (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
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
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
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::preparePaint(
1861 SkPaint* paint,
1862 const SkRect& srcRect,
1863 const SkRect& destRect,
1864 CompositeOperator compositeOp,
1865 blink::WebBlendMode blendMode,
1866 bool isLazyDecoded) const
1867 {
1868 paint->setXfermode(WebCoreCompositeToSkiaComposite(compositeOp, blendMode).g et());
1869 paint->setColorFilter(this->colorFilter());
1870 paint->setAlpha(this->getNormalizedAlpha());
1871 paint->setLooper(this->drawLooper());
1872 paint->setAntiAlias(shouldDrawAntiAliased(this, destRect));
1873
1874 InterpolationQuality resampling;
1875 if (this->isAccelerated()) {
1876 resampling = InterpolationLow;
1877 } else if (this->printing()) {
1878 resampling = InterpolationNone;
1879 } else if (isLazyDecoded) {
1880 resampling = InterpolationHigh;
1881 } else {
1882 // Take into account scale applied to the canvas when computing sampling mode (e.g. CSS scale or page scale).
1883 SkRect destRectTarget = destRect;
1884 SkMatrix totalMatrix = this->getTotalMatrix();
1885 if (!(totalMatrix.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPersp ective_Mask)))
1886 totalMatrix.mapRect(&destRectTarget, destRect);
1887
1888 resampling = computeInterpolationQuality(totalMatrix,
1889 SkScalarToFloat(srcRect.width()), SkScalarToFloat(srcRect.height()),
1890 SkScalarToFloat(destRectTarget.width()), SkScalarToFloat(destRectTar get.height()));
1891 }
1892
1893 if (resampling == InterpolationNone) {
1894 // FIXME: This is to not break tests (it results in the filter bitmap fl ag
1895 // being set to true). We need to decide if we respect InterpolationNone
1896 // being returned from computeInterpolationQuality.
1897 resampling = InterpolationLow;
1898 }
1899 resampling = limitInterpolationQuality(this, resampling);
1900
1901 bool useBicubicFilter = resampling == InterpolationHigh;
1902 paint->setFilterLevel(convertToSkiaFilterLevel(useBicubicFilter, resampling) );
1859 } 1903 }
1904
1905 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698