Commit be3e8666 authored by benjamin@webkit.org's avatar benjamin@webkit.org

Remove platform/graphic's Generator

https://bugs.webkit.org/show_bug.cgi?id=116084

Patch by Benjamin Poulain <bpoulain@apple.com> on 2013-05-13
Reviewed by Darin Adler.

The Generator no longer abstract anything useful, its only
implementation is Gradient.

* GNUmakefile.list.am:
* WebCore.exp.in:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/GeneratedImage.h:
* platform/graphics/Generator.h: Removed.
* platform/graphics/GeneratorGeneratedImage.cpp:
(WebCore::GeneratorGeneratedImage::draw):
(WebCore::GeneratorGeneratedImage::drawPattern):
* platform/graphics/GeneratorGeneratedImage.h:
(WebCore::GeneratorGeneratedImage::create):
(WebCore::GeneratorGeneratedImage::GeneratorGeneratedImage):
(GeneratorGeneratedImage):
* platform/graphics/Gradient.h:
(WebCore):
(Gradient):
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::fillRect):
* platform/graphics/GraphicsContext.h:
(WebCore):
(GraphicsContext):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150053 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e94bca80
2013-05-13 Benjamin Poulain <bpoulain@apple.com>
Remove platform/graphic's Generator
https://bugs.webkit.org/show_bug.cgi?id=116084
Reviewed by Darin Adler.
The Generator no longer abstract anything useful, its only
implementation is Gradient.
* GNUmakefile.list.am:
* WebCore.exp.in:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/GeneratedImage.h:
* platform/graphics/Generator.h: Removed.
* platform/graphics/GeneratorGeneratedImage.cpp:
(WebCore::GeneratorGeneratedImage::draw):
(WebCore::GeneratorGeneratedImage::drawPattern):
* platform/graphics/GeneratorGeneratedImage.h:
(WebCore::GeneratorGeneratedImage::create):
(WebCore::GeneratorGeneratedImage::GeneratorGeneratedImage):
(GeneratorGeneratedImage):
* platform/graphics/Gradient.h:
(WebCore):
(Gradient):
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::fillRect):
* platform/graphics/GraphicsContext.h:
(WebCore):
(GraphicsContext):
2013-05-13 David Kilzer <ddkilzer@apple.com>
Upstream iOS Clipboard and Pasteboard changes
......
......@@ -5679,7 +5679,6 @@ webcore_platform_sources += \
Source/WebCore/platform/graphics/LayoutSize.h \
Source/WebCore/platform/graphics/GeneratedImage.cpp \
Source/WebCore/platform/graphics/GeneratedImage.h \
Source/WebCore/platform/graphics/Generator.h \
Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp \
Source/WebCore/platform/graphics/GeneratorGeneratedImage.h \
Source/WebCore/platform/graphics/Glyph.h \
......
......@@ -67,6 +67,7 @@ __ZN3WTF10StringImplcvP8NSStringEv
__ZN3WTF12AtomicString3addEPK10__CFString
__ZN3WTF6StringC1EP8NSString
__ZN3WTF6StringC1EPK10__CFString
__ZN7WebCore8GradientD1Ev
__ZN7WebCore10ClientRectC1ERKNS_7IntRectE
__ZN7WebCore10ClientRectC1ERKNS_9FloatRectE
__ZN7WebCore10ClientRectC1Ev
......
......@@ -29993,10 +29993,6 @@
RelativePath="..\platform\graphics\GeneratedImage.h"
>
</File>
<File
RelativePath="..\platform\graphics\Generator.h"
>
</File>
<File
RelativePath="..\platform\graphics\GeneratorGeneratedImage.cpp"
>
......@@ -11666,7 +11666,6 @@
<ClInclude Include="..\platform\graphics\FontSmoothingMode.h" />
<ClInclude Include="..\platform\graphics\FontTraitsMask.h" />
<ClInclude Include="..\platform\graphics\GeneratedImage.h" />
<ClInclude Include="..\platform\graphics\Generator.h" />
<ClInclude Include="..\platform\graphics\Glyph.h" />
<ClInclude Include="..\platform\graphics\GlyphBuffer.h" />
<ClInclude Include="..\platform\graphics\GlyphMetricsMap.h" />
......@@ -8193,9 +8193,6 @@
<ClInclude Include="..\platform\graphics\GeneratedImage.h">
<Filter>platform\graphics</Filter>
</ClInclude>
<ClInclude Include="..\platform\graphics\Generator.h">
<Filter>platform\graphics</Filter>
</ClInclude>
<ClInclude Include="..\platform\graphics\Glyph.h">
<Filter>platform\graphics</Filter>
</ClInclude>
......
......@@ -5001,7 +5001,6 @@
BCDFD4960E30592F009D10AD /* JSXMLHttpRequestUpload.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDFD4940E30592F009D10AD /* JSXMLHttpRequestUpload.h */; };
BCE0139A0C0BEF180043860A /* JSStyleSheet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE013980C0BEF180043860A /* JSStyleSheet.cpp */; };
BCE0139B0C0BEF180043860A /* JSStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE013990C0BEF180043860A /* JSStyleSheet.h */; };
BCE04C8A0DAFF7A0007A0F41 /* Generator.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE04C890DAFF7A0007A0F41 /* Generator.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCE1C41B0D982980003B02F2 /* Location.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE1C4190D982980003B02F2 /* Location.h */; };
BCE1C41C0D982981003B02F2 /* Location.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE1C41A0D982980003B02F2 /* Location.cpp */; };
BCE1C43B0D9830D3003B02F2 /* JSLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE1C4390D9830D3003B02F2 /* JSLocation.cpp */; };
......@@ -11725,7 +11724,6 @@
BCDFD4940E30592F009D10AD /* JSXMLHttpRequestUpload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSXMLHttpRequestUpload.h; sourceTree = "<group>"; };
BCE013980C0BEF180043860A /* JSStyleSheet.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSStyleSheet.cpp; sourceTree = "<group>"; };
BCE013990C0BEF180043860A /* JSStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSStyleSheet.h; sourceTree = "<group>"; };
BCE04C890DAFF7A0007A0F41 /* Generator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Generator.h; sourceTree = "<group>"; };
BCE1C4190D982980003B02F2 /* Location.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Location.h; sourceTree = "<group>"; };
BCE1C41A0D982980003B02F2 /* Location.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Location.cpp; sourceTree = "<group>"; };
BCE1C4220D9829F2003B02F2 /* Location.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Location.idl; sourceTree = "<group>"; };
......@@ -18415,7 +18413,6 @@
BCE4413512F7490B009B84B8 /* FontWidthVariant.h */,
4FB390AC15EF61F3007AD51F /* GeneratedImage.cpp */,
BC23F0DA0DAFF4A4009FDC91 /* GeneratedImage.h */,
BCE04C890DAFF7A0007A0F41 /* Generator.h */,
2D2FC0561460CD6F00263633 /* GeneratorGeneratedImage.cpp */,
2D2FC0571460CD6F00263633 /* GeneratorGeneratedImage.h */,
086BBD0E136039C2008B15D8 /* Glyph.h */,
......@@ -21934,7 +21931,6 @@
1432E8470C51493800B1500F /* GCController.h in Headers */,
C0C054CC1118C8E400CE2636 /* generate-bindings.pl in Headers */,
BC23F0DB0DAFF4A4009FDC91 /* GeneratedImage.h in Headers */,
BCE04C8A0DAFF7A0007A0F41 /* Generator.h in Headers */,
2D481F04146B5C6B00AA7834 /* GeneratorGeneratedImage.h in Headers */,
A622A8FF122C44A600A785B3 /* GenericBinding.h in Headers */,
0720B0A114D3323500642955 /* GenericEventQueue.h in Headers */,
/*
* Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2008, 2013 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -28,7 +28,6 @@
#include "Image.h"
#include "Generator.h"
#include "IntSize.h"
#include <wtf/RefPtr.h>
......
/*
* Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef Generator_h
#define Generator_h
#include <wtf/RefCounted.h>
namespace WebCore {
class FloatRect;
class GraphicsContext;
class Generator : public RefCounted<Generator> {
public:
virtual ~Generator() {};
virtual void fill(GraphicsContext*, const FloatRect&) = 0;
virtual void adjustParametersForTiledDrawing(IntSize& /* size */, FloatRect& /* srcRect */) { }
virtual unsigned hash() const = 0;
virtual bool hasAlpha() const = 0;
};
} //namespace
#endif
/*
* Copyright (C) 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -41,7 +41,7 @@ void GeneratorGeneratedImage::draw(GraphicsContext* destContext, const FloatRect
if (destRect.size() != srcRect.size())
destContext->scale(FloatSize(destRect.width() / srcRect.width(), destRect.height() / srcRect.height()));
destContext->translate(-srcRect.x(), -srcRect.y());
destContext->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
destContext->fillRect(FloatRect(FloatPoint(), m_size), *m_gradient.get());
}
void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
......@@ -50,7 +50,7 @@ void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const Fl
// Allow the generator to provide visually-equivalent tiling parameters for better performance.
IntSize adjustedSize = m_size;
FloatRect adjustedSrcRect = srcRect;
m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
m_gradient->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
// Factor in the destination context's scale to generate at the best resolution
AffineTransform destContextCTM = destContext->getCTM(GraphicsContext::DefinitelyIncludeDeviceScale);
......@@ -60,15 +60,15 @@ void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const Fl
adjustedPatternCTM.scale(1.0 / xScale, 1.0 / yScale);
adjustedSrcRect.scale(xScale, yScale);
unsigned generatorHash = m_generator->hash();
unsigned generatorHash = m_gradient->hash();
if (!m_cachedImageBuffer || m_cachedGeneratorHash != generatorHash || m_cachedAdjustedSize != adjustedSize || !destContext->isCompatibleWithBuffer(m_cachedImageBuffer.get())) {
m_cachedImageBuffer = destContext->createCompatibleBuffer(adjustedSize, m_generator->hasAlpha());
m_cachedImageBuffer = destContext->createCompatibleBuffer(adjustedSize, m_gradient->hasAlpha());
if (!m_cachedImageBuffer)
return;
// Fill with the generated image.
m_cachedImageBuffer->context()->fillRect(FloatRect(FloatPoint(), adjustedSize), *m_generator);
m_cachedImageBuffer->context()->fillRect(FloatRect(FloatPoint(), adjustedSize), *m_gradient);
m_cachedGeneratorHash = generatorHash;
m_cachedAdjustedSize = adjustedSize;
......
/*
* Copyright (C) 2008, 2012 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2008, 2012, 2013 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -27,7 +27,7 @@
#define GeneratorGeneratedImage_h
#include "GeneratedImage.h"
#include "Generator.h"
#include "Gradient.h"
#include "Image.h"
#include "ImageBuffer.h"
#include "IntSize.h"
......@@ -37,7 +37,7 @@ namespace WebCore {
class GeneratorGeneratedImage : public GeneratedImage {
public:
static PassRefPtr<GeneratorGeneratedImage> create(PassRefPtr<Generator> generator, const IntSize& size)
static PassRefPtr<GeneratorGeneratedImage> create(PassRefPtr<Gradient> generator, const IntSize& size)
{
return adoptRef(new GeneratorGeneratedImage(generator, size));
}
......@@ -49,13 +49,13 @@ protected:
virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode);
GeneratorGeneratedImage(PassRefPtr<Generator> generator, const IntSize& size)
: m_generator(generator)
GeneratorGeneratedImage(PassRefPtr<Gradient> generator, const IntSize& size)
: m_gradient(generator)
{
m_size = size;
}
RefPtr<Generator> m_generator;
RefPtr<Gradient> m_gradient;
OwnPtr<ImageBuffer> m_cachedImageBuffer;
IntSize m_cachedAdjustedSize;
unsigned m_cachedGeneratorHash;
......
/*
* Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007, 2008, 2011, 2012, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2007 Alp Toker <alp@atoker.com>
* Copyright (C) 2008 Torch Mobile, Inc.
*
......@@ -30,9 +30,9 @@
#include "AffineTransform.h"
#include "FloatPoint.h"
#include "Generator.h"
#include "GraphicsTypes.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
#if USE(CG)
......@@ -66,8 +66,10 @@ typedef void* PlatformGradient;
namespace WebCore {
class Color;
class FloatRect;
class GraphicsContext;
class Gradient : public Generator {
class Gradient : public RefCounted<Gradient> {
public:
static PassRefPtr<Gradient> create(const FloatPoint& p0, const FloatPoint& p1)
{
......@@ -77,14 +79,14 @@ namespace WebCore {
{
return adoptRef(new Gradient(p0, r0, p1, r1, aspectRatio));
}
virtual ~Gradient();
~Gradient();
struct ColorStop;
void addColorStop(const ColorStop&);
void addColorStop(float, const Color&);
void getColor(float value, float* r, float* g, float* b, float* a) const;
virtual bool hasAlpha() const OVERRIDE;
bool hasAlpha() const;
bool isRadial() const { return m_radial; }
bool isZeroSize() const { return m_p0.x() == m_p1.x() && m_p0.y() == m_p1.y() && (!m_radial || m_r0 == m_r1); }
......@@ -162,12 +164,12 @@ namespace WebCore {
// Qt and CG transform the gradient at draw time
AffineTransform gradientSpaceTransform() { return m_gradientSpaceTransformation; }
virtual void fill(GraphicsContext*, const FloatRect&);
virtual void adjustParametersForTiledDrawing(IntSize& size, FloatRect& srcRect);
void fill(GraphicsContext*, const FloatRect&);
void adjustParametersForTiledDrawing(IntSize&, FloatRect&);
void setPlatformGradientSpaceTransform(const AffineTransform& gradientSpaceTransformation);
virtual unsigned hash() const OVERRIDE;
unsigned hash() const;
void invalidateHash() { m_cachedHash = 0; }
#if USE(CG)
......
/*
* Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2003, 2004, 2005, 2006, 2009, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -28,7 +28,7 @@
#include "BidiResolver.h"
#include "BitmapImage.h"
#include "Generator.h"
#include "Gradient.h"
#include "ImageBuffer.h"
#include "IntRect.h"
#include "RoundedRect.h"
......@@ -664,11 +664,11 @@ void GraphicsContext::setTextDrawingMode(TextDrawingModeFlags mode)
setPlatformTextDrawingMode(mode);
}
void GraphicsContext::fillRect(const FloatRect& rect, Generator& generator)
void GraphicsContext::fillRect(const FloatRect& rect, Gradient& gradient)
{
if (paintingDisabled())
return;
generator.fill(this, rect);
gradient.fill(this, rect);
}
void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace styleColorSpace, CompositeOperator op, BlendMode blendMode)
......
/*
* Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2003, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2008-2009 Torch Mobile, Inc.
*
* Redistribution and use in source and binary forms, with or without
......@@ -82,7 +82,7 @@ namespace WebCore {
class AffineTransform;
class DrawingBuffer;
class Generator;
class Gradient;
class GraphicsContextPlatformPrivate;
class ImageBuffer;
class IntRect;
......@@ -270,7 +270,7 @@ namespace WebCore {
void fillRect(const FloatRect&);
void fillRect(const FloatRect&, const Color&, ColorSpace);
void fillRect(const FloatRect&, Generator&);
void fillRect(const FloatRect&, Gradient&);
void fillRect(const FloatRect&, const Color&, ColorSpace, CompositeOperator, BlendMode = BlendModeNormal);
void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace);
void fillRoundedRect(const RoundedRect&, const Color&, ColorSpace, BlendMode = BlendModeNormal);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment