My blog has been moved to ariya.ofilabs.com.
Showing posts with label qualcomm. Show all posts
Showing posts with label qualcomm. Show all posts

Wednesday, October 06, 2010

color inversion for web pages

Something I worked on during my last few weeks with Qualcomm was color inversion for the web browser in Android. The patch was then integrated by Enrico (see the diff) because I switched job.

Later on this feature was also pulled into CyanogenMod. Thus, if you are running CyanogenMod 6 on your shiny Android device, you can try this feature already! In the web browser, just pick the Settings menu and then scroll a bit until you see a checkbox for Invert Color. You should get something like the captured screens below:

The idea behind this is to reduce the power consumption of Organic LED display, because on mostly-white web page, it hungrily grabs to 3x more power compared to LCD. This is similar to Jeff's trick of applying color filter in SurfaceFlinger.

Doing it at the user-space level gives one advantage: we can keep the embedded images non-inverted. Blindly inverting the entire screen would result in web pages look rather funky, especially those new sites with photos to accompany the articles. Of course, this hackish approach will not work 100%, (hint: double XOR?) since the web designer likely never intend the page to be color inverted. However it seems to work most of the time, at least with pages which do not have ueberartistic look-and-feel.

Faithful followers of my blog know that I already played with the color inversion ages ago, in the form of giving night mode appearance for QWebView. Thus, it happened that in one afternoon break I played with QtWebKit to do something similar to this selective color inversion.

Now, in the case of Android WebKit, the effect was rather easy to achieve. This is because Skia's SkCanvas is basically an interface which can be subclassed easily, while none of the functions in QPainter is virtual. The trick using Skia was to use a proxy canvas (a slight variation of Skia's built-in SkProxyCanvas) which I invented for this purpose but somehow also useful for another feature.

For QtWebKit however, we need to tweak it with some QPaintEngine voodoo. Check out the code at the usual X2 repository, find it under webkit/nightcapture (it still has some rooms for improvement, left as exercises for the adventurous readers). For simplicity, I made it as capturing tool so you need to pass a URL and the output filename. Unless you do something wrong, expect to get something like this:

The trick is the same as my approach for the Android patch: invert the colors of each image before drawing it, at the end invert the entire viewport. This seems like slow, but it's the best compromise I found out working with most sites. Note how we skip inverting any brush pixmap as usually brush is for the tiled background (and thus we want to keep it that way, i.e. not inverted). You can do some fancy magic with clipping and whatnot, but I doubt the end result is much better. Again, this whole stuff is a hack anyway and there will be always corner cases which will not work, no matter what approach you pick, thus there is no need to make it more complicated that it should be.

Just like they say, we code for life, i.e. the battery life.

Friday, August 06, 2010

even LOST has its season finale

the final countdown

Today is my last day at Qualcomm.

It still feels like yesterday when I set foot in this continent, started some fun with X2, enjoyed Brazil, had this meet-up in Cupertino, did little exploration around San Diego, and then got blessed with a cute boy. Time really flies. Now it's already time to move on, again (though this time without a geeky resignation).

I will miss Snapdragon (the pictured HTC EVO is powered by the said platform). Or any other dragons.

Those who are annoyed by a certain obsession of mine probably can guess where I'm heading to. In the grand mission of inspiring and pushing developers to write better and more exciting applications, a particular productivity barrier needs to be broken. And I dropped enough (subtle) hints in my previous blog entries already.

Stay tuned.

Tuesday, May 18, 2010

Saturday, April 10, 2010

cupertino

Tomorrow, we (a bunch of Qualcomm folks working on WebKit) will go up north. We'll be at Apple HQ in Cupertino for the WebKit contributors meeting. I look forward to meeting all the great WebKit hackers (again) face-to-face!

Wednesday, December 30, 2009

"i" for innovate

As I have hinted before, somehow I aimed to move to some sunny place in California. Well, lucky as we could be, after days of experiencing the transient stage (with tons of good and bad experiences, what a roller-coaster), we slowly settle in San Diego, (arguably) a beautiful place to live. The proof is the following picture, basically I can enjoy watching sunset from our balcony every day when the weather permits (it does usually).

sunset from the balcony

Few weeks ago, I started a new position within Qualcomm Innovation Center Inc., specifically in the new Web Technologies team. This center is a wholly-owned subsidiary of Qualcomm, one of the top 10 semiconductor sales leaders last year. The official party line of Qualcomm Innovation Center is best understood by what our president, Rob Chandhok, has expressed once: focus on such important open source initiatives as Linux and Webkit, and on open source operating systems such as Symbian, Android and Chrome.

Qualcomm

Of course, faithful followers of my blog can quickly point out that this whole thing is just a cover-up for the real motive: the strong desire to live in a perfect symmetry :)

the best juice on earth

In addition, to convince you that the alignment of the planet has been planned for this, surely you know (perfectly) where the upcoming Camp KDE will be held?

See you in 2 weeks. Happy 0x7da!