+2012-08-30 Dan Bernstein <mitz@apple.com>
+
+ [CG] ImageCG.cpp contains a mix of Image and BitmapImage functions
+ https://bugs.webkit.org/show_bug.cgi?id=95470
+
+ Reviewed by Darin Adler.
+
+ * WebCore.gypi: Added BitmapImageCG.cpp.
+ * WebCore.vcproj/WebCore.vcproj: Ditto.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+ * platform/graphics/cg/BitmapImageCG.cpp: Copied from Source/WebCore/platform/graphics/cg/ImageCG.cpp
+ then deleted Image function implementations.
+ * platform/graphics/cg/ImageCG.cpp: Deleted BitmapImage and FrameData function implementations.
+
2012-08-30 Victor Carbune <victor@rosedu.org>
[Chromium] The CC button is not painted
'platform/graphics/cairo/RefPtrCairo.cpp',
'platform/graphics/cairo/RefPtrCairo.h',
'platform/graphics/cairo/TransformationMatrixCairo.cpp',
+ 'platform/graphics/cg/BitmapImageCG.cpp',
'platform/graphics/cg/ColorCG.cpp',
'platform/graphics/cg/FloatPointCG.cpp',
'platform/graphics/cg/FloatRectCG.cpp',
Name="cg"
>
<File
+ RelativePath="..\platform\graphics\cg\BitmapImageCG.cpp"
+ >
+ <FileConfiguration
+ Name="Debug_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
RelativePath="..\platform\graphics\cg\ColorCG.cpp"
>
<FileConfiguration
375CD23B119D44EA00A2A859 /* HyphenationMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 375CD239119D44EA00A2A859 /* HyphenationMac.mm */; };
376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 376DCCE013B4F966002EBEFC /* TextRun.cpp */; };
3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 377A3A9015EFCE9B0059F5C7 /* BitmapImageCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */; };
377C4CDF1014E9F600B9AE42 /* PlaceholderDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 377C4CDD1014E9F600B9AE42 /* PlaceholderDocument.h */; };
377C4CE01014E9F600B9AE42 /* PlaceholderDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 377C4CDE1014E9F600B9AE42 /* PlaceholderDocument.cpp */; };
3784C34B0E11AA34007D8D48 /* FontTraitsMask.h in Headers */ = {isa = PBXBuildFile; fileRef = 3784C34A0E11AA34007D8D48 /* FontTraitsMask.h */; settings = {ATTRIBUTES = (Private, ); }; };
375CD239119D44EA00A2A859 /* HyphenationMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HyphenationMac.mm; sourceTree = "<group>"; };
376DCCE013B4F966002EBEFC /* TextRun.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextRun.cpp; sourceTree = "<group>"; };
3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverlapTestRequestClient.h; sourceTree = "<group>"; };
+ 377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BitmapImageCG.cpp; sourceTree = "<group>"; };
377C4CDD1014E9F600B9AE42 /* PlaceholderDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaceholderDocument.h; sourceTree = "<group>"; };
377C4CDE1014E9F600B9AE42 /* PlaceholderDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlaceholderDocument.cpp; sourceTree = "<group>"; };
3784C34A0E11AA34007D8D48 /* FontTraitsMask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontTraitsMask.h; sourceTree = "<group>"; };
B27535290B053814002CE64F /* cg */ = {
isa = PBXGroup;
children = (
+ 377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */,
0FCF33230F2B9715004B6795 /* ColorCG.cpp */,
B275352B0B053814002CE64F /* FloatPointCG.cpp */,
B275352C0B053814002CE64F /* FloatRectCG.cpp */,
FBD6AF8B15EF25E5008B7110 /* CSSBasicShapes.cpp in Sources */,
FBD6AF8D15EF260A008B7110 /* BasicShapes.cpp in Sources */,
4FB390AD15EF61F3007AD51F /* GeneratedImage.cpp in Sources */,
+ 377A3A9015EFCE9B0059F5C7 /* BitmapImageCG.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- /dev/null
+/*
+ * Copyright (C) 2004, 2005, 2006 Apple 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.
+ */
+
+#include "config.h"
+#include "BitmapImage.h"
+
+#if USE(CG)
+
+#include "FloatConversion.h"
+#include "GraphicsContextCG.h"
+#include "ImageObserver.h"
+#include <ApplicationServices/ApplicationServices.h>
+#include <wtf/RetainPtr.h>
+
+#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
+#include "WebCoreSystemInterface.h"
+#endif
+
+#if PLATFORM(WIN)
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#endif
+
+namespace WebCore {
+
+bool FrameData::clear(bool clearMetadata)
+{
+ if (clearMetadata)
+ m_haveMetadata = false;
+
+ m_orientation = DefaultImageOrientation;
+
+ if (m_frame) {
+ CGImageRelease(m_frame);
+ m_frame = 0;
+ return true;
+ }
+ return false;
+}
+
+BitmapImage::BitmapImage(CGImageRef cgImage, ImageObserver* observer)
+ : Image(observer)
+ , m_currentFrame(0)
+ , m_frames(0)
+ , m_frameTimer(0)
+ , m_repetitionCount(cAnimationNone)
+ , m_repetitionCountStatus(Unknown)
+ , m_repetitionsComplete(0)
+ , m_decodedSize(0)
+ , m_decodedPropertiesSize(0)
+ , m_frameCount(1)
+ , m_isSolidColor(false)
+ , m_checkedForSolidColor(false)
+ , m_animationFinished(true)
+ , m_allDataReceived(true)
+ , m_haveSize(true)
+ , m_sizeAvailable(true)
+ , m_haveFrameCount(true)
+{
+ CGFloat width = CGImageGetWidth(cgImage);
+ CGFloat height = CGImageGetHeight(cgImage);
+ m_decodedSize = width * height * 4;
+ m_size = IntSize(width, height);
+
+ // Since we don't have a decoder, we can't figure out the image orientation.
+ // Set m_sizeRespectingOrientation to be the same as m_size so it's not 0x0.
+ m_sizeRespectingOrientation = IntSize(width, height);
+
+ m_frames.grow(1);
+ m_frames[0].m_frame = cgImage;
+ m_frames[0].m_hasAlpha = true;
+ m_frames[0].m_haveMetadata = true;
+
+ checkForSolidColor();
+}
+
+// Drawing Routines
+
+void BitmapImage::checkForSolidColor()
+{
+ m_checkedForSolidColor = true;
+ if (frameCount() > 1) {
+ m_isSolidColor = false;
+ return;
+ }
+
+ CGImageRef image = frameAtIndex(0);
+
+ // Currently we only check for solid color in the important special case of a 1x1 image.
+ if (image && CGImageGetWidth(image) == 1 && CGImageGetHeight(image) == 1) {
+ unsigned char pixel[4]; // RGBA
+ RetainPtr<CGContextRef> bmap(AdoptCF, CGBitmapContextCreate(pixel, 1, 1, 8, sizeof(pixel), deviceRGBColorSpaceRef(),
+ kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big));
+ if (!bmap)
+ return;
+ GraphicsContext(bmap.get()).setCompositeOperation(CompositeCopy);
+ CGRect dst = { {0, 0}, {1, 1} };
+ CGContextDrawImage(bmap.get(), dst, image);
+ if (pixel[3] == 0)
+ m_solidColor = Color(0, 0, 0, 0);
+ else
+ m_solidColor = Color(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]);
+ m_isSolidColor = true;
+ }
+}
+
+CGImageRef BitmapImage::getCGImageRef()
+{
+ return frameAtIndex(0);
+}
+
+CGImageRef BitmapImage::getFirstCGImageRefOfSize(const IntSize& size)
+{
+ size_t count = frameCount();
+ for (size_t i = 0; i < count; ++i) {
+ CGImageRef cgImage = frameAtIndex(i);
+ if (cgImage && IntSize(CGImageGetWidth(cgImage), CGImageGetHeight(cgImage)) == size)
+ return cgImage;
+ }
+
+ // Fallback to the default CGImageRef if we can't find the right size
+ return getCGImageRef();
+}
+
+RetainPtr<CFArrayRef> BitmapImage::getCGImageArray()
+{
+ size_t count = frameCount();
+ if (!count)
+ return 0;
+
+ CFMutableArrayRef array = CFArrayCreateMutable(NULL, count, &kCFTypeArrayCallBacks);
+ for (size_t i = 0; i < count; ++i) {
+ if (CGImageRef currFrame = frameAtIndex(i))
+ CFArrayAppendValue(array, currFrame);
+ }
+ return RetainPtr<CFArrayRef>(AdoptCF, array);
+}
+
+void BitmapImage::draw(GraphicsContext* ctx, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator op)
+{
+ draw(ctx, dstRect, srcRect, styleColorSpace, op, DoNotRespectImageOrientation);
+}
+
+void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& destRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, RespectImageOrientationEnum shouldRespectImageOrientation)
+{
+ startAnimation();
+
+ CGImageRef image = frameAtIndex(m_currentFrame);
+ if (!image) // If it's too early we won't have an image yet.
+ return;
+
+ if (mayFillWithSolidColor()) {
+ fillWithSolidColor(ctxt, destRect, solidColor(), styleColorSpace, compositeOp);
+ return;
+ }
+
+ FloatSize selfSize = currentFrameSize();
+ ImageOrientation orientation = DefaultImageOrientation;
+
+ if (shouldRespectImageOrientation == RespectImageOrientation)
+ orientation = frameOrientationAtIndex(m_currentFrame);
+
+ ctxt->drawNativeImage(image, selfSize, styleColorSpace, destRect, srcRect, compositeOp, orientation);
+
+ if (imageObserver())
+ imageObserver()->didDraw(this);
+}
+
+}
+
+#endif // USE(CG)
*/
#include "config.h"
-#include "BitmapImage.h"
+#include "Image.h"
#if USE(CG)
-#include "AffineTransform.h"
#include "FloatConversion.h"
#include "FloatRect.h"
#include "GraphicsContextCG.h"
#include "ImageObserver.h"
-#include "PDFDocumentImage.h"
-#include "PlatformString.h"
#include <ApplicationServices/ApplicationServices.h>
-#include <CoreFoundation/CFArray.h>
#include <wtf/RetainPtr.h>
#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
namespace WebCore {
-bool FrameData::clear(bool clearMetadata)
-{
- if (clearMetadata)
- m_haveMetadata = false;
-
- m_orientation = DefaultImageOrientation;
-
- if (m_frame) {
- CGImageRelease(m_frame);
- m_frame = 0;
- return true;
- }
- return false;
-}
-
-// ================================================
-// Image Class
-// ================================================
-
-BitmapImage::BitmapImage(CGImageRef cgImage, ImageObserver* observer)
- : Image(observer)
- , m_currentFrame(0)
- , m_frames(0)
- , m_frameTimer(0)
- , m_repetitionCount(cAnimationNone)
- , m_repetitionCountStatus(Unknown)
- , m_repetitionsComplete(0)
- , m_decodedSize(0)
- , m_decodedPropertiesSize(0)
- , m_frameCount(1)
- , m_isSolidColor(false)
- , m_checkedForSolidColor(false)
- , m_animationFinished(true)
- , m_allDataReceived(true)
- , m_haveSize(true)
- , m_sizeAvailable(true)
- , m_haveFrameCount(true)
-{
- CGFloat width = CGImageGetWidth(cgImage);
- CGFloat height = CGImageGetHeight(cgImage);
- m_decodedSize = width * height * 4;
- m_size = IntSize(width, height);
-
- // Since we don't have a decoder, we can't figure out the image orientation.
- // Set m_sizeRespectingOrientation to be the same as m_size so it's not 0x0.
- m_sizeRespectingOrientation = IntSize(width, height);
-
- m_frames.grow(1);
- m_frames[0].m_frame = cgImage;
- m_frames[0].m_hasAlpha = true;
- m_frames[0].m_haveMetadata = true;
-
- checkForSolidColor();
-}
-
-// Drawing Routines
-
-void BitmapImage::checkForSolidColor()
-{
- m_checkedForSolidColor = true;
- if (frameCount() > 1) {
- m_isSolidColor = false;
- return;
- }
-
- CGImageRef image = frameAtIndex(0);
-
- // Currently we only check for solid color in the important special case of a 1x1 image.
- if (image && CGImageGetWidth(image) == 1 && CGImageGetHeight(image) == 1) {
- unsigned char pixel[4]; // RGBA
- RetainPtr<CGContextRef> bmap(AdoptCF, CGBitmapContextCreate(pixel, 1, 1, 8, sizeof(pixel), deviceRGBColorSpaceRef(),
- kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big));
- if (!bmap)
- return;
- GraphicsContext(bmap.get()).setCompositeOperation(CompositeCopy);
- CGRect dst = { {0, 0}, {1, 1} };
- CGContextDrawImage(bmap.get(), dst, image);
- if (pixel[3] == 0)
- m_solidColor = Color(0, 0, 0, 0);
- else
- m_solidColor = Color(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]);
- m_isSolidColor = true;
- }
-}
-
RetainPtr<CGImageRef> Image::imageWithColorSpace(CGImageRef originalImage, ColorSpace colorSpace)
{
CGColorSpaceRef originalColorSpace = CGImageGetColorSpace(originalImage);
return originalImage;
}
-CGImageRef BitmapImage::getCGImageRef()
-{
- return frameAtIndex(0);
-}
-
-CGImageRef BitmapImage::getFirstCGImageRefOfSize(const IntSize& size)
-{
- size_t count = frameCount();
- for (size_t i = 0; i < count; ++i) {
- CGImageRef cgImage = frameAtIndex(i);
- if (cgImage && IntSize(CGImageGetWidth(cgImage), CGImageGetHeight(cgImage)) == size)
- return cgImage;
- }
-
- // Fallback to the default CGImageRef if we can't find the right size
- return getCGImageRef();
-}
-
-RetainPtr<CFArrayRef> BitmapImage::getCGImageArray()
-{
- size_t count = frameCount();
- if (!count)
- return 0;
-
- CFMutableArrayRef array = CFArrayCreateMutable(NULL, count, &kCFTypeArrayCallBacks);
- for (size_t i = 0; i < count; ++i) {
- if (CGImageRef currFrame = frameAtIndex(i))
- CFArrayAppendValue(array, currFrame);
- }
- return RetainPtr<CFArrayRef>(AdoptCF, array);
-}
-
-void BitmapImage::draw(GraphicsContext* ctx, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator op)
-{
- draw(ctx, dstRect, srcRect, styleColorSpace, op, DoNotRespectImageOrientation);
-}
-
-void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& destRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, RespectImageOrientationEnum shouldRespectImageOrientation)
-{
- startAnimation();
-
- CGImageRef image = frameAtIndex(m_currentFrame);
- if (!image) // If it's too early we won't have an image yet.
- return;
-
- if (mayFillWithSolidColor()) {
- fillWithSolidColor(ctxt, destRect, solidColor(), styleColorSpace, compositeOp);
- return;
- }
-
- FloatSize selfSize = currentFrameSize();
- ImageOrientation orientation = DefaultImageOrientation;
-
- if (shouldRespectImageOrientation == RespectImageOrientation)
- orientation = frameOrientationAtIndex(m_currentFrame);
-
- ctxt->drawNativeImage(image, selfSize, styleColorSpace, destRect, srcRect, compositeOp, orientation);
-
- if (imageObserver())
- imageObserver()->didDraw(this);
-}
-
static void drawPatternCallback(void* info, CGContextRef context)
{
CGImageRef image = (CGImageRef)info;
imageObserver()->didDraw(this);
}
-
}
#endif // USE(CG)