2

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.

Thanks.

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,
                              dfp.paint());
}

LOOPER_END

}

Sam
  • 4,521
  • 13
  • 46
  • 81

1 Answers1

5

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.)

Romain Guy
  • 97,993
  • 18
  • 219
  • 200
  • 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 00:21
  • 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