Bug 79212

Summary: [BlackBerry] Upstream ImageBlackBerry in platform/graphics/blackberry
Product: WebKit Reporter: Robin Cao <robin.webkit>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: charles.wei, leo.yang, rwlbuis, tonikitoo, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: Other   
Bug Depends on:    
Bug Blocks: 73119    
Attachments:
Description Flags
patch
none
updated patch
none
Updated patch for landing none

Description Robin Cao 2012-02-22 02:15:39 PST
Add ImageBlackBerry.cpp in platform/graphics/blackberry.
Comment 1 Robin Cao 2012-02-22 02:28:26 PST
Created attachment 128163 [details]
patch
Comment 2 Rob Buis 2012-02-22 04:25:05 PST
Comment on attachment 128163 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=128163&action=review

Still some stuff to improve.

> Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:2
> + * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.

Needs 2012.

> Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:30
> +    String iconName(name); // a.k.a. "enable string comparisons with =="

I dont see a need for this, why not just use strcmp?

> Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:40
> +        context->fillRect(FloatRect(0, 0, 16, 16), Color::white, ColorSpaceDeviceRGB);

There may be a variant that flood fills the entire surface, then you dont need to specify the FloatRect.

> Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:59
> +    // FIXME: Have a setting for the resource path

Is the FIXME still accurate?
Comment 3 Robin Cao 2012-02-22 19:48:18 PST
(In reply to comment #2)
> (From update of attachment 128163 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=128163&action=review
> 
> Still some stuff to improve.
> 
> > Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:2
> > + * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
> 
> Needs 2012.

Will add.

> > Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:30
> > +    String iconName(name); // a.k.a. "enable string comparisons with =="
> 
> I dont see a need for this, why not just use strcmp?
> 

Good point.

> > Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:40
> > +        context->fillRect(FloatRect(0, 0, 16, 16), Color::white, ColorSpaceDeviceRGB);
> 
> There may be a variant that flood fills the entire surface, then you dont need to specify the FloatRect.
> 

GraphicsContext does not have functions that flood fills the entire surface, though SkCanvas have such functions.
We can change it something like this:

SkCanvas* canvas = context->platformContext()->canvas();
canvas->drawColor(SK_ColorWHITE);

Both are ok for me, but I prefer not to change it.

> > Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:59
> > +    // FIXME: Have a setting for the resource path
> 
> Is the FIXME still accurate?

I don't think we need to add a public setting for the resource path. And seems no other ports did this.
I will remove the FIXME.
Comment 4 Robin Cao 2012-02-22 20:00:46 PST
Created attachment 128375 [details]
updated patch
Comment 5 Antonio Gomes 2012-02-23 19:27:10 PST
Comment on attachment 128375 [details]
updated patch

View in context: https://bugs.webkit.org/attachment.cgi?id=128375&action=review

> Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:52
> +        context->fillRect(FloatRect(0, 0, 16, 16), Color::white, ColorSpaceDeviceRGB);
> +
> +        if (!strcmp(name, "searchCancel"))
> +            context->setFillColor(Color(128, 128, 128), ColorSpaceDeviceRGB);
> +        else
> +            context->setFillColor(Color(64, 64, 64), ColorSpaceDeviceRGB);
> +
> +        context->translate(8, 8);
> +
> +        context->rotate(piDouble / 4.0);
> +        context->fillRect(FloatRect(-1, -7, 2, 14));
> +
> +        context->rotate(-piDouble / 2.0);
> +        context->fillRect(FloatRect(-1, -7, 2, 14));

some magic numbers here. Anyway we could improve it?

> Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:70
> +    img->setData(buffer.release(), true);

what is true here?
Comment 6 Robin Cao 2012-02-23 20:16:21 PST
(In reply to comment #5)
> (From update of attachment 128375 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=128375&action=review
> 
> > Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:52
> > +        context->fillRect(FloatRect(0, 0, 16, 16), Color::white, ColorSpaceDeviceRGB);
> > +
> > +        if (!strcmp(name, "searchCancel"))
> > +            context->setFillColor(Color(128, 128, 128), ColorSpaceDeviceRGB);
> > +        else
> > +            context->setFillColor(Color(64, 64, 64), ColorSpaceDeviceRGB);
> > +
> > +        context->translate(8, 8);
> > +
> > +        context->rotate(piDouble / 4.0);
> > +        context->fillRect(FloatRect(-1, -7, 2, 14));
> > +
> > +        context->rotate(-piDouble / 2.0);
> > +        context->fillRect(FloatRect(-1, -7, 2, 14));
> 
> some magic numbers here. Anyway we could improve it?
> 

We just want to draw a "x" here. Maybe i should add a comment?

> > Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:70
> > +    img->setData(buffer.release(), true);
> 
> what is true here?

true == allDataReceived
bool Image::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived);
Comment 7 Antonio Gomes 2012-02-23 20:21:55 PST
Comment on attachment 128375 [details]
updated patch

View in context: https://bugs.webkit.org/attachment.cgi?id=128375&action=review

>>> Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:52
>>> +        context->fillRect(FloatRect(-1, -7, 2, 14));
>> 
>> some magic numbers here. Anyway we could improve it?
> 
> We just want to draw a "x" here. Maybe i should add a comment?

please add.

>>> Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp:70
>>> +    img->setData(buffer.release(), true);
>> 
>> what is true here?
> 
> true == allDataReceived
> bool Image::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived);

lets add a /*allDataReceived*/ comment
Comment 8 Robin Cao 2012-02-23 21:48:40 PST
Created attachment 128647 [details]
Updated patch for landing
Comment 9 Leo Yang 2012-02-23 21:55:18 PST
Comment on attachment 128647 [details]
Updated patch for landing

Sending to cq...
Comment 10 WebKit Review Bot 2012-02-24 04:38:47 PST
Comment on attachment 128647 [details]
Updated patch for landing

Clearing flags on attachment: 128647

Committed r108774: <http://trac.webkit.org/changeset/108774>
Comment 11 WebKit Review Bot 2012-02-24 04:38:52 PST
All reviewed patches have been landed.  Closing bug.