void player_impl::init_video(vo_context *vo, int render_type) { int ret = 0; if (render_type == RENDER_ANDROID_OGL) { ret = android_gles_init_video(vo, video_width(), video_height(), PIX_FMT_YUV420P); if(ret == 0) { vo->init_video = android_gles_init_video; m_draw_frame = android_gles_render_one_frame; vo->re_size = android_gles_re_size; vo->aspect_ratio = android_gles_aspect_ratio; vo->use_overlay = android_gles_use_overlay; vo->destory_video = android_gles_destory_render; vo->render_one_frame = &player_impl::draw_frame; ::logger("init video render to android opengles.\n"); } } // 保存this为user_ctx. vo->user_ctx = (void*)this; }
void bitmap_draw(bitmap_t* bitmap, short* buffer, unsigned int x, unsigned int y) { if (bitmap == NULL) { return; } int width = bitmap_width(bitmap); int height = bitmap_height(bitmap); if (!video_check_bounds(x, y)) { return; } int i; int screen_location = y + height - 1; short* buffer_position = (short*) buffer + screen_location * video_width() + x; short* bitmap_position = bitmap->bitmapData; for (i = 0; i < height; i++) { memcpy((char*) buffer_position, (char*) bitmap_position, width << 1); if (width % 2 == 0) { bitmap_position += width; } else { bitmap_position += width + 1; } buffer_position -= video_width(); } }