void onDraw(SkCanvas* canvas) override { draw_pass(canvas, kCheckerboard_Pass); canvas->saveLayer(nullptr, nullptr); canvas->translate(kMargin, kMargin); draw_pass(canvas, kBackground_Pass); SkPaint titlePaint(fLabelPaint); titlePaint.setTextSize(9 * titlePaint.getTextSize() / 8); titlePaint.setFakeBoldText(true); titlePaint.setTextAlign(SkPaint::kCenter_Align); canvas->drawText("Porter Duff", sizeof("Porter Duff") - 1, kLabelSpacing + 4 * kShapeTypeSpacing, kTitleSpacing / 2 + titlePaint.getTextSize() / 3, titlePaint); canvas->drawText("Advanced", sizeof("Advanced") - 1, kXfermodeTypeSpacing + kLabelSpacing + 4 * kShapeTypeSpacing, kTitleSpacing / 2 + titlePaint.getTextSize() / 3, titlePaint); draw_pass(canvas, kShape_Pass); canvas->restore(); }
static void draw_camera(int i, int j, int f, float a) { struct camera *c = get_camera(i); init_camera(i); if (c->frame) { /* Apply a basic projection for offscreen rendering. */ glMatrixMode(GL_PROJECTION); { glPushMatrix(); glLoadIdentity(); if (c->type == CAMERA_ORTHO) glOrtho (c->l, c->r, c->b, c->t, c->n, c->f); else glFrustum(c->l, c->r, c->b, c->t, c->n, c->f); } glMatrixMode(GL_MODELVIEW); { glPushMatrix(); glLoadIdentity(); } /* Render the scene to the offscreen buffer. */ glPushAttrib(GL_VIEWPORT_BIT | GL_SCISSOR_BIT); { int w = get_image_w(c->image); int h = get_image_h(c->image); glViewport(0, 0, w, h); glScissor (0, 0, w, h); opengl_push_framebuffer(c->frame); { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); draw_scene(j, f, a); } opengl_pop_framebuffer(); } glPopAttrib(); /* Revert the projection. */ glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); } else { int eye; int tile; int pass; /* Iterate over all tiles of this host. */ for (tile = 0; tile < (int) get_tile_count(); ++tile) { float d[2][3]; /* Iterate over the eyes. */ get_eye_pos(d[0], c, 0, tile); get_eye_pos(d[1], c, 1, tile); for (eye = 0; eye < (c->mode ? 2 : 1); ++eye) { camera_eye = eye; if (draw_tile(c, eye, tile, d[eye])) { pass = 0; /* Iterate over all passes of this eye and tile. */ while ((pass = draw_pass(c->mode, eye, tile, pass, d))) { if (get_tile_flags(tile) & TILE_TEST_COLOR) draw_color(j, eye); else if (get_tile_flags(tile) & TILE_TEST_GHOST) draw_ghost(j, eye); else draw_scene(j, f, a); } } } } /* HACK */ if (c->mode != STEREO_VARRIER_00) opengl_set_fence(); } }