[chromium] Chromium port never sets USE(CG) so code behind it is dead
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 May 2012 23:58:55 +0000 (23:58 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 May 2012 23:58:55 +0000 (23:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=86537

Reviewed by Adrienne Walker.

Deletes code behind USE(CG) in chromium-specific code and removes unneeded USE(SKIA) guards.

Source/WebCore:

* platform/chromium/DragImageRef.h:
(WebCore):
* platform/chromium/MIMETypeRegistryChromium.cpp:
(WebCore::MIMETypeRegistry::isSupportedImageMIMETypeForEncoding):
* platform/chromium/ScrollbarThemeChromiumMac.mm:
(WebCore::ScrollbarThemeChromiumMac::paint):
* platform/chromium/ThemeChromiumMac.mm:
(WebCore::paintStepper):
* platform/graphics/chromium/PlatformImage.cpp:
(WebCore::PlatformImage::updateFromImage):

Source/WebKit/chromium:

* src/GraphicsContext3DChromium.cpp:
(WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::grContext):
(WebCore::GraphicsContext3DPrivate::paintFramebufferToCanvas):
(WebCore::GraphicsContext3D::grContext):
* src/GraphicsContext3DPrivate.h:
(GraphicsContext3DPrivate):
* src/PlatformSupport.cpp:
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::doPixelReadbackToCanvas):

Tools:

* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::paintRect):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@117190 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/chromium/DragImageRef.h
Source/WebCore/platform/chromium/MIMETypeRegistryChromium.cpp
Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm
Source/WebCore/platform/chromium/ThemeChromiumMac.mm
Source/WebCore/platform/graphics/chromium/PlatformImage.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
Source/WebKit/chromium/src/GraphicsContext3DPrivate.h
Source/WebKit/chromium/src/PlatformSupport.cpp
Source/WebKit/chromium/src/WebViewImpl.cpp
Tools/ChangeLog
Tools/DumpRenderTree/chromium/WebViewHost.cpp

index 48ef0ab..1574775 100644 (file)
@@ -1,3 +1,23 @@
+2012-05-15  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Chromium port never sets USE(CG) so code behind it is dead
+        https://bugs.webkit.org/show_bug.cgi?id=86537
+
+        Reviewed by Adrienne Walker.
+
+        Deletes code behind USE(CG) in chromium-specific code and removes unneeded USE(SKIA) guards.
+
+        * platform/chromium/DragImageRef.h:
+        (WebCore):
+        * platform/chromium/MIMETypeRegistryChromium.cpp:
+        (WebCore::MIMETypeRegistry::isSupportedImageMIMETypeForEncoding):
+        * platform/chromium/ScrollbarThemeChromiumMac.mm:
+        (WebCore::ScrollbarThemeChromiumMac::paint):
+        * platform/chromium/ThemeChromiumMac.mm:
+        (WebCore::paintStepper):
+        * platform/graphics/chromium/PlatformImage.cpp:
+        (WebCore::PlatformImage::updateFromImage):
+
 2012-05-15  Keyar Hood  <keyar@chromium.org>
 
         Skia does not respect a specified InterpolationQuality
index a2398e4..7a6aca8 100644 (file)
 #ifndef DragImageRef_h
 #define DragImageRef_h
 
-#if USE(CG)
-typedef struct CGImage* CGImageRef;
-#else
 class SkBitmap;
-#endif
 
 namespace WebCore {
 
-#if USE(CG)
-typedef CGImageRef DragImageRef;
-#else
 typedef SkBitmap* DragImageRef;
-#endif
 
 } // namespace WebCore
 
index ee2d561..f764c3d 100644 (file)
@@ -104,7 +104,7 @@ bool MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(const String& mimeTyp
 {
     if (mimeType == "image/jpeg" || mimeType == "image/png")
         return true;
-#if USE(WEBP) && USE(SKIA)
+#if USE(WEBP)
     if (mimeType == "image/webp")
         return true;
 #endif
index acfbc1d..75e4a29 100644 (file)
 #include "ImageBuffer.h"
 #include "LocalCurrentGraphicsContext.h"
 #include "NSScrollerImpDetails.h"
+#include "PlatformContextSkia.h"
 #include "PlatformSupport.h"
 #include "ScrollAnimatorMac.h"
 #include "ScrollView.h"
-#include <Carbon/Carbon.h>
-
-#if USE(SKIA)
-#include "PlatformContextSkia.h"
 #include "skia/ext/skia_utils_mac.h"
-#endif
+#include <Carbon/Carbon.h>
 
 namespace WebCore {
 
@@ -121,11 +118,7 @@ bool ScrollbarThemeChromiumMac::paint(ScrollbarThemeClient* scrollbar, GraphicsC
                 value = 0;
         }
 
-#if !USE(SKIA)
-        setIsCurrentlyDrawingIntoLayer(context->isCALayerContext());
-#else
         setIsCurrentlyDrawingIntoLayer(false);
-#endif
 
         CGFloat oldKnobAlpha = 0;
         CGFloat oldTrackAlpha = 0;
@@ -201,12 +194,8 @@ bool ScrollbarThemeChromiumMac::paint(ScrollbarThemeClient* scrollbar, GraphicsC
         trackInfo.enableState = kThemeTrackNothingToScroll;
     trackInfo.trackInfo.scrollbar.pressState = scrollbarPartToHIPressedState(scrollbar->pressedPart());
 
-#if USE(SKIA)
     SkCanvas* canvas = context->platformContext()->canvas();
     CGAffineTransform currentCTM = gfx::SkMatrixToCGAffineTransform(canvas->getTotalMatrix());
-#else
-    CGAffineTransform currentCTM = CGContextGetCTM(context->platformContext());
-#endif
 
     // The Aqua scrollbar is buggy when rotated and scaled.  We will just draw into a bitmap if we detect a scale or rotation.
     bool canDrawDirectly = currentCTM.a == 1.0f && currentCTM.b == 0.0f && currentCTM.c == 0.0f && (currentCTM.d == 1.0f || currentCTM.d == -1.0f);
@@ -227,12 +216,8 @@ bool ScrollbarThemeChromiumMac::paint(ScrollbarThemeClient* scrollbar, GraphicsC
     }
 
     // Draw thumbless.
-#if USE(SKIA)
     gfx::SkiaBitLocker bitLocker(drawingContext->platformContext()->canvas());
     CGContextRef cgContext = bitLocker.cgContext();
-#else
-    CGContextRef cgContext = drawingContext->platformContext();
-#endif
     HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal);
 
     IntRect tickmarkTrackRect = trackRect(scrollbar, false);
index 69cb74a..e718d05 100644 (file)
 #import "ScrollView.h"
 #import "WebCoreSystemInterface.h"
 #import <Carbon/Carbon.h>
-#include <wtf/StdLibExtras.h>
 #import <objc/runtime.h>
-
-#if USE(SKIA)
 #include "PlatformContextSkia.h"
 #include "skia/ext/skia_utils_mac.h"
-#endif
+#include <wtf/StdLibExtras.h>
 
 using namespace std;
 
@@ -641,12 +638,8 @@ static void paintStepper(ControlStates states, GraphicsContext* context, const I
         int heightDiff = clampToInteger(bounds.size.height - backgroundBounds.size.height);
         backgroundBounds.origin.y = bounds.origin.y + (heightDiff / 2) + 1;
     }
-#if USE(SKIA)
     gfx::SkiaBitLocker bitLocker(context->platformContext()->canvas());
     CGContextRef cgContext = bitLocker.cgContext();
-#else
-    CGContextRef cgContext = context->platformContext();
-#endif
     HIThemeDrawButton(&backgroundBounds, &drawInfo, cgContext, kHIThemeOrientationNormal, 0);
     context->restore();
 }
index 9672c9c..2e2f1ab 100644 (file)
  */
 
 #include "config.h"
-
 #include "PlatformImage.h"
 
-#if USE(SKIA)
 #include "NativeImageSkia.h"
 #include "PlatformContextSkia.h"
-#elif USE(CG)
-#include <CoreGraphics/CGBitmapContext.h>
-#include <CoreGraphics/CGContext.h>
-#include <CoreGraphics/CGImage.h>
-#include <wtf/RetainPtr.h>
-#else
-#error "Need to implement for your platform"
-#endif
 
 namespace WebCore {
 
@@ -47,19 +37,12 @@ PlatformImage::PlatformImage()
 
 void PlatformImage::updateFromImage(NativeImagePtr nativeImage)
 {
-#if USE(SKIA)
     // The layer contains an Image.
     NativeImageSkia* skiaImage = static_cast<NativeImageSkia*>(nativeImage);
     ASSERT(skiaImage);
     const SkBitmap& skiaBitmap = skiaImage->bitmap();
 
     IntSize bitmapSize(skiaBitmap.width(), skiaBitmap.height());
-#elif USE(CG)
-    // NativeImagePtr is a CGImageRef on Mac OS X.
-    int width = CGImageGetWidth(nativeImage);
-    int height = CGImageGetHeight(nativeImage);
-    IntSize bitmapSize(width, height);
-#endif
 
     size_t bufferSize = bitmapSize.width() * bitmapSize.height() * 4;
     if (m_size != bitmapSize) {
@@ -68,44 +51,10 @@ void PlatformImage::updateFromImage(NativeImagePtr nativeImage)
         m_size = bitmapSize;
     }
 
-#if USE(SKIA)
     SkAutoLockPixels lock(skiaBitmap);
     // FIXME: do we need to support more image configurations?
     ASSERT(skiaBitmap.config()== SkBitmap::kARGB_8888_Config);
     skiaBitmap.copyPixelsTo(m_pixelData.get(), bufferSize);
-#elif USE(CG)
-    // FIXME: we should get rid of this temporary copy where possible.
-    int tempRowBytes = width * 4;
-    // Note we do not zero this vector since we are going to
-    // completely overwrite its contents with the image below.
-    // Try to reuse the color space from the image to preserve its colors.
-    // Some images use a color space (such as indexed) unsupported by the bitmap context.
-    RetainPtr<CGColorSpaceRef> colorSpaceReleaser;
-    CGColorSpaceRef colorSpace = CGImageGetColorSpace(nativeImage);
-    CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace);
-    switch (colorSpaceModel) {
-    case kCGColorSpaceModelMonochrome:
-    case kCGColorSpaceModelRGB:
-    case kCGColorSpaceModelCMYK:
-    case kCGColorSpaceModelLab:
-    case kCGColorSpaceModelDeviceN:
-        break;
-    default:
-        colorSpaceReleaser.adoptCF(CGColorSpaceCreateDeviceRGB());
-        colorSpace = colorSpaceReleaser.get();
-        break;
-    }
-    RetainPtr<CGContextRef> tempContext(AdoptCF, CGBitmapContextCreate(m_pixelData.get(),
-                                                                       width, height, 8, tempRowBytes,
-                                                                       colorSpace,
-                                                                       kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
-    CGContextSetBlendMode(tempContext.get(), kCGBlendModeCopy);
-    CGContextDrawImage(tempContext.get(),
-                       CGRectMake(0, 0, static_cast<CGFloat>(width), static_cast<CGFloat>(height)),
-                       nativeImage);
-#else
-#error "Need to implement for your platform."
-#endif
 }
 
 } // namespace WebCore
index 075557a..4bf2794 100644 (file)
@@ -1,3 +1,24 @@
+2012-05-15  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Chromium port never sets USE(CG) so code behind it is dead
+        https://bugs.webkit.org/show_bug.cgi?id=86537
+
+        Reviewed by Adrienne Walker.
+
+        Deletes code behind USE(CG) in chromium-specific code and removes unneeded USE(SKIA) guards.
+
+        * src/GraphicsContext3DChromium.cpp:
+        (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
+        (WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
+        (WebCore::GraphicsContext3DPrivate::grContext):
+        (WebCore::GraphicsContext3DPrivate::paintFramebufferToCanvas):
+        (WebCore::GraphicsContext3D::grContext):
+        * src/GraphicsContext3DPrivate.h:
+        (GraphicsContext3DPrivate):
+        * src/PlatformSupport.cpp:
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::doPixelReadbackToCanvas):
+
 2012-05-15  Anders Carlsson  <andersca@apple.com>
 
         Set the new PlatformWheelEvent member variables to sane defaults
index 0fe9286..a829994 100644 (file)
@@ -40,6 +40,8 @@
 #include "ChromeClientImpl.h"
 #include "DrawingBuffer.h"
 #include "Extensions3DChromium.h"
+#include "GrContext.h"
+#include "GrGLInterface.h"
 #include "GraphicsContext3DPrivate.h"
 #include "HTMLCanvasElement.h"
 #include "HTMLImageElement.h"
 #include <wtf/FastMalloc.h>
 #include <wtf/text/CString.h>
 
-#if USE(CG)
-#include "GraphicsContext.h"
-#include "WebGLRenderingContext.h"
-#include <CoreGraphics/CGContext.h>
-#include <CoreGraphics/CGImage.h>
-#endif
-
-#if USE(SKIA)
-#include "GrContext.h"
-#include "GrGLInterface.h"
-#endif
 
 namespace {
 
@@ -97,24 +88,16 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(PassOwnPtr<WebKit::WebGraphic
     , m_layerComposited(false)
     , m_preserveDrawingBuffer(preserveDrawingBuffer)
     , m_resourceSafety(ResourceSafetyUnknown)
-#if USE(SKIA)
     , m_grContext(0)
-#elif USE(CG)
-    , m_renderOutputSize(0)
-#else
-#error Must port to your platform
-#endif
 {
 }
 
 GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
 {
-#if USE(SKIA)
     if (m_grContext) {
         m_grContext->contextDestroyed();
         GrSafeUnref(m_grContext);
     }
-#endif
 }
 
 PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, GraphicsContext3D::RenderStyle renderStyle, bool preserveDrawingBuffer)
@@ -163,7 +146,6 @@ Platform3DObject GraphicsContext3DPrivate::platformTexture() const
     return m_impl->getPlatformTextureId();
 }
 
-#if USE(SKIA)
 class GrMemoryAllocationChangedCallback : public Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM {
 public:
     GrMemoryAllocationChangedCallback(GraphicsContext3DPrivate* context)
@@ -202,7 +184,6 @@ GrContext* GraphicsContext3DPrivate::grContext()
     }
     return m_grContext;
 }
-#endif
 
 void GraphicsContext3DPrivate::prepareTexture()
 {
@@ -228,7 +209,7 @@ void GraphicsContext3DPrivate::paintFramebufferToCanvas(int framebuffer, int wid
 {
     unsigned char* pixels = 0;
     size_t bufferSize = 4 * width * height;
-#if USE(SKIA)
+
     const SkBitmap* canvasBitmap = imageBuffer->context()->platformContext()->bitmap();
     const SkBitmap* readbackBitmap = 0;
     ASSERT(canvasBitmap->config() == SkBitmap::kARGB_8888_Config);
@@ -254,16 +235,6 @@ void GraphicsContext3DPrivate::paintFramebufferToCanvas(int framebuffer, int wid
     // Read back the frame buffer.
     SkAutoLockPixels bitmapLock(*readbackBitmap);
     pixels = static_cast<unsigned char*>(readbackBitmap->getPixels());
-#elif USE(CG)
-    if (!m_renderOutput || m_renderOutputSize != bufferSize) {
-        m_renderOutput = adoptArrayPtr(new unsigned char[bufferSize]);
-        m_renderOutputSize = bufferSize;
-    }
-
-    pixels = m_renderOutput.get();
-#else
-#error Must port to your platform
-#endif
 
     m_impl->readBackFramebuffer(pixels, 4 * width * height, framebuffer, width, height);
 
@@ -275,7 +246,6 @@ void GraphicsContext3DPrivate::paintFramebufferToCanvas(int framebuffer, int wid
         }
     }
 
-#if USE(SKIA)
     readbackBitmap->notifyPixelsChanged();
     if (m_resizingBitmap.readyToDraw()) {
         // We need to draw the resizing bitmap into the canvas's backing store.
@@ -284,11 +254,6 @@ void GraphicsContext3DPrivate::paintFramebufferToCanvas(int framebuffer, int wid
         dst.set(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(canvasBitmap->width()), SkIntToScalar(canvasBitmap->height()));
         canvas.drawBitmapRect(m_resizingBitmap, 0, dst);
     }
-#elif USE(CG)
-    GraphicsContext3D::paintToCanvas(pixels, width, height, imageBuffer->width(), imageBuffer->height(), imageBuffer->context()->platformContext());
-#else
-#error Must port to your platform
-#endif
 }
 
 void GraphicsContext3DPrivate::paintRenderingResultsToCanvas(CanvasRenderingContext* context, DrawingBuffer* drawingBuffer)
@@ -1057,12 +1022,10 @@ Platform3DObject GraphicsContext3D::platformTexture() const
     return m_private->platformTexture();
 }
 
-#if USE(SKIA)
 GrContext* GraphicsContext3D::grContext()
 {
     return m_private->grContext();
 }
-#endif
 
 void GraphicsContext3D::prepareTexture()
 {
index b798989..c9355ad 100644 (file)
 
 #include "Extensions3DChromium.h"
 #include "GraphicsContext3D.h"
+#include "SkBitmap.h"
 #include <wtf/HashSet.h>
 #include <wtf/OwnArrayPtr.h>
 #include <wtf/OwnPtr.h>
-#if USE(SKIA)
-#include "SkBitmap.h"
-#endif
 
-#if USE(SKIA)
 class GrContext;
-#endif
 
 namespace WebKit {
 class WebGraphicsContext3D;
@@ -68,9 +64,7 @@ public:
 
     PlatformGraphicsContext3D platformGraphicsContext3D() const;
     Platform3DObject platformTexture() const;
-#if USE(SKIA)
     GrContext* grContext();
-#endif
 
     bool makeContextCurrent();
 
@@ -324,6 +318,8 @@ public:
 private:
     GraphicsContext3DPrivate(PassOwnPtr<WebKit::WebGraphicsContext3D>, bool preserveDrawingBuffer);
 
+    void initializeExtensions();
+
     OwnPtr<WebKit::WebGraphicsContext3D> m_impl;
     OwnPtr<Extensions3DChromium> m_extensions;
     OwnPtr<GraphicsContextLostCallbackAdapter> m_contextLostCallbackAdapter;
@@ -343,7 +339,6 @@ private:
     };
     ResourceSafety m_resourceSafety;
 
-#if USE(SKIA)
     // If the width and height of the Canvas's backing store don't
     // match those that we were given in the most recent call to
     // reshape(), then we need an intermediate bitmap to read back the
@@ -352,14 +347,6 @@ private:
     SkBitmap m_resizingBitmap;
 
     GrContext* m_grContext;
-#endif
-
-#if USE(CG)
-    OwnArrayPtr<unsigned char> m_renderOutput;
-    size_t m_renderOutputSize;
-#endif
-
-    void initializeExtensions();
 };
 
 } // namespace WebCore
index d5f0e75..e067857 100644 (file)
 #include "platform/WebURL.h"
 #include "platform/WebVector.h"
 
-#if USE(CG)
-#include <CoreGraphics/CGContext.h>
-#endif
-
 #if OS(WINDOWS)
 #include "platform/WebRect.h"
 #include "platform/win/WebThemeEngine.h"
index 41d8fac..a00e2b5 100644 (file)
 #include "PlatformGestureEvent.h"
 #endif
 
-#if USE(CG)
-#include <CoreGraphics/CGBitmapContext.h>
-#include <CoreGraphics/CGContext.h>
-#endif
-
 #if OS(WINDOWS)
 #include "RenderThemeChromiumWin.h"
 #else
@@ -1484,18 +1479,13 @@ void WebViewImpl::layout()
 void WebViewImpl::doPixelReadbackToCanvas(WebCanvas* canvas, const IntRect& rect)
 {
     ASSERT(!m_layerTreeView.isNull());
-#if USE(SKIA)
+
     PlatformContextSkia context(canvas);
 
     // PlatformGraphicsContext is actually a pointer to PlatformContextSkia
     GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
     int bitmapHeight = canvas->getDevice()->accessBitmap(false).height();
-#elif USE(CG)
-    GraphicsContext gc(canvas);
-    int bitmapHeight = CGBitmapContextGetHeight(reinterpret_cast<CGContextRef>(canvas));
-#else
-    notImplemented();
-#endif
+
     // Compute rect to sample from inverted GPU buffer.
     IntRect invertRect(rect.x(), bitmapHeight - rect.maxY(), rect.width(), rect.height());
 
index 856c23e..f61bc2c 100644 (file)
@@ -1,5 +1,17 @@
 2012-05-15  James Robinson  <jamesr@chromium.org>
 
+        [chromium] Chromium port never sets USE(CG) so code behind it is dead
+        https://bugs.webkit.org/show_bug.cgi?id=86537
+
+        Reviewed by Adrienne Walker.
+
+        Deletes code behind USE(CG) in chromium-specific code and removes unneeded USE(SKIA) guards.
+
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::paintRect):
+
+2012-05-15  James Robinson  <jamesr@chromium.org>
+
         [chromium] Remove WEBKIT_USING_(SKIA|CG) #defines
         https://bugs.webkit.org/show_bug.cgi?id=86536
 
index 2f1a740..cd78036 100644 (file)
@@ -1735,12 +1735,7 @@ void WebViewHost::paintRect(const WebRect& rect)
     ASSERT(!m_isPainting);
     ASSERT(canvas());
     m_isPainting = true;
-#if USE(CG)
-    webWidget()->paint(skia::BeginPlatformPaint(canvas()), rect);
-    skia::EndPlatformPaint(canvas());
-#else
     webWidget()->paint(canvas(), rect);
-#endif
     m_isPainting = false;
 }