Take the 2-minute tour ×

Upon the link

Hardware accleration

I found that Canvas now supports hardware acceleration(mostly).

I downloaded the 4.2.2 AOSP(API Level 17) source and checked the code in external/skia/src/core/sKCanvas.cpp

I reached sKCanvas.cpp because this will finally get called via jni from Android Canvas class.

However, say drawPosText(), this function should be using hardware acceleration (open gl)

in the code. But when I checked this function in sKCanvas.cpp, I dont see any code related to open gl.

Did I misunderstand anything? This does confuse me.


void SkCanvas::drawPosText(const void* text, size_t byteLength,
                       const SkPoint pos[], const SkPaint& paint) {
LOOPER_BEGIN(paint, SkDrawFilter::kText_Type)

while (iter.next()) {
    SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint());
    iter.fDevice->drawPosText(iter, text, byteLength, &pos->fX, 0, 2,



share|improve this question

1 Answer 1

up vote 4 down vote accepted

You are looking at the software implementation. The hardware implementation is in frameworks/base/libs/hwui and frameworks/base/core/java/android/view/ (see HardwareRenderer.java, HardwareCanvas.java, GLES20Canvas.java, etc.)

share|improve this answer
Thanks. I noticed GLES20Canvas extends HardwareCanvas. Do you know which file that GLEs20Canvas.java accesses to in the native layer? –  Sam Aug 14 '13 at 0:21
I just told you: frameworks/base/libs/hwui :) –  Romain Guy Aug 14 '13 at 0:36
Thanks. one more question, is that SkCanvas purely software implementation? if so, then it makes sense for Android to create GLES20Canvas.java. otherwise, if SkCanvas can also take advantage of hardware acceleration, then what's the difference between Canvas.java and GLES20Canvas.java? –  Sam Aug 14 '13 at 14:06
SkCanvas is the software implementation. –  Romain Guy Aug 14 '13 at 16:44

Your Answer


