summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-18 17:42:45 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-18 17:42:45 +0000
commit3a9eb83a621e991d593b9d02d377db75a0272f29 (patch)
tree6ba043e91f2a430983c4ac7c767f90d5adecd9cc /webkit
parentaad0ab57d277c5bec206ea6f6766835e3ec4bf4a (diff)
downloadchromium_src-3a9eb83a621e991d593b9d02d377db75a0272f29.zip
chromium_src-3a9eb83a621e991d593b9d02d377db75a0272f29.tar.gz
chromium_src-3a9eb83a621e991d593b9d02d377db75a0272f29.tar.bz2
Backout my image change which broke mac.
Review URL: http://codereview.chromium.org/11446 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5611 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/chromium_bridge_impl.cc72
-rw-r--r--webkit/port/platform/chromium/ChromiumBridge.h6
-rw-r--r--webkit/port/platform/graphics/ImageSkia.cpp95
3 files changed, 80 insertions, 93 deletions
diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc
index 54f445c..a7f7c76 100644
--- a/webkit/glue/chromium_bridge_impl.cc
+++ b/webkit/glue/chromium_bridge_impl.cc
@@ -5,8 +5,6 @@
#include "config.h"
#include "ChromiumBridge.h"
-#include "BitmapImage.h"
-#include "BitmapImageSingleFrameSkia.h"
#include "ClipboardUtilitiesChromium.h"
#include "Cursor.h"
#include "Frame.h"
@@ -30,7 +28,6 @@
#include "base/stats_counters.h"
#include "base/string_util.h"
#include "base/trace_event.h"
-#include "build/build_config.h"
#include "net/base/mime_util.h"
#if USE(V8)
#include <v8.h>
@@ -45,13 +42,6 @@
#include "webkit/glue/webview_impl.h"
#include "webkit/glue/webview_delegate.h"
-#if defined(OS_WIN)
-#include <windows.h>
-#include <vssym32.h>
-
-#include "base/gfx/native_theme.h"
-#endif
-
namespace {
PlatformWidget ToPlatform(WebCore::Widget* widget) {
@@ -324,68 +314,6 @@ String ChromiumBridge::uiResourceProtocol() {
return webkit_glue::StdStringToString(webkit_glue::GetUIResourceProtocol());
}
-
-// Resources ------------------------------------------------------------------
-
-#if defined(OS_WIN)
-// Creates an Image for the text area resize corner. We do this by drawing the
-// theme native control into a memory buffer then converting the memory buffer
-// into an image. We don't bother caching this image because the caller holds
-// onto a static copy (see WebCore/rendering/RenderLayer.cpp).
-static PassRefPtr<Image> GetTextAreaResizeCorner() {
- // Get the size of the resizer.
- const int thickness = ScrollbarTheme::nativeTheme()->scrollbarThickness();
-
- // Setup a memory buffer.
- gfx::PlatformCanvasWin canvas(thickness, thickness, false);
- gfx::PlatformDeviceWin& device = canvas.getTopPlatformDevice();
- device.prepareForGDI(0, 0, thickness, thickness);
- HDC hdc = device.getBitmapDC();
- RECT widgetRect = { 0, 0, thickness, thickness };
-
- // Do the drawing.
- gfx::NativeTheme::instance()->PaintStatusGripper(hdc, SP_GRIPPER, 0, 0,
- &widgetRect);
- device.postProcessGDI(0, 0, thickness, thickness);
- return BitmapImageSingleFrameSkia::create(device.accessBitmap(false));
-}
-#endif
-
-PassRefPtr<Image> ChromiumBridge::loadPlatformImageResource(const char* name) {
- // Some need special handling.
- if (!strcmp(name, "textAreaResizeCorner")) {
-#if defined(OS_WIN)
- return GetTextAreaResizeCorner();
-#else
- DLOG(WARNING) << "This needs implementing on other platforms.";
- return Image::nullImage();
-#endif
- }
-
- // The rest get converted to a resource ID that we can pass to the glue.
- int resource_id = 0;
- if (!strcmp(name, "missingImage")) {
- resource_id = IDR_BROKENIMAGE;
- } else if (!strcmp(name, "tickmarkDash")) {
- resource_id = IDR_TICKMARK_DASH;
- } else if (!strcmp(name, "deleteButton") ||
- !strcmp(name, "deleteButtonPressed")) {
- NOTREACHED() << "Image resource " << name << " does not exist yet.";
- return Image::nullImage();
- } else {
- NOTREACHED() << "Unknown image resource " << name;
- return Image::nullImage();
- }
-
- std::string data = webkit_glue::GetDataResource(resource_id);
- RefPtr<SharedBuffer> buffer(
- SharedBuffer::create(data.empty() ? "" : data.data(),
- data.length()));
- RefPtr<Image> image = BitmapImage::create();
- image->setData(buffer, true);
- return image;
-}
-
// Screen ---------------------------------------------------------------------
int ChromiumBridge::screenDepth(Widget* widget) {
diff --git a/webkit/port/platform/chromium/ChromiumBridge.h b/webkit/port/platform/chromium/ChromiumBridge.h
index 3599bb7..9f19d8b 100644
--- a/webkit/port/platform/chromium/ChromiumBridge.h
+++ b/webkit/port/platform/chromium/ChromiumBridge.h
@@ -33,7 +33,6 @@
#include "config.h"
#include "PasteboardPrivate.h"
-#include "PassRefPtr.h"
#include "PlatformString.h"
class NativeImageSkia;
@@ -46,7 +45,6 @@ namespace WebCore {
class Cursor;
class Document;
class Frame;
- class Image;
class IntRect;
class KURL;
class String;
@@ -106,9 +104,6 @@ namespace WebCore {
// Protocol -----------------------------------------------------------
static String uiResourceProtocol();
- // Resources ----------------------------------------------------------
- static PassRefPtr<Image> loadPlatformImageResource(const char* name);
-
// Screen -------------------------------------------------------------
static int screenDepth(Widget*);
static int screenDepthPerComponent(Widget*);
@@ -132,6 +127,7 @@ namespace WebCore {
// Widget -------------------------------------------------------------
static void widgetSetCursor(Widget*, const Cursor&);
static void widgetSetFocus(Widget*);
+
};
}
diff --git a/webkit/port/platform/graphics/ImageSkia.cpp b/webkit/port/platform/graphics/ImageSkia.cpp
index 5213660..47815d4 100644
--- a/webkit/port/platform/graphics/ImageSkia.cpp
+++ b/webkit/port/platform/graphics/ImageSkia.cpp
@@ -1,10 +1,10 @@
// Copyright (c) 2008, Google 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:
-//
+//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
-//
+//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -28,11 +28,11 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "config.h"
+#include "build/build_config.h"
#include "AffineTransform.h"
#include "BitmapImage.h"
#include "BitmapImageSingleFrameSkia.h"
-#include "ChromiumBridge.h"
#include "FloatRect.h"
#include "GraphicsContext.h"
#include "Logging.h"
@@ -40,11 +40,22 @@
#include "NotImplemented.h"
#include "PlatformContextSkia.h"
#include "PlatformString.h"
+#include "ScrollbarTheme.h"
+
#include "SkiaUtils.h"
#include "SkShader.h"
#include "base/gfx/image_operations.h"
#include "base/gfx/platform_canvas.h"
+#include "webkit/glue/webkit_glue.h"
+#include "webkit/glue/webkit_resources.h"
+
+#if defined(OS_WIN)
+#include <windows.h>
+#include <vssym32.h>
+#include "base/gfx/gdi_util.h"
+#include "base/gfx/native_theme.h"
+#endif
namespace WebCore {
@@ -93,7 +104,7 @@ ResamplingMode computeResamplingMode(const NativeImageSkia& bitmap,
// We don't need to resample if the source and destination are the same.
return RESAMPLE_NONE;
}
-
+
if (srcWidth <= kSmallImageSizeThreshold ||
srcHeight <= kSmallImageSizeThreshold ||
destWidth <= kSmallImageSizeThreshold ||
@@ -102,7 +113,7 @@ ResamplingMode computeResamplingMode(const NativeImageSkia& bitmap,
// rules (think 1x1 images used to make lines).
return RESAMPLE_NONE;
}
-
+
if (srcHeight * kLargeStretch <= destHeight ||
srcWidth * kLargeStretch <= destWidth) {
// Large image detected.
@@ -118,7 +129,7 @@ ResamplingMode computeResamplingMode(const NativeImageSkia& bitmap,
// is slow and doesn't give us very much when growing a lot.
return RESAMPLE_LINEAR;
}
-
+
if ((fabs(destWidth - srcWidth) / srcWidth <
kFractionalChangeThreshold) &&
(fabs(destHeight - srcHeight) / srcHeight <
@@ -242,7 +253,6 @@ void paintSkBitmap(PlatformContextSkia* platformContext,
const SkPorterDuff::Mode& compOp)
{
SkPaint paint;
- paint.setAntiAlias(true);
paint.setPorterDuffXfermode(compOp);
gfx::PlatformCanvas* canvas = platformContext->canvas();
@@ -255,13 +265,10 @@ void paintSkBitmap(PlatformContextSkia* platformContext,
paint.setFilterBitmap(false);
drawResampledBitmap(*canvas, paint, bitmap, srcRect, destRect);
} else {
- // No resampling necessary, we can just draw the bitmap. We want to
- // filter it if we decided to do linear interpolation above, or if there
- // is something interesting going on with the matrix (like a rotation).
+ // No resampling necessary, we can just draw the bitmap.
// Note: for serialization, we will want to subset the bitmap first so
// we don't send extra pixels.
- paint.setFilterBitmap(!canvas->getTotalMatrix().rectStaysRect() ||
- resampling == RESAMPLE_LINEAR);
+ paint.setFilterBitmap(resampling == RESAMPLE_LINEAR);
canvas->drawBitmapRect(bitmap, &srcRect, destRect, &paint);
}
}
@@ -288,6 +295,34 @@ void TransformDimensions(const SkMatrix& matrix,
*dest_height = SkScalarToFloat((dest_points[2] - dest_points[0]).length());
}
+#if defined(OS_WIN)
+// Creates an Image for the text area resize corner. We do this by drawing the
+// theme native control into a memory buffer then converting the memory buffer
+// into a BMP byte stream, then feeding it into the Image object. We have to
+// convert the HBITMAP into a BMP file because the Image object doesn't allow
+// us to directly manipulate the image data. We don't bother caching this
+// image because the caller holds onto a static copy (see
+// WebCore/rendering/RenderLayer.cpp).
+static PassRefPtr<Image> GetTextAreaResizeCorner()
+{
+ // Get the size of the resizer.
+ const int thickness = ScrollbarTheme::nativeTheme()->scrollbarThickness();
+
+ // Setup a memory buffer.
+ gfx::PlatformCanvasWin canvas(thickness, thickness, false);
+ gfx::PlatformDeviceWin& device = canvas.getTopPlatformDevice();
+ device.prepareForGDI(0, 0, thickness, thickness);
+ HDC hdc = device.getBitmapDC();
+ RECT widgetRect = { 0, 0, thickness, thickness };
+
+ // Do the drawing.
+ gfx::NativeTheme::instance()->PaintStatusGripper(hdc, SP_GRIPPER, 0, 0,
+ &widgetRect);
+ device.postProcessGDI(0, 0, thickness, thickness);
+ return BitmapImageSingleFrameSkia::create(device.accessBitmap(false));
+}
+#endif
+
} // namespace
void FrameData::clear()
@@ -299,9 +334,37 @@ void FrameData::clear()
// properties like frame durations without re-decoding.
}
+static inline PassRefPtr<Image> loadImageWithResourceId(int resourceId)
+{
+ RefPtr<Image> image = BitmapImage::create();
+ // Load the desired resource.
+ std::string data(webkit_glue::GetDataResource(resourceId));
+ RefPtr<SharedBuffer> buffer(SharedBuffer::create(data.data(), data.length()));
+ image->setData(buffer, true);
+ return image.release();
+}
+
+// static
PassRefPtr<Image> Image::loadPlatformResource(const char *name)
{
- return ChromiumBridge::loadPlatformImageResource(name);
+ if (!strcmp(name, "missingImage"))
+ return loadImageWithResourceId(IDR_BROKENIMAGE);
+ if (!strcmp(name, "tickmarkDash"))
+ return loadImageWithResourceId(IDR_TICKMARK_DASH);
+ // TODO(port): Need to make this portable.
+ if (!strcmp(name, "textAreaResizeCorner"))
+#if defined(OS_WIN)
+ return GetTextAreaResizeCorner();
+#else
+ notImplemented();
+#endif
+ if (!strcmp(name, "deleteButton") || !strcmp(name, "deleteButtonPressed")) {
+ LOG(NotYetImplemented, "Image resource %s does not yet exist\n", name);
+ return Image::nullImage();
+ }
+
+ LOG(NotYetImplemented, "Unknown image resource %s requested\n", name);
+ return Image::nullImage();
}
void Image::drawPattern(GraphicsContext* context,
@@ -409,7 +472,7 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect,
{
if (!m_source.initialized())
return;
-
+
// Spin the animation to the correct frame before we try to draw it, so we
// don't draw an old frame and then immediately need to draw a newer one,
// causing flicker and wasting CPU.
@@ -453,4 +516,4 @@ PassRefPtr<BitmapImageSingleFrameSkia> BitmapImageSingleFrameSkia::create(
return image.release();
}
-} // namespace WebCore
+} // namespace WebCore