Skip to content

Commit

Permalink
Update WebKit to 45111 and Skia to 239
Browse files Browse the repository at this point in the history
Review URL: http://codereview.chromium.org/147121

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19211 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
amanda@chromium.org committed Jun 25, 2009
1 parent 2d896ae commit 8860e4f
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 97 deletions.
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
vars = {
"webkit_trunk":
"http://svn.webkit.org/repository/webkit/trunk",
"webkit_revision": "45086",
"webkit_revision": "45111",
}


Expand Down Expand Up @@ -35,7 +35,7 @@ deps = {
"http://v8.googlecode.com/svn/trunk@2249",

"src/third_party/skia":
"http://skia.googlecode.com/svn/trunk@224",
"http://skia.googlecode.com/svn/trunk@239",

"src/webkit/data/layout_tests/LayoutTests":
Var("webkit_trunk") + "/LayoutTests@" + Var("webkit_revision"),
Expand Down
10 changes: 5 additions & 5 deletions app/gfx/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void Canvas::FillRectInt(const SkColor& color, int x, int y, int w, int h) {
SkPaint paint;
paint.setColor(color);
paint.setStyle(SkPaint::kFill_Style);
paint.setPorterDuffXfermode(SkPorterDuff::kSrcOver_Mode);
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
FillRectInt(x, y, w, h, paint);
}

Expand All @@ -63,19 +63,19 @@ void Canvas::FillRectInt(int x, int y, int w, int h, const SkPaint& paint) {
}

void Canvas::DrawRectInt(const SkColor& color, int x, int y, int w, int h) {
DrawRectInt(color, x, y, w, h, SkPorterDuff::kSrcOver_Mode);
DrawRectInt(color, x, y, w, h, SkXfermode::kSrcOver_Mode);
}

void Canvas::DrawRectInt(const SkColor& color, int x, int y, int w, int h,
SkPorterDuff::Mode mode) {
SkXfermode::Mode mode) {
SkPaint paint;
paint.setColor(color);
paint.setStyle(SkPaint::kStroke_Style);
// Set a stroke width of 0, which will put us down the stroke rect path. If
// we set a stroke width of 1, for example, this will internally create a
// path and fill it, which causes problems near the edge of the canvas.
paint.setStrokeWidth(SkIntToScalar(0));
paint.setPorterDuffXfermode(mode);
paint.setXfermodeMode(mode);

SkIRect rc = {x, y, x + w, y + h};
drawIRect(rc, paint);
Expand Down Expand Up @@ -236,7 +236,7 @@ void Canvas::TileImageInt(const SkBitmap& bitmap, int src_x, int src_y,
SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode);
paint.setShader(shader);
paint.setPorterDuffXfermode(SkPorterDuff::kSrcOver_Mode);
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);

// CreateBitmapShader returns a Shader with a reference count of one, we
// need to unref after paint takes ownership of the shader.
Expand Down
10 changes: 5 additions & 5 deletions app/gfx/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class Rect;
// SkScalarRound.
//
// A handful of methods in this class are overloaded providing an additional
// argument of type SkPorterDuff::Mode. SkPorterDuff::Mode specifies how the
// argument of type SkXfermode::Mode. SkXfermode::Mode specifies how the
// source and destination colors are combined. Unless otherwise specified,
// the variant that does not take a SkPorterDuff::Mode uses a transfer mode
// the variant that does not take a SkXfermode::Mode uses a transfer mode
// of kSrcOver_Mode.
class Canvas : public skia::PlatformCanvas {
public:
Expand Down Expand Up @@ -99,11 +99,11 @@ class Canvas : public skia::PlatformCanvas {
void FillRectInt(int x, int y, int w, int h, const SkPaint& paint);

// Fills the specified region with the specified color using a transfer
// mode of SkPorterDuff::kSrcOver_Mode.
// mode of SkXfermode::kSrcOver_Mode.
void FillRectInt(const SkColor& color, int x, int y, int w, int h);

// Draws a single pixel rect in the specified region with the specified
// color, using a transfer mode of SkPorterDuff::kSrcOver_Mode.
// color, using a transfer mode of SkXfermode::kSrcOver_Mode.
//
// NOTE: if you need a single pixel line, use DraLineInt.
void DrawRectInt(const SkColor& color, int x, int y, int w, int h);
Expand All @@ -113,7 +113,7 @@ class Canvas : public skia::PlatformCanvas {
//
// NOTE: if you need a single pixel line, use DraLineInt.
void DrawRectInt(const SkColor& color, int x, int y, int w, int h,
SkPorterDuff::Mode mode);
SkXfermode::Mode mode);

// Draws a single pixel line with the specified color.
void DrawLineInt(const SkColor& color, int x1, int y1, int x2, int y2);
Expand Down
66 changes: 2 additions & 64 deletions chrome/browser/cocoa/cocoa_utils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,71 +21,9 @@ void ReleaseData(void* info, const void* pixelData, size_t size) {

namespace CocoaUtils {

NSImage* SkBitmapToNSImage(const SkBitmap& icon) {
NSImage* SkBitmapToNSImage(const SkBitmap& skiaBitmap) {
// First convert SkBitmap to CGImageRef.
CGImageRef cgimage;
if (icon.config() != SkBitmap::kARGB_8888_Config) {
cgimage = SkCreateCGImageRef(icon);
} else {
// The above code returns a valid NSImage even in the
// kARGB_8888_Config case. As an example, the unit test which
// draws a blue SkBitmap can lockPixels, NSReadPixel, and pull out
// a single pixel from the NSImage and see it blue. However, the
// NSImage returned will be in ABGR format. Although Cocoa is
// otherwise happy with that format (as seen in simple tests
// outside Chromium), Chromium is NOT happy. In Chromium, B and R
// are swapped.
//
// As a hint, CIImage supports a few formats, such as ARGB.
// Interestingly, it does NOT support ABGR. I speculate there is
// some way we set up our drawing context which has the format
// specified wrong (in skia/ext/bitmap_platform_device_mac.cc),
// but I have not been able to solve this yet.
//
// TODO(jrg): track down the disconnect.
// TODO(jrg): Remove byte conversion.
// TODO(jrg): Fix unit tests to NOT swap bytes.
// http://crbug.com/14020
CGBitmapInfo info = (kCGImageAlphaPremultipliedFirst |
kCGBitmapByteOrder32Host);
int width = icon.width();
int height = icon.height();
int rowbytes = icon.rowBytes();
int rowwords = rowbytes/4;
unsigned length = rowbytes * height;
DCHECK(length > 0);
uint32_t* rawptr = static_cast<uint32_t*>(malloc(length));
DCHECK(rawptr);
if (!rawptr || !length)
return nil;

// Convert ABGR to ARGB
icon.lockPixels();
uint32_t* rawbitmap = static_cast<uint32_t*>(icon.getPixels());
uint32_t rawbit;
int offset;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
offset = x + y*rowwords;
rawbit = rawbitmap[offset];
rawptr[offset] = SkPackARGB32(SkGetPackedA32(rawbit),
SkGetPackedR32(rawbit),
SkGetPackedG32(rawbit),
SkGetPackedB32(rawbit));
}
}
icon.unlockPixels();

CGDataProviderRef dataRef =
CGDataProviderCreateWithData(rawptr, rawptr, length, ReleaseData);
CGColorSpaceRef space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
cgimage = CGImageCreate(width, height, 8,
icon.bytesPerPixel() * 8,
rowbytes, space, info, dataRef,
NULL, false, kCGRenderingIntentDefault);
CGColorSpaceRelease(space);
CGDataProviderRelease(dataRef);
}
CGImageRef cgimage = SkCreateCGImageRef(skiaBitmap);

// Now convert to NSImage.
NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc]
Expand Down
17 changes: 5 additions & 12 deletions chrome/browser/cocoa/cocoa_utils_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@

// If not red, is blue.
// If not tfbit (twenty-four-bit), is 444.
// If swap, swap R and B before testing (see TODOs in cocoa_utils.mm)
void ShapeHelper(int width, int height, bool isred, bool tfbit, bool swap);
void ShapeHelper(int width, int height, bool isred, bool tfbit);
};

void CocoaUtilsTest::ShapeHelper(int width, int height,
bool isred, bool tfbit, bool swap) {
bool isred, bool tfbit) {
SkBitmap thing;

if (tfbit)
Expand Down Expand Up @@ -48,12 +47,6 @@
[image unlockFocus];
[color getRed:&red green:&green blue:&blue alpha:&alpha];

if (swap) {
CGFloat tmp = red;
red = blue;
blue = tmp;
}

// Be tolerant of floating point rounding, gamma, etc.
if (isred) {
EXPECT_GT(red, 0.8);
Expand All @@ -68,15 +61,15 @@


TEST_F(CocoaUtilsTest, BitmapToNSImage_RedSquare64x64) {
ShapeHelper(64, 64, true, true, true);
ShapeHelper(64, 64, true, true);
}

TEST_F(CocoaUtilsTest, BitmapToNSImage_BlueRectangle199x19) {
ShapeHelper(199, 19, false, true, true);
ShapeHelper(199, 19, false, true);
}

TEST_F(CocoaUtilsTest, BitmapToNSImage_BlueRectangle444) {
ShapeHelper(200, 200, false, false, false);
ShapeHelper(200, 200, false, false);
}


Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/download/download_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void PaintDownloadComplete(gfx::Canvas* canvas,
canvas->saveLayerAlpha(&bounds,
static_cast<int>(255.0 * opacity),
SkCanvas::kARGB_ClipLayer_SaveFlag);
canvas->drawARGB(0, 255, 255, 255, SkPorterDuff::kClear_Mode);
canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y());
canvas->restore();
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/gtk/tabs/tab_renderer_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ void TabRendererGtk::PaintTabBackground(gfx::Canvas* canvas) {
canvas->saveLayerAlpha(&bounds,
static_cast<int>(animation->GetCurrentValue() * kHoverOpacity * 0xff),
SkCanvas::kARGB_ClipLayer_SaveFlag);
canvas->drawARGB(0, 255, 255, 255, SkPorterDuff::kClear_Mode);
canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
PaintActiveTabBackground(canvas);
canvas->restore();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ void AutocompletePopupContentsView::MakeCanvasTransparent(
SkColor transparency = GetThemeProvider()->ShouldUseNativeFrame() ?
kGlassPopupTransparency : kOpaquePopupTransparency;
paint.setColor(SkColorSetARGB(transparency, 255, 255, 255));
paint.setPorterDuffXfermode(SkPorterDuff::kDstIn_Mode);
paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
paint.setStyle(SkPaint::kFill_Style);
canvas->FillRectInt(0, 0, canvas->getDevice()->width(),
canvas->getDevice()->height(), paint);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/views/tabs/tab_overview_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void TabOverviewContainer::Paint(gfx::Canvas* canvas) {
paint.setShader(shader);
shader = NULL;
paint.setStyle(SkPaint::kFill_Style);
paint.setPorterDuffXfermode(SkPorterDuff::kSrcOver_Mode);
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
canvas->drawPaint(paint);

// Restore the canvas (resetting the clip).
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/views/tabs/tab_strip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas) {
// Make sure unselected tabs are somewhat transparent.
SkPaint paint;
paint.setColor(SkColorSetARGB(200, 255, 255, 255));
paint.setPorterDuffXfermode(SkPorterDuff::kDstIn_Mode);
paint.setXfermode(SkXfermode::kDstIn_Mode);
paint.setStyle(SkPaint::kFill_Style);
canvas->FillRectInt(
0, 0, width(),
Expand Down
2 changes: 1 addition & 1 deletion chrome/renderer/render_widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ void RenderWidget::PaintRect(const gfx::Rect& rect,
SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode);
paint.setShader(shader)->unref();
paint.setPorterDuffXfermode(SkPorterDuff::kSrcOver_Mode);
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
canvas->drawPaint(paint);
}

Expand Down
10 changes: 7 additions & 3 deletions skia/config/SkUserConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,15 @@ typedef unsigned uint32_t;

#define SK_CPU_LENDIAN
#undef SK_CPU_BENDIAN
// we want (memory order) RGBA
// we want (memory order) BGRA, because that's what core image uses with
// kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, which is what
// Apple recommends for best performance (ARGB becomes BGRA in memory on
// little-endian) -- and we want skia and coregraphic to have matching memory
// layouts, so that we don't have to spend time converting between them.
#define SK_A32_SHIFT 24
#define SK_R32_SHIFT 0
#define SK_R32_SHIFT 16
#define SK_G32_SHIFT 8
#define SK_B32_SHIFT 16
#define SK_B32_SHIFT 0

#elif defined(SK_BUILD_FOR_UNIX)

Expand Down
9 changes: 9 additions & 0 deletions skia/ext/bitmap_platform_device_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,22 @@ bool Constrain(int available_size, int* position, int *size) {
static CGContextRef CGContextForData(void* data, int width, int height) {
CGColorSpaceRef color_space =
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
#define HAS_ARGB_SHIFTS(a, r, g, b) \
(SK_A32_SHIFT == (a) && SK_R32_SHIFT == (r) \
&& SK_G32_SHIFT == (g) && SK_B32_SHIFT == (b))
#if defined(SK_CPU_LENDIAN) && HAS_ARGB_SHIFTS(24, 16, 8, 0)
// Allocate a bitmap context with 4 components per pixel (BGRA). Apple
// recommends these flags for improved CG performance.
CGContextRef context =
CGBitmapContextCreate(data, width, height, 8, width * 4,
color_space,
kCGImageAlphaPremultipliedFirst |
kCGBitmapByteOrder32Host);
#else
#error We require that Skia's and CoreGraphics's recommended \
image memory layout match.
#endif
#undef HAS_ARGB_SHIFTS
CGColorSpaceRelease(color_space);

if (!context)
Expand Down
9 changes: 9 additions & 0 deletions skia/ext/skia_utils_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,20 @@ SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque) {

// Allocate a bitmap context with 4 components per pixel (BGRA). Apple
// recommends these flags for improved CG performance.
#define HAS_ARGB_SHIFTS(a, r, g, b) \
(SK_A32_SHIFT == (a) && SK_R32_SHIFT == (r) \
&& SK_G32_SHIFT == (g) && SK_B32_SHIFT == (b))
#if defined(SK_CPU_LENDIAN) && HAS_ARGB_SHIFTS(24, 16, 8, 0)
scoped_cftyperef<CGContextRef> context(
CGBitmapContextCreate(data, size.width, size.height, 8, size.width*4,
color_space,
kCGImageAlphaPremultipliedFirst |
kCGBitmapByteOrder32Host));
#else
#error We require that Skia's and CoreGraphics's recommended \
image memory layout match.
#endif
#undef HAS_ARGB_SHIFTS

// Something went really wrong. Best guess is that the bitmap data is invalid.
DCHECK(context != NULL);
Expand Down
1 change: 1 addition & 0 deletions skia/skia.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
'../third_party/skia/src/effects/SkLayerRasterizer.cpp',
'../third_party/skia/src/effects/SkNWayCanvas.cpp',
'../third_party/skia/src/effects/SkPaintFlagsDrawFilter.cpp',
'../third_party/skia/src/effects/SkPorterDuff.cpp',
'../third_party/skia/src/effects/SkPixelXorXfermode.cpp',
'../third_party/skia/src/effects/SkRadialGradient_Table.h',
'../third_party/skia/src/effects/SkTransparentShader.cpp',
Expand Down
1 change: 1 addition & 0 deletions webkit/port/bindings/scripts/CodeGeneratorV8.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,7 @@ my %typeCanFailConversion = (
"AtomicString" => 0,
"Attr" => 1,
"CompareHow" => 0,
"DataGridColumn" => 0,
"DOMString" => 0,
"DOMWindow" => 0,
"DocumentType" => 0,
Expand Down
2 changes: 2 additions & 0 deletions webkit/port/bindings/v8/v8_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
#include "V8CSSStyleSheet.h"
#include "V8CSSVariablesDeclaration.h"
#include "V8CSSVariablesRule.h"
#include "V8DataGridColumn.h"
#include "V8DataGridColumnList.h"
#include "V8Database.h"
#include "V8Document.h"
#include "V8DocumentFragment.h"
Expand Down
2 changes: 2 additions & 0 deletions webkit/port/bindings/v8/v8_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
V(CDATASECTION, CDATASection) \
V(COMMENT, Comment) \
V(DOCUMENT, Document) \
V(DATAGRIDCOLUMN, DataGridColumn) \
V(DATAGRIDCOLUMNLIST, DataGridColumnList) \
V(DOCUMENTFRAGMENT, DocumentFragment) \
V(DOCUMENTTYPE, DocumentType) \
V(ELEMENT, Element) \
Expand Down
6 changes: 6 additions & 0 deletions webkit/webkit.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,8 @@
'../third_party/WebKit/WebCore/html/CanvasPattern.idl',
'../third_party/WebKit/WebCore/html/CanvasPixelArray.idl',
'../third_party/WebKit/WebCore/html/CanvasRenderingContext2D.idl',
'../third_party/WebKit/WebCore/html/DataGridColumn.idl',
'../third_party/WebKit/WebCore/html/DataGridColumnList.idl',
'../third_party/WebKit/WebCore/html/File.idl',
'../third_party/WebKit/WebCore/html/FileList.idl',
'../third_party/WebKit/WebCore/html/HTMLAnchorElement.idl',
Expand Down Expand Up @@ -1660,6 +1662,10 @@
'../third_party/WebKit/WebCore/html/CollectionCache.cpp',
'../third_party/WebKit/WebCore/html/CollectionCache.h',
'../third_party/WebKit/WebCore/html/CollectionType.h',
'../third_party/WebKit/WebCore/html/DataGridColumn.cpp',
'../third_party/WebKit/WebCore/html/DataGridColumn.h',
'../third_party/WebKit/WebCore/html/DataGridColumnList.cpp',
'../third_party/WebKit/WebCore/html/DataGridColumnList.h',
'../third_party/WebKit/WebCore/html/File.cpp',
'../third_party/WebKit/WebCore/html/File.h',
'../third_party/WebKit/WebCore/html/FileList.cpp',
Expand Down

0 comments on commit 8860e4f

Please sign in to comment.