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

Side by Side Diff: Source/core/platform/graphics/GeneratorGeneratedImage.cpp

Issue 16357011: Remove support for -webkit-color-correction (which we've never supported on (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: resolve merge conflicts, obey brace style changes Created 7 years, 6 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) 2008, 2009, 2010, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 14 matching lines...) Expand all
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/platform/graphics/GeneratorGeneratedImage.h" 27 #include "core/platform/graphics/GeneratorGeneratedImage.h"
28 28
29 #include "core/platform/PlatformMemoryInstrumentation.h" 29 #include "core/platform/PlatformMemoryInstrumentation.h"
30 #include "core/platform/graphics/FloatRect.h" 30 #include "core/platform/graphics/FloatRect.h"
31 #include "core/platform/graphics/GraphicsContextStateSaver.h" 31 #include "core/platform/graphics/GraphicsContextStateSaver.h"
32 32
33 namespace WebCore { 33 namespace WebCore {
34 34
35 void GeneratorGeneratedImage::draw(GraphicsContext* destContext, const FloatRect & destRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp, BlendMode) 35 void GeneratorGeneratedImage::draw(GraphicsContext* destContext, const FloatRect & destRect, const FloatRect& srcRect, CompositeOperator compositeOp, BlendMode)
36 { 36 {
37 GraphicsContextStateSaver stateSaver(*destContext); 37 GraphicsContextStateSaver stateSaver(*destContext);
38 destContext->setCompositeOperation(compositeOp); 38 destContext->setCompositeOperation(compositeOp);
39 destContext->clip(destRect); 39 destContext->clip(destRect);
40 destContext->translate(destRect.x(), destRect.y()); 40 destContext->translate(destRect.x(), destRect.y());
41 if (destRect.size() != srcRect.size()) 41 if (destRect.size() != srcRect.size())
42 destContext->scale(FloatSize(destRect.width() / srcRect.width(), destRec t.height() / srcRect.height())); 42 destContext->scale(FloatSize(destRect.width() / srcRect.width(), destRec t.height() / srcRect.height()));
43 destContext->translate(-srcRect.x(), -srcRect.y()); 43 destContext->translate(-srcRect.x(), -srcRect.y());
44 destContext->fillRect(FloatRect(FloatPoint(), m_size), *m_gradient.get()); 44 destContext->fillRect(FloatRect(FloatPoint(), m_size), *m_gradient.get());
45 } 45 }
46 46
47 void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const Fl oatRect& srcRect, const AffineTransform& patternTransform, 47 void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const Fl oatRect& srcRect, const AffineTransform& patternTransform,
48 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compo siteOp, const FloatRect& destRect, BlendMode) 48 const FloatPoint& phase, CompositeOperator compositeOp, const FloatRect& des tRect, BlendMode)
49 { 49 {
50 // Allow the generator to provide visually-equivalent tiling parameters for better performance. 50 // Allow the generator to provide visually-equivalent tiling parameters for better performance.
51 IntSize adjustedSize = m_size; 51 IntSize adjustedSize = m_size;
52 FloatRect adjustedSrcRect = srcRect; 52 FloatRect adjustedSrcRect = srcRect;
53 m_gradient->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect); 53 m_gradient->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
54 54
55 // Factor in the destination context's scale to generate at the best resolut ion 55 // Factor in the destination context's scale to generate at the best resolut ion
56 AffineTransform destContextCTM = destContext->getCTM(GraphicsContext::Defini telyIncludeDeviceScale); 56 AffineTransform destContextCTM = destContext->getCTM(GraphicsContext::Defini telyIncludeDeviceScale);
57 double xScale = fabs(destContextCTM.xScale()); 57 double xScale = fabs(destContextCTM.xScale());
58 double yScale = fabs(destContextCTM.yScale()); 58 double yScale = fabs(destContextCTM.yScale());
59 AffineTransform adjustedPatternCTM = patternTransform; 59 AffineTransform adjustedPatternCTM = patternTransform;
60 adjustedPatternCTM.scale(1.0 / xScale, 1.0 / yScale); 60 adjustedPatternCTM.scale(1.0 / xScale, 1.0 / yScale);
61 adjustedSrcRect.scale(xScale, yScale); 61 adjustedSrcRect.scale(xScale, yScale);
62 62
63 unsigned generatorHash = m_gradient->hash(); 63 unsigned generatorHash = m_gradient->hash();
64 64
65 if (!m_cachedImageBuffer || m_cachedGeneratorHash != generatorHash || m_cach edAdjustedSize != adjustedSize || !destContext->isCompatibleWithBuffer(m_cachedI mageBuffer.get())) { 65 if (!m_cachedImageBuffer || m_cachedGeneratorHash != generatorHash || m_cach edAdjustedSize != adjustedSize || !destContext->isCompatibleWithBuffer(m_cachedI mageBuffer.get())) {
66 m_cachedImageBuffer = destContext->createCompatibleBuffer(adjustedSize, m_gradient->hasAlpha()); 66 m_cachedImageBuffer = destContext->createCompatibleBuffer(adjustedSize, m_gradient->hasAlpha());
67 if (!m_cachedImageBuffer) 67 if (!m_cachedImageBuffer)
68 return; 68 return;
69 69
70 // Fill with the generated image. 70 // Fill with the generated image.
71 m_cachedImageBuffer->context()->fillRect(FloatRect(FloatPoint(), adjuste dSize), *m_gradient); 71 m_cachedImageBuffer->context()->fillRect(FloatRect(FloatPoint(), adjuste dSize), *m_gradient);
72 72
73 m_cachedGeneratorHash = generatorHash; 73 m_cachedGeneratorHash = generatorHash;
74 m_cachedAdjustedSize = adjustedSize; 74 m_cachedAdjustedSize = adjustedSize;
75 } 75 }
76 76
77 // Tile the image buffer into the context. 77 // Tile the image buffer into the context.
78 m_cachedImageBuffer->drawPattern(destContext, adjustedSrcRect, adjustedPatte rnCTM, phase, styleColorSpace, compositeOp, destRect); 78 m_cachedImageBuffer->drawPattern(destContext, adjustedSrcRect, adjustedPatte rnCTM, phase, compositeOp, destRect);
79 m_cacheTimer.restart(); 79 m_cacheTimer.restart();
80 } 80 }
81 81
82 void GeneratorGeneratedImage::invalidateCacheTimerFired(DeferrableOneShotTimer<G eneratorGeneratedImage>*) 82 void GeneratorGeneratedImage::invalidateCacheTimerFired(DeferrableOneShotTimer<G eneratorGeneratedImage>*)
83 { 83 {
84 m_cachedImageBuffer.clear(); 84 m_cachedImageBuffer.clear();
85 m_cachedAdjustedSize = IntSize(); 85 m_cachedAdjustedSize = IntSize();
86 } 86 }
87 87
88 void GeneratorGeneratedImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectIn fo) const 88 void GeneratorGeneratedImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectIn fo) const
89 { 89 {
90 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image); 90 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image);
91 GeneratedImage::reportMemoryUsage(memoryObjectInfo); 91 GeneratedImage::reportMemoryUsage(memoryObjectInfo);
92 info.addMember(m_gradient, "gradient"); 92 info.addMember(m_gradient, "gradient");
93 info.addMember(m_cachedImageBuffer, "cachedImageBuffer"); 93 info.addMember(m_cachedImageBuffer, "cachedImageBuffer");
94 info.addMember(m_cacheTimer, "cacheTimer"); 94 info.addMember(m_cacheTimer, "cacheTimer");
95 } 95 }
96 96
97 } 97 }
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/GeneratorGeneratedImage.h ('k') | Source/core/platform/graphics/GraphicsContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698