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

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

Issue 10787031: Revert 120033 - GeneratorGeneratedImage should cache images for the non-tiled case (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1180/
Patch Set: Created 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "GeneratorGeneratedImage.h" 27 #include "GeneratorGeneratedImage.h"
28 28
29 #include "FloatRect.h" 29 #include "FloatRect.h"
30 #include "GraphicsContext.h" 30 #include "GraphicsContext.h"
31 #include "Length.h" 31 #include "Length.h"
32 32
33 namespace WebCore { 33 namespace WebCore {
34 34
35 void GeneratorGeneratedImage::draw(GraphicsContext* destContext, const FloatRect & destRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOpera tor compositeOp) 35 void GeneratorGeneratedImage::draw(GraphicsContext* destContext, const FloatRect & destRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
36 { 36 {
37 unsigned generatorHash = m_generator->hash(); 37 GraphicsContextStateSaver stateSaver(*destContext);
38 if (!m_cachedImageBuffer || m_cachedGeneratorHash != generatorHash || m_cach edAdjustedSize != m_size || !destContext->isCompatibleWithBuffer(m_cachedImageBu ffer.get())) { 38 destContext->setCompositeOperation(compositeOp);
39 // Create a BitmapImage and call draw on it. 39 destContext->clip(destRect);
40 m_cachedImageBuffer = destContext->createCompatibleBuffer(m_size); 40 destContext->translate(destRect.x(), destRect.y());
41 if (!m_cachedImageBuffer) 41 if (destRect.size() != srcRect.size())
42 return; 42 destContext->scale(FloatSize(destRect.width() / srcRect.width(), destRec t.height() / srcRect.height()));
43 43 destContext->translate(-srcRect.x(), -srcRect.y());
44 // Fill with the generated image. 44 destContext->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
45 m_cachedImageBuffer->context()->fillRect(FloatRect(FloatPoint(), m_size) , *m_generator);
46
47 m_cachedGeneratorHash = generatorHash;
48 m_cachedAdjustedSize = m_size;
49 }
50
51 // Draw the image buffer to the destination
52 m_cachedImageBuffer->draw(destContext, styleColorSpace, destRect, srcRect, c ompositeOp);
53 m_cacheTimer.restart();
54 } 45 }
55 46
56 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,
57 const FloatPoint& phase, ColorSpace styleColorS pace, CompositeOperator compositeOp, const FloatRect& destRect) 48 const FloatPoint& phase, ColorSpace styleColorS pace, CompositeOperator compositeOp, const FloatRect& destRect)
58 { 49 {
59 // 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.
60 IntSize adjustedSize = m_size; 51 IntSize adjustedSize = m_size;
61 FloatRect adjustedSrcRect = srcRect; 52 FloatRect adjustedSrcRect = srcRect;
62 m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect); 53 m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
63 54
(...skipping 30 matching lines...) Expand all
94 intrinsicRatio = FloatSize(); 85 intrinsicRatio = FloatSize();
95 } 86 }
96 87
97 void GeneratorGeneratedImage::invalidateCacheTimerFired(DeferrableOneShotTimer<G eneratorGeneratedImage>*) 88 void GeneratorGeneratedImage::invalidateCacheTimerFired(DeferrableOneShotTimer<G eneratorGeneratedImage>*)
98 { 89 {
99 m_cachedImageBuffer.clear(); 90 m_cachedImageBuffer.clear();
100 m_cachedAdjustedSize = IntSize(); 91 m_cachedAdjustedSize = IntSize();
101 } 92 }
102 93
103 } 94 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698