Skip to content

Commit 15462ff

Browse files
author
David Hyatt
committed
More refactoring of image to disentangle graphics (e.g., Cairo) from
platform (e.g., Windows). * WebCore.vcproj/WebCore/WebCore.vcproj: Add ImageWin to project. * loader/Cache.cpp: (WebCore::Cache::init): * loader/icon/IconDataCache.cpp: (WebCore::IconDataCache::loadImageFromResource): Renamed loadResource to loadPlatformResource to try to make it more clear that this call is implemented on each OS (and not by graphics libraries). * platform/Image.cpp: (WebCore::Image::Image): (WebCore::Image::~Image): (WebCore::Image::invalidateData): (WebCore::Image::size): (WebCore::Image::setData): (WebCore::Image::setNativeData): Fix up the PDF code to not be considered platform data any more, since PDF rendering is not for a specific OS. Renamed the methods that set OS-specific data (like NSImage) to PlatformData instead of NativeData. * platform/Image.h: Shifted the PDF members into CG defines. Made CGImageRef a CG define. Renamed methods to reflect that they are OS-specific and not graphics-library-specific. * platform/cairo/ImageCairo.cpp: Removed the platform data methods. Other platforms besides Windows that use Cairo will need to account for this change by adding these methods to their OS Image***.cpp file. * platform/cg/ImageCG.cpp: (WebCore::Image::drawTiled): Add FIXMEs to the wkpattern stuff. * platform/cg/PDFDocumentImage.cpp: Shouldn't have #imports in .cpp. * platform/mac/ImageMac.mm: (WebCore::Image::initPlatformData): (WebCore::Image::invalidatePlatformData): (WebCore::Image::loadPlatformResource): (WebCore::Image::getTIFFRepresentation): Add the platform data initializers to the Mac Image file. Move the TIFF representation there as well, since this is only used by Mac code. * platform/win/ImageWin.cpp: Added. (WebCore::Image::initPlatformData): (WebCore::Image::invalidatePlatformData): (WebCore::Image::loadPlatformResource): (WebCore::Image::supportsType): Similar work for Windows. Add stubs for possible future HBITMAP returns in the platform data methods. * rendering/RenderLayer.cpp: (WebCore::RenderLayer::paintResizeControl): * rendering/RenderThemeMac.mm: (WebCore::RenderThemeMac::paintResizeControl): loadResource -> loadPlatformResource Canonical link: https://commits.webkit.org/13444@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16048 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 1f8a47b commit 15462ff

14 files changed

Lines changed: 259 additions & 118 deletions

File tree

WebCore/ChangeLog

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,70 @@
1+
2006-08-25 David Hyatt <hyatt@apple.com>
2+
3+
More refactoring of image to disentangle graphics (e.g., Cairo) from
4+
platform (e.g., Windows).
5+
6+
* WebCore.vcproj/WebCore/WebCore.vcproj:
7+
Add ImageWin to project.
8+
9+
* loader/Cache.cpp:
10+
(WebCore::Cache::init):
11+
* loader/icon/IconDataCache.cpp:
12+
(WebCore::IconDataCache::loadImageFromResource):
13+
Renamed loadResource to loadPlatformResource to try to make it more clear
14+
that this call is implemented on each OS (and not by graphics libraries).
15+
16+
* platform/Image.cpp:
17+
(WebCore::Image::Image):
18+
(WebCore::Image::~Image):
19+
(WebCore::Image::invalidateData):
20+
(WebCore::Image::size):
21+
(WebCore::Image::setData):
22+
(WebCore::Image::setNativeData):
23+
Fix up the PDF code to not be considered platform data any more, since
24+
PDF rendering is not for a specific OS.
25+
26+
Renamed the methods that set OS-specific data (like NSImage) to PlatformData
27+
instead of NativeData.
28+
29+
* platform/Image.h:
30+
Shifted the PDF members into CG defines. Made CGImageRef a CG define.
31+
Renamed methods to reflect that they are OS-specific and not
32+
graphics-library-specific.
33+
34+
* platform/cairo/ImageCairo.cpp:
35+
Removed the platform data methods. Other platforms besides Windows that
36+
use Cairo will need to account for this change by adding these methods
37+
to their OS Image***.cpp file.
38+
39+
* platform/cg/ImageCG.cpp:
40+
(WebCore::Image::drawTiled):
41+
Add FIXMEs to the wkpattern stuff.
42+
43+
* platform/cg/PDFDocumentImage.cpp:
44+
Shouldn't have #imports in .cpp.
45+
46+
* platform/mac/ImageMac.mm:
47+
(WebCore::Image::initPlatformData):
48+
(WebCore::Image::invalidatePlatformData):
49+
(WebCore::Image::loadPlatformResource):
50+
(WebCore::Image::getTIFFRepresentation):
51+
Add the platform data initializers to the Mac Image file. Move the
52+
TIFF representation there as well, since this is only used by Mac code.
53+
54+
* platform/win/ImageWin.cpp: Added.
55+
(WebCore::Image::initPlatformData):
56+
(WebCore::Image::invalidatePlatformData):
57+
(WebCore::Image::loadPlatformResource):
58+
(WebCore::Image::supportsType):
59+
Similar work for Windows. Add stubs for possible future HBITMAP returns
60+
in the platform data methods.
61+
62+
* rendering/RenderLayer.cpp:
63+
(WebCore::RenderLayer::paintResizeControl):
64+
* rendering/RenderThemeMac.mm:
65+
(WebCore::RenderThemeMac::paintResizeControl):
66+
loadResource -> loadPlatformResource
67+
168
2006-08-26 Adam Roben <aroben@apple.com>
269

370
Rubber-stamped by Adele.

WebCore/WebCore.vcproj/WebCore/WebCore.vcproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,11 @@
15971597
RelativePath="..\..\platform\win\GlyphMapWin.cpp"
15981598
>
15991599
</File>
1600+
<File
1601+
RelativePath="..\..\platform\win\ImageWin.cpp"
1602+
>
1603+
</File>
1604+
16001605
<File
16011606
RelativePath="..\..\platform\win\IntPointWin.cpp"
16021607
>

WebCore/WebCore.xcodeproj/project.pbxproj

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,23 @@
16111611
FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
16121612
/* End PBXBuildFile section */
16131613

1614+
/* Begin PBXBuildStyle section */
1615+
BC57BF170AA0243000A43CF1 /* Development */ = {
1616+
isa = PBXBuildStyle;
1617+
buildSettings = {
1618+
COPY_PHASE_STRIP = NO;
1619+
};
1620+
name = Development;
1621+
};
1622+
BC57BF180AA0243000A43CF1 /* Deployment */ = {
1623+
isa = PBXBuildStyle;
1624+
buildSettings = {
1625+
COPY_PHASE_STRIP = YES;
1626+
};
1627+
name = Deployment;
1628+
};
1629+
/* End PBXBuildStyle section */
1630+
16141631
/* Begin PBXContainerItemProxy section */
16151632
DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
16161633
isa = PBXContainerItemProxy;
@@ -6462,6 +6479,12 @@
64626479
0867D690FE84028FC02AAC07 /* Project object */ = {
64636480
isa = PBXProject;
64646481
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
6482+
buildSettings = {
6483+
};
6484+
buildStyles = (
6485+
BC57BF170AA0243000A43CF1 /* Development */,
6486+
BC57BF180AA0243000A43CF1 /* Deployment */,
6487+
);
64656488
hasScannedForEncodings = 1;
64666489
knownRegions = (
64676490
English,

WebCore/loader/Cache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void Cache::init()
8888
nullImage = new Image;
8989

9090
if (!brokenImage)
91-
brokenImage = Image::loadResource("missingImage");
91+
brokenImage = Image::loadPlatformResource("missingImage");
9292

9393
if (!m_loader)
9494
m_loader = new Loader();

WebCore/loader/icon/IconDataCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void IconDataCache::loadImageFromResource(const char* resource)
9191
if (!resource)
9292
return;
9393
delete m_image;
94-
m_image = Image::loadResource(resource);
94+
m_image = Image::loadPlatformResource(resource);
9595
m_dataSet = true;
9696
}
9797

WebCore/platform/Image.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "Timer.h"
3636
#include <wtf/Vector.h>
3737

38-
#if __APPLE__
38+
#if PLATFORM(CG)
3939
// FIXME: Will go away when we make PDF a subclass.
4040
#include "PDFDocumentImage.h"
4141
#endif
@@ -52,7 +52,11 @@ Image::Image()
5252
m_isSolidColor(false), m_animatingImageType(true), m_animationFinished(false),
5353
m_haveSize(false), m_sizeAvailable(false)
5454
{
55-
initNativeData();
55+
#if PLATFORM(CG)
56+
m_isPDF = false; // FIXME: Will go away when we make PDF a subclass.
57+
m_PDFDoc = 0;
58+
#endif
59+
initPlatformData();
5660
}
5761

5862
Image::Image(ImageAnimationObserver* observer, bool isPDF)
@@ -61,10 +65,10 @@ Image::Image(ImageAnimationObserver* observer, bool isPDF)
6165
m_isSolidColor(false), m_animatingImageType(true), m_animationFinished(false),
6266
m_haveSize(false), m_sizeAvailable(false)
6367
{
64-
initNativeData();
65-
#if __APPLE__
66-
if (isPDF)
67-
setIsPDF(); // FIXME: Will go away when we make PDF a subclass.
68+
initPlatformData();
69+
#if PLATFORM(CG)
70+
m_isPDF = isPDF; // FIXME: Will go away when we make PDF a subclass.
71+
m_PDFDoc = 0;
6872
#endif
6973
m_animationObserver = observer;
7074
}
@@ -73,7 +77,9 @@ Image::~Image()
7377
{
7478
invalidateData();
7579
stopAnimation();
76-
destroyNativeData();
80+
#if PLATFORM(CG)
81+
delete m_PDFDoc; // FIXME: Will go away when we make a PDF image subclass.
82+
#endif
7783
}
7884

7985
void Image::invalidateData()
@@ -82,7 +88,7 @@ void Image::invalidateData()
8288
if (m_frames.size()) {
8389
m_frames.last().clear();
8490
m_isSolidColor = false;
85-
invalidateNativeData();
91+
invalidatePlatformData();
8692
}
8793
}
8894

@@ -115,7 +121,7 @@ bool Image::isNull() const
115121

116122
IntSize Image::size() const
117123
{
118-
#if __APPLE__
124+
#if PLATFORM(CG)
119125
// FIXME: Will go away when we make PDF a subclass.
120126
if (m_isPDF) {
121127
if (m_PDFDoc) {
@@ -148,7 +154,7 @@ bool Image::setData(bool allDataReceived)
148154
}
149155
#endif
150156

151-
#if __APPLE__
157+
#if PLATFORM(CG)
152158
// Avoid the extra copy of bytes by just handing the byte array directly to a CFDataRef.
153159
CFDataRef data = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(m_data.data()), length, kCFAllocatorNull);
154160
bool result = setNativeData(data, allDataReceived);
@@ -162,7 +168,7 @@ bool Image::setData(bool allDataReceived)
162168

163169
bool Image::setNativeData(NativeBytePtr data, bool allDataReceived)
164170
{
165-
#if __APPLE__
171+
#if PLATFORM(CG)
166172
// FIXME: Will go away when we make PDF a subclass.
167173
if (m_isPDF) {
168174
if (allDataReceived && !m_PDFDoc)

WebCore/platform/Image.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class Image : Noncopyable {
9999
Image(ImageAnimationObserver* observer, bool isPDF = false);
100100
~Image();
101101

102-
static Image* loadResource(const char *name);
102+
static Image* loadPlatformResource(const char *name);
103103
static bool supportsType(const String& type);
104104

105105
bool isNull() const;
@@ -134,12 +134,12 @@ class Image : Noncopyable {
134134

135135
#if PLATFORM(MAC)
136136
// Accessors for native image formats.
137-
CGImageRef getCGImageRef();
138137
NSImage* getNSImage();
139138
CFDataRef getTIFFRepresentation();
139+
#endif
140140

141-
// PDF
142-
void setIsPDF() { m_isPDF = true; }
141+
#if PLATFORM(CG)
142+
CGImageRef getCGImageRef();
143143
#endif
144144

145145
private:
@@ -163,14 +163,11 @@ class Image : Noncopyable {
163163
void startAnimation();
164164
void advanceAnimation(Timer<Image>* timer);
165165

166-
// Constructor for native data.
167-
void initNativeData();
168-
169-
// Destructor for native data.
170-
void destroyNativeData();
166+
// Constructor for OS-specific data.
167+
void initPlatformData();
171168

172169
// Invalidation of native data.
173-
void invalidateNativeData();
170+
void invalidatePlatformData();
174171

175172
// Checks to see if the image is a 1x1 solid color. We optimize these images and just do a fill rect instead.
176173
void checkForSolidColor();
@@ -192,6 +189,9 @@ class Image : Noncopyable {
192189
#if PLATFORM(MAC)
193190
mutable NSImage* m_nsImage; // A cached NSImage of frame 0. Only built lazily if someone actually queries for one.
194191
mutable CFDataRef m_tiffRep; // Cached TIFF rep for frame 0. Only built lazily if someone queries for one.
192+
#endif
193+
194+
#if PLATFORM(CG)
195195
PDFDocumentImage* m_PDFDoc;
196196
bool m_isPDF;
197197
#endif

WebCore/platform/cairo/ImageCairo.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
#include <cairo.h>
3434
#include <math.h>
3535

36-
// This function loads resources from WebKit
37-
Vector<char> loadResourceIntoArray(const char*);
38-
3936
namespace WebCore {
4037

4138
void FrameData::clear()
@@ -52,32 +49,6 @@ void FrameData::clear()
5249
// Image Class
5350
// ================================================
5451

55-
void Image::initNativeData()
56-
{
57-
}
58-
59-
void Image::destroyNativeData()
60-
{
61-
}
62-
63-
void Image::invalidateNativeData()
64-
{
65-
}
66-
67-
Image* Image::loadResource(const char *name)
68-
{
69-
Vector<char> arr = loadResourceIntoArray(name);
70-
Image* img = new Image;
71-
img->setNativeData(&arr, true);
72-
return img;
73-
}
74-
75-
bool Image::supportsType(const String& type)
76-
{
77-
// FIXME: Implement.
78-
return false;
79-
}
80-
8152
// Drawing Routines
8253

8354
static void setCompositingOperation(cairo_t* context, CompositeOperator op, bool hasAlpha)

0 commit comments

Comments
 (0)