int main(void) { setSize(900, 700); drawImage(150,0,700,500,"file:background.png"); //Text setColourGradient("white","yellow"); drawString(200,470,"H a p p y...W i n t e r"); //SnowMan Body setColourGradient("gray","white"); fillOval(440.0,160.0,65.0,60.0); fillOval(430.0,220.0,90.0,80.0); fillOval(400.0,300.0,150.0,160.0); //Facial Features setColourGradient("black","green"); fillOval(455.0,175.0,10.0,10.0); fillOval(480.0,175.0,10.0,10.0); drawArc(470,200,20,50,30,40); //Hands setColour(white); drawLine(440,240,395,200); drawLine(520,240,565,200); //Accessories drawOval(472,235,10,10); drawOval(472,255,10,10); drawOval(472,275,10,10); return 0; }
int main(void) { drawOval(30,30,100,150); drawOval(0,0,499,299); drawArc(100,100,90,120,0,180); return 0; }
static void ovalDraw(XtPointer cd) { MedmOval *po = (MedmOval *)cd; Record *pR = po->records?po->records[0]:NULL; DisplayInfo *displayInfo = po->updateTask->displayInfo; XGCValues gcValues; unsigned long gcValueMask; Display *display = XtDisplay(po->updateTask->displayInfo->drawingArea); DlOval *dlOval = po->dlElement->structure.oval; #if DEBUG_VISIBILITY print("ovalDraw: \n"); #endif if(isConnected(po->records)) { gcValueMask = GCForeground|GCLineWidth|GCLineStyle; switch (dlOval->dynAttr.clr) { case STATIC : case DISCRETE: gcValues.foreground = displayInfo->colormap[dlOval->attr.clr]; break; case ALARM : gcValues.foreground = alarmColor(pR->severity); break; default : gcValues.foreground = displayInfo->colormap[dlOval->attr.clr]; medmPrintf(1,"\novalDraw: Unknown attribute\n"); break; } gcValues.line_width = dlOval->attr.width; gcValues.line_style = ((dlOval->attr.style == SOLID) ? LineSolid : LineOnOffDash); XChangeGC(display,displayInfo->gc,gcValueMask,&gcValues); /* Draw depending on visibility */ if(calcVisibility(&dlOval->dynAttr, po->records)) drawOval(po); if(!pR->readAccess) { drawBlackRectangle(po->updateTask); } } else if(isStaticDynamic(&dlOval->dynAttr, True)) { /* clr and vis are both static */ gcValueMask = GCForeground|GCLineWidth|GCLineStyle; gcValues.foreground = displayInfo->colormap[dlOval->attr.clr]; gcValues.line_width = dlOval->attr.width; gcValues.line_style = ((dlOval->attr.style == SOLID) ? LineSolid : LineOnOffDash); XChangeGC(display,displayInfo->gc,gcValueMask,&gcValues); drawOval(po); } else { gcValueMask = GCForeground|GCLineWidth|GCLineStyle; gcValues.foreground = WhitePixel(display,DefaultScreen(display)); gcValues.line_width = dlOval->attr.width; gcValues.line_style = ((dlOval->attr.style == SOLID) ? LineSolid : LineOnOffDash); XChangeGC(display,displayInfo->gc,gcValueMask,&gcValues); drawOval(po); } }
//Draws a smiley face at (x,y) void drawSmileyFace(int x,int y, int radius){ glColor3f(1.0, 1.0, 0.0); drawCircle(x,y,radius,40,2,0); glColor3f(0,0,0); drawOval(x-(radius*2/4),y+(radius*2/4),radius/15,radius/8,30,2,0); drawOval(x+(radius*2/4),y+(radius*2/4),radius/15,radius/8,30,2,0); glColor3f(0,0,0); drawOval(0,0,200,200,40,-1,0); glColor3f(1.0, 1.0, 0.0); drawOval(0,0,180,180,40,-1,0); }
//------------------------------------------------------------------------- // draw the current shape //------------------------------------------------------------------------- void drawShape () { switch (currentShape) { case DRAW_OVAL: drawOval (0, 0, width[currentShape], height[currentShape], segments[currentShape]); break; case FILL_OVAL: fillOval (0, 0, width[currentShape], height[currentShape], segments[currentShape]); break; case DRAW_ARC: drawArc (0, 0, width[currentShape], height[currentShape], startAngleW, arcAngleW, segments[currentShape]); break; case FILL_ARC: fillArc (0, 0, width[currentShape], height[currentShape], startAngleF, arcAngleF, segments[currentShape]); break; } }
/* * Implementation of move oval */ void moveOval( Shape *s, int x, int y ) { /* Move the oval */ printf("This function should have moved a oval\n"); eraseOval( s ); s->x_pos = x; s->y_pos = y; drawOval( s ); }
namespace SkRecords { bool Draw::skip(const PairedPushCull& r) { if (fCanvas->quickReject(r.base->rect)) { fIndex += r.skip; return true; } return false; } bool Draw::skip(const BoundedDrawPosTextH& r) { return fCanvas->quickRejectY(r.minY, r.maxY); } // NoOps draw nothing. template <> void Draw::draw(const NoOp&) {} #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } DRAW(Restore, restore()); DRAW(Save, save(r.flags)); DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags)); DRAW(PopCull, popCull()); DRAW(PushCull, pushCull(r.rect)); DRAW(Clear, clear(r.color)); DRAW(Concat, concat(r.matrix)); DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); DRAW(ClipPath, clipPath(r.path, r.op, r.doAA)); DRAW(ClipRRect, clipRRect(r.rrect, r.op, r.doAA)); DRAW(ClipRect, clipRect(r.rect, r.op, r.doAA)); DRAW(ClipRegion, clipRegion(r.region, r.op)); DRAW(DrawBitmap, drawBitmap(r.bitmap, r.left, r.top, r.paint)); DRAW(DrawBitmapMatrix, drawBitmapMatrix(r.bitmap, r.matrix, r.paint)); DRAW(DrawBitmapNine, drawBitmapNine(r.bitmap, r.center, r.dst, r.paint)); DRAW(DrawBitmapRectToRect, drawBitmapRectToRect(r.bitmap, r.src, r.dst, r.paint, r.flags)); DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint)); DRAW(DrawOval, drawOval(r.oval, r.paint)); DRAW(DrawPaint, drawPaint(r.paint)); DRAW(DrawPath, drawPath(r.path, r.paint)); DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint)); DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint)); DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); DRAW(DrawRect, drawRect(r.rect, r.paint)); DRAW(DrawSprite, drawSprite(r.bitmap, r.left, r.top, r.paint)); DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, r.matrix, r.paint)); DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, r.xmode.get(), r.indices, r.indexCount, r.paint)); #undef DRAW template <> void Draw::draw(const PairedPushCull& r) { this->draw(*r.base); } template <> void Draw::draw(const BoundedDrawPosTextH& r) { this->draw(*r.base); } } // namespace SkRecords
/* * Implementation of draw */ void drawShape(Shape *s) { switch( s->type ) { case ST_OVAL: drawOval( s ); break; case ST_RECTANGLE: drawRectangle( s ); break; } }
void Design::render(Patterns &patterns) { Common::MemoryReadStream in(_data, _len); bool needRender = true; while (needRender) { byte fillType = in.readByte(); byte borderThickness = in.readByte(); byte borderFillType = in.readByte(); int type = in.readByte(); if (in.eos()) break; debug(8, "fill: %d borderFill: %d border: %d type: %d", fillType, borderFillType, borderThickness, type); switch (type) { case 4: drawRect(_surface, in, patterns, fillType, borderThickness, borderFillType); break; case 8: drawRoundRect(_surface, in, patterns, fillType, borderThickness, borderFillType); break; case 12: drawOval(_surface, in, patterns, fillType, borderThickness, borderFillType); break; case 16: case 20: drawPolygon(_surface, in, patterns, fillType, borderThickness, borderFillType); break; case 24: drawBitmap(_surface, in); break; default: warning("Unknown type => %d", type); break; } //g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->w, _surface->h); //((WageEngine *)g_engine)->processEvents(); //g_system->updateScreen(); //g_system->delayMillis(500); } }
/* NEW METHOD: 20110125 Paint circles at the start and end node. Given a Node, there seems to be no support for finding its maze co-ordinates so this brute forces it from the maze side by iterating through all maze nodes until the start and stop nodes are identified. */ void VisualizeSquareMazeRunner::drawSpNode(int x,int y,int color) { setPenColor(color); drawOval(x*PixelsPerNode+5,y*PixelsPerNode+5,PixelsPerNode-7,PixelsPerNode-7,0); }
namespace SkRecords { // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multiple threads. static SkBitmap shallow_copy(const SkBitmap& bitmap) { return bitmap; } // NoOps draw nothing. template <> void Draw::draw(const NoOp&) {} #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } DRAW(Restore, restore()); DRAW(Save, save()); DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags)); DRAW(PopCull, popCull()); DRAW(PushCull, pushCull(r.rect)); DRAW(Clear, clear(r.color)); DRAW(Concat, concat(r.matrix)); DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); DRAW(ClipPath, clipPath(r.path, r.op, r.doAA)); DRAW(ClipRRect, clipRRect(r.rrect, r.op, r.doAA)); DRAW(ClipRect, clipRect(r.rect, r.op, r.doAA)); DRAW(ClipRegion, clipRegion(r.region, r.op)); DRAW(DrawBitmap, drawBitmap(shallow_copy(r.bitmap), r.left, r.top, r.paint)); DRAW(DrawBitmapMatrix, drawBitmapMatrix(shallow_copy(r.bitmap), r.matrix, r.paint)); DRAW(DrawBitmapNine, drawBitmapNine(shallow_copy(r.bitmap), r.center, r.dst, r.paint)); DRAW(DrawBitmapRectToRect, drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, r.flags)); DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint)); DRAW(DrawOval, drawOval(r.oval, r.paint)); DRAW(DrawPaint, drawPaint(r.paint)); DRAW(DrawPath, drawPath(r.path, r.paint)); DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode.get(), r.paint)); DRAW(DrawPicture, drawPicture(r.picture, r.matrix, r.paint)); DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint)); DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint)); DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); DRAW(DrawRect, drawRect(r.rect, r.paint)); DRAW(DrawSprite, drawSprite(shallow_copy(r.bitmap), r.left, r.top, r.paint)); DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, r.matrix, r.paint)); DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, r.xmode.get(), r.indices, r.indexCount, r.paint)); #undef DRAW // This is an SkRecord visitor that fills an SkBBoxHierarchy. // // The interesting part here is how to calculate bounds for ops which don't // have intrinsic bounds. What is the bounds of a Save or a Translate? // // We answer this by thinking about a particular definition of bounds: if I // don't execute this op, pixels in this rectangle might draw incorrectly. So // the bounds of a Save, a Translate, a Restore, etc. are the union of the // bounds of Draw* ops that they might have an effect on. For any given // Save/Restore block, the bounds of the Save, the Restore, and any other // non-drawing ("control") ops inside are exactly the union of the bounds of // the drawing ops inside that block. // // To implement this, we keep a stack of active Save blocks. As we consume ops // inside the Save/Restore block, drawing ops are unioned with the bounds of // the block, and control ops are stashed away for later. When we finish the // block with a Restore, our bounds are complete, and we go back and fill them // in for all the control ops we stashed away. class FillBounds : SkNoncopyable { public: FillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) : fBounds(record.count()) { // Calculate bounds for all ops. This won't go quite in order, so we'll need // to store the bounds separately then feed them in to the BBH later in order. fCTM.setIdentity(); for (fCurrentOp = 0; fCurrentOp < record.count(); fCurrentOp++) { record.visit<void>(fCurrentOp, *this); } // If we have any lingering unpaired Saves, simulate restores to make // sure all ops in those Save blocks have their bounds calculated. while (!fSaveStack.isEmpty()) { this->popSaveBlock(); } // Any control ops not part of any Save/Restore block draw everywhere. while (!fControlIndices.isEmpty()) { this->popControl(SkIRect::MakeLargest()); } // Finally feed all stored bounds into the BBH. They'll be returned in this order. SkASSERT(NULL != bbh); for (uintptr_t i = 0; i < record.count(); i++) { if (!fBounds[i].isEmpty()) { bbh->insert((void*)i, fBounds[i], true/*ok to defer*/); } } bbh->flushDeferredInserts(); } template <typename T> void operator()(const T& r) { this->updateCTM(r); this->trackBounds(r); } private: struct SaveBounds { int controlOps; // Number of control ops in this Save block, including the Save. SkIRect bounds; // Bounds of everything in the block. }; template <typename T> void updateCTM(const T&) { /* most ops don't change the CTM */ } void updateCTM(const Restore& r) { fCTM = r.matrix; } void updateCTM(const SetMatrix& r) { fCTM = r.matrix; } void updateCTM(const Concat& r) { fCTM.preConcat(r.matrix); } // The bounds of these ops must be calculated when we hit the Restore // from the bounds of the ops in the same Save block. void trackBounds(const Save&) { this->pushSaveBlock(); } // TODO: bounds of SaveLayer may be more complicated? void trackBounds(const SaveLayer&) { this->pushSaveBlock(); } void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock(); } void trackBounds(const Concat&) { this->pushControl(); } void trackBounds(const SetMatrix&) { this->pushControl(); } void trackBounds(const ClipRect&) { this->pushControl(); } void trackBounds(const ClipRRect&) { this->pushControl(); } void trackBounds(const ClipPath&) { this->pushControl(); } void trackBounds(const ClipRegion&) { this->pushControl(); } // For all other ops, we can calculate and store the bounds directly now. template <typename T> void trackBounds(const T& op) { fBounds[fCurrentOp] = this->bounds(op); this->updateSaveBounds(fBounds[fCurrentOp]); } // TODO: remove this trivially-safe default when done bounding all ops template <typename T> SkIRect bounds(const T&) { return SkIRect::MakeLargest(); } void pushSaveBlock() { // Starting a new Save block. Push a new entry to represent that. SaveBounds sb = { 0, SkIRect::MakeEmpty() }; fSaveStack.push(sb); this->pushControl(); } SkIRect popSaveBlock() { // We're done the Save block. Apply the block's bounds to all control ops inside it. SaveBounds sb; fSaveStack.pop(&sb); while (sb.controlOps --> 0) { this->popControl(sb.bounds); } // This whole Save block may be part another Save block. this->updateSaveBounds(sb.bounds); // If called from a real Restore (not a phony one for balance), it'll need the bounds. return sb.bounds; } void pushControl() { fControlIndices.push(fCurrentOp); if (!fSaveStack.isEmpty()) { fSaveStack.top().controlOps++; } } void popControl(const SkIRect& bounds) { fBounds[fControlIndices.top()] = bounds; fControlIndices.pop(); } void updateSaveBounds(const SkIRect& bounds) { // If we're in a Save block, expand its bounds to cover these bounds too. if (!fSaveStack.isEmpty()) { fSaveStack.top().bounds.join(bounds); } } SkIRect bounds(const NoOp&) { return SkIRect::MakeEmpty(); } // NoOps don't draw anywhere. SkAutoTMalloc<SkIRect> fBounds; // One for each op in the record. SkMatrix fCTM; unsigned fCurrentOp; SkTDArray<SaveBounds> fSaveStack; SkTDArray<unsigned> fControlIndices; }; } // namespace SkRecords
namespace SkRecords { // NoOps draw nothing. template <> void Draw::draw(const NoOp&) {} #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } DRAW(Restore, restore()); DRAW(Save, save()); DRAW(SaveLayer, saveLayer(SkCanvas::SaveLayerRec(r.bounds, r.paint, r.backdrop.get(), r.saveLayerFlags))); DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); DRAW(Concat, concat(r.matrix)); DRAW(Translate, translate(r.dx, r.dy)); DRAW(ClipPath, clipPath(r.path, r.opAA.op, r.opAA.aa)); DRAW(ClipRRect, clipRRect(r.rrect, r.opAA.op, r.opAA.aa)); DRAW(ClipRect, clipRect(r.rect, r.opAA.op, r.opAA.aa)); DRAW(ClipRegion, clipRegion(r.region, r.op)); #ifdef SK_EXPERIMENTAL_SHADOWING DRAW(TranslateZ, SkCanvas::translateZ(r.z)); #else template <> void Draw::draw(const TranslateZ& r) { } #endif DRAW(DrawArc, drawArc(r.oval, r.startAngle, r.sweepAngle, r.useCenter, r.paint)); DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint)); DRAW(DrawImage, drawImage(r.image.get(), r.left, r.top, r.paint)); template <> void Draw::draw(const DrawImageLattice& r) { SkCanvas::Lattice lattice; lattice.fXCount = r.xCount; lattice.fXDivs = r.xDivs; lattice.fYCount = r.yCount; lattice.fYDivs = r.yDivs; lattice.fFlags = (0 == r.flagCount) ? nullptr : r.flags; lattice.fBounds = &r.src; fCanvas->drawImageLattice(r.image.get(), lattice, r.dst, r.paint); } DRAW(DrawImageRect, legacy_drawImageRect(r.image.get(), r.src, r.dst, r.paint, r.constraint)); DRAW(DrawImageNine, drawImageNine(r.image.get(), r.center, r.dst, r.paint)); DRAW(DrawOval, drawOval(r.oval, r.paint)); DRAW(DrawPaint, drawPaint(r.paint)); DRAW(DrawPath, drawPath(r.path, r.paint)); DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode, r.paint)); DRAW(DrawPicture, drawPicture(r.picture.get(), &r.matrix, r.paint)); #ifdef SK_EXPERIMENTAL_SHADOWING DRAW(DrawShadowedPicture, drawShadowedPicture(r.picture.get(), &r.matrix, r.paint, r.params)); #else template <> void Draw::draw(const DrawShadowedPicture& r) { } #endif DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint)); DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint)); DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); DRAW(DrawRect, drawRect(r.rect, r.paint)); DRAW(DrawRegion, drawRegion(r.region, r.paint)); DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); DRAW(DrawTextBlob, drawTextBlob(r.blob.get(), r.x, r.y, r.paint)); DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, &r.matrix, r.paint)); DRAW(DrawTextRSXform, drawTextRSXform(r.text, r.byteLength, r.xforms, r.cull, r.paint)); DRAW(DrawAtlas, drawAtlas(r.atlas.get(), r.xforms, r.texs, r.colors, r.count, r.mode, r.cull, r.paint)); DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, r.xmode, r.indices, r.indexCount, r.paint)); DRAW(DrawAnnotation, drawAnnotation(r.rect, r.key.c_str(), r.value.get())); #undef DRAW template <> void Draw::draw(const DrawDrawable& r) { SkASSERT(r.index >= 0); SkASSERT(r.index < fDrawableCount); if (fDrawables) { SkASSERT(nullptr == fDrawablePicts); fCanvas->drawDrawable(fDrawables[r.index], r.matrix); } else { fCanvas->drawPicture(fDrawablePicts[r.index], r.matrix, nullptr); } } // This is an SkRecord visitor that fills an SkBBoxHierarchy. // // The interesting part here is how to calculate bounds for ops which don't // have intrinsic bounds. What is the bounds of a Save or a Translate? // // We answer this by thinking about a particular definition of bounds: if I // don't execute this op, pixels in this rectangle might draw incorrectly. So // the bounds of a Save, a Translate, a Restore, etc. are the union of the // bounds of Draw* ops that they might have an effect on. For any given // Save/Restore block, the bounds of the Save, the Restore, and any other // non-drawing ("control") ops inside are exactly the union of the bounds of // the drawing ops inside that block. // // To implement this, we keep a stack of active Save blocks. As we consume ops // inside the Save/Restore block, drawing ops are unioned with the bounds of // the block, and control ops are stashed away for later. When we finish the // block with a Restore, our bounds are complete, and we go back and fill them // in for all the control ops we stashed away. class FillBounds : SkNoncopyable { public: FillBounds(const SkRect& cullRect, const SkRecord& record, SkRect bounds[]) : fNumRecords(record.count()) , fCullRect(cullRect) , fBounds(bounds) { fCTM = SkMatrix::I(); fCurrentClipBounds = fCullRect; } void cleanUp() { // If we have any lingering unpaired Saves, simulate restores to make // sure all ops in those Save blocks have their bounds calculated. while (!fSaveStack.isEmpty()) { this->popSaveBlock(); } // Any control ops not part of any Save/Restore block draw everywhere. while (!fControlIndices.isEmpty()) { this->popControl(fCullRect); } } void setCurrentOp(int currentOp) { fCurrentOp = currentOp; } template <typename T> void operator()(const T& op) { this->updateCTM(op); this->updateClipBounds(op); this->trackBounds(op); } // In this file, SkRect are in local coordinates, Bounds are translated back to identity space. typedef SkRect Bounds; int currentOp() const { return fCurrentOp; } const SkMatrix& ctm() const { return fCTM; } const Bounds& getBounds(int index) const { return fBounds[index]; } // Adjust rect for all paints that may affect its geometry, then map it to identity space. Bounds adjustAndMap(SkRect rect, const SkPaint* paint) const { // Inverted rectangles really confuse our BBHs. rect.sort(); // Adjust the rect for its own paint. if (!AdjustForPaint(paint, &rect)) { // The paint could do anything to our bounds. The only safe answer is the current clip. return fCurrentClipBounds; } // Adjust rect for all the paints from the SaveLayers we're inside. if (!this->adjustForSaveLayerPaints(&rect)) { // Same deal as above. return fCurrentClipBounds; } // Map the rect back to identity space. fCTM.mapRect(&rect); // Nothing can draw outside the current clip. if (!rect.intersect(fCurrentClipBounds)) { return Bounds::MakeEmpty(); } return rect; } private: struct SaveBounds { int controlOps; // Number of control ops in this Save block, including the Save. Bounds bounds; // Bounds of everything in the block. const SkPaint* paint; // Unowned. If set, adjusts the bounds of all ops in this block. SkMatrix ctm; }; // Only Restore, SetMatrix, Concat, and Translate change the CTM. template <typename T> void updateCTM(const T&) {} void updateCTM(const Restore& op) { fCTM = op.matrix; } void updateCTM(const SetMatrix& op) { fCTM = op.matrix; } void updateCTM(const Concat& op) { fCTM.preConcat(op.matrix); } void updateCTM(const Translate& op) { fCTM.preTranslate(op.dx, op.dy); } // Most ops don't change the clip. template <typename T> void updateClipBounds(const T&) {} // Clip{Path,RRect,Rect,Region} obviously change the clip. They all know their bounds already. void updateClipBounds(const ClipPath& op) { this->updateClipBoundsForClipOp(op.devBounds); } void updateClipBounds(const ClipRRect& op) { this->updateClipBoundsForClipOp(op.devBounds); } void updateClipBounds(const ClipRect& op) { this->updateClipBoundsForClipOp(op.devBounds); } void updateClipBounds(const ClipRegion& op) { this->updateClipBoundsForClipOp(op.devBounds); } // The bounds of clip ops need to be adjusted for the paints of saveLayers they're inside. void updateClipBoundsForClipOp(const SkIRect& devBounds) { Bounds clip = SkRect::Make(devBounds); // We don't call adjustAndMap() because as its last step it would intersect the adjusted // clip bounds with the previous clip, exactly what we can't do when the clip grows. if (this->adjustForSaveLayerPaints(&clip)) { fCurrentClipBounds = clip.intersect(fCullRect) ? clip : Bounds::MakeEmpty(); } else { fCurrentClipBounds = fCullRect; } } // Restore holds the devBounds for the clip after the {save,saveLayer}/restore block completes. void updateClipBounds(const Restore& op) { // This is just like the clip ops above, but we need to skip the effects (if any) of our // paired saveLayer (if it is one); it has not yet been popped off the save stack. Our // devBounds reflect the state of the world after the saveLayer/restore block is done, // so they are not affected by the saveLayer's paint. const int kSavesToIgnore = 1; Bounds clip = SkRect::Make(op.devBounds); if (this->adjustForSaveLayerPaints(&clip, kSavesToIgnore)) { fCurrentClipBounds = clip.intersect(fCullRect) ? clip : Bounds::MakeEmpty(); } else { fCurrentClipBounds = fCullRect; } } // We also take advantage of SaveLayer bounds when present to further cut the clip down. void updateClipBounds(const SaveLayer& op) { if (op.bounds) { // adjustAndMap() intersects these layer bounds with the previous clip for us. fCurrentClipBounds = this->adjustAndMap(*op.bounds, op.paint); } } // The bounds of these ops must be calculated when we hit the Restore // from the bounds of the ops in the same Save block. void trackBounds(const Save&) { this->pushSaveBlock(nullptr); } void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); } void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock(); } void trackBounds(const SetMatrix&) { this->pushControl(); } void trackBounds(const Concat&) { this->pushControl(); } void trackBounds(const Translate&) { this->pushControl(); } void trackBounds(const TranslateZ&) { this->pushControl(); } void trackBounds(const ClipRect&) { this->pushControl(); } void trackBounds(const ClipRRect&) { this->pushControl(); } void trackBounds(const ClipPath&) { this->pushControl(); } void trackBounds(const ClipRegion&) { this->pushControl(); } // For all other ops, we can calculate and store the bounds directly now. template <typename T> void trackBounds(const T& op) { fBounds[fCurrentOp] = this->bounds(op); this->updateSaveBounds(fBounds[fCurrentOp]); } void pushSaveBlock(const SkPaint* paint) { // Starting a new Save block. Push a new entry to represent that. SaveBounds sb; sb.controlOps = 0; // If the paint affects transparent black, the bound shouldn't be smaller // than the current clip bounds. sb.bounds = PaintMayAffectTransparentBlack(paint) ? fCurrentClipBounds : Bounds::MakeEmpty(); sb.paint = paint; sb.ctm = this->fCTM; fSaveStack.push(sb); this->pushControl(); } static bool PaintMayAffectTransparentBlack(const SkPaint* paint) { if (paint) { // FIXME: this is very conservative if (paint->getImageFilter() || paint->getColorFilter()) { return true; } // Unusual blendmodes require us to process a saved layer // even with operations outisde the clip. // For example, DstIn is used by masking layers. // https://code.google.com/p/skia/issues/detail?id=1291 // https://crbug.com/401593 switch (paint->getBlendMode()) { // For each of the following transfer modes, if the source // alpha is zero (our transparent black), the resulting // blended alpha is not necessarily equal to the original // destination alpha. case SkBlendMode::kClear: case SkBlendMode::kSrc: case SkBlendMode::kSrcIn: case SkBlendMode::kDstIn: case SkBlendMode::kSrcOut: case SkBlendMode::kDstATop: case SkBlendMode::kModulate: return true; break; default: break; } } return false; } Bounds popSaveBlock() { // We're done the Save block. Apply the block's bounds to all control ops inside it. SaveBounds sb; fSaveStack.pop(&sb); while (sb.controlOps --> 0) { this->popControl(sb.bounds); } // This whole Save block may be part another Save block. this->updateSaveBounds(sb.bounds); // If called from a real Restore (not a phony one for balance), it'll need the bounds. return sb.bounds; } void pushControl() { fControlIndices.push(fCurrentOp); if (!fSaveStack.isEmpty()) { fSaveStack.top().controlOps++; } } void popControl(const Bounds& bounds) { fBounds[fControlIndices.top()] = bounds; fControlIndices.pop(); } void updateSaveBounds(const Bounds& bounds) { // If we're in a Save block, expand its bounds to cover these bounds too. if (!fSaveStack.isEmpty()) { fSaveStack.top().bounds.join(bounds); } } // FIXME: this method could use better bounds Bounds bounds(const DrawText&) const { return fCurrentClipBounds; } Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; } Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOps don't draw. Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); } Bounds bounds(const DrawRegion& op) const { SkRect rect = SkRect::Make(op.region.getBounds()); return this->adjustAndMap(rect, &op.paint); } Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval, &op.paint); } // Tighter arc bounds? Bounds bounds(const DrawArc& op) const { return this->adjustAndMap(op.oval, &op.paint); } Bounds bounds(const DrawRRect& op) const { return this->adjustAndMap(op.rrect.rect(), &op.paint); } Bounds bounds(const DrawDRRect& op) const { return this->adjustAndMap(op.outer.rect(), &op.paint); } Bounds bounds(const DrawImage& op) const { const SkImage* image = op.image.get(); SkRect rect = SkRect::MakeXYWH(op.left, op.top, image->width(), image->height()); return this->adjustAndMap(rect, op.paint); } Bounds bounds(const DrawImageLattice& op) const { return this->adjustAndMap(op.dst, op.paint); } Bounds bounds(const DrawImageRect& op) const { return this->adjustAndMap(op.dst, op.paint); } Bounds bounds(const DrawImageNine& op) const { return this->adjustAndMap(op.dst, op.paint); } Bounds bounds(const DrawPath& op) const { return op.path.isInverseFillType() ? fCurrentClipBounds : this->adjustAndMap(op.path.getBounds(), &op.paint); } Bounds bounds(const DrawPoints& op) const { SkRect dst; dst.set(op.pts, op.count); // Pad the bounding box a little to make sure hairline points' bounds aren't empty. SkScalar stroke = SkMaxScalar(op.paint.getStrokeWidth(), 0.01f); dst.outset(stroke/2, stroke/2); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawPatch& op) const { SkRect dst; dst.set(op.cubics, SkPatchUtils::kNumCtrlPts); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawVertices& op) const { SkRect dst; dst.set(op.vertices, op.vertexCount); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawAtlas& op) const { if (op.cull) { // TODO: <reed> can we pass nullptr for the paint? Isn't cull already "correct" // for the paint (by the caller)? return this->adjustAndMap(*op.cull, op.paint); } else { return fCurrentClipBounds; } } Bounds bounds(const DrawPicture& op) const { SkRect dst = op.picture->cullRect(); op.matrix.mapRect(&dst); return this->adjustAndMap(dst, op.paint); } Bounds bounds(const DrawShadowedPicture& op) const { SkRect dst = op.picture->cullRect(); op.matrix.mapRect(&dst); return this->adjustAndMap(dst, op.paint); } Bounds bounds(const DrawPosText& op) const { const int N = op.paint.countText(op.text, op.byteLength); if (N == 0) { return Bounds::MakeEmpty(); } SkRect dst; dst.set(op.pos, N); AdjustTextForFontMetrics(&dst, op.paint); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawPosTextH& op) const { const int N = op.paint.countText(op.text, op.byteLength); if (N == 0) { return Bounds::MakeEmpty(); } SkScalar left = op.xpos[0], right = op.xpos[0]; for (int i = 1; i < N; i++) { left = SkMinScalar(left, op.xpos[i]); right = SkMaxScalar(right, op.xpos[i]); } SkRect dst = { left, op.y, right, op.y }; AdjustTextForFontMetrics(&dst, op.paint); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawTextOnPath& op) const { SkRect dst = op.path.getBounds(); // Pad all sides by the maximum padding in any direction we'd normally apply. SkRect pad = { 0, 0, 0, 0}; AdjustTextForFontMetrics(&pad, op.paint); // That maximum padding happens to always be the right pad today. SkASSERT(pad.fLeft == -pad.fRight); SkASSERT(pad.fTop == -pad.fBottom); SkASSERT(pad.fRight > pad.fBottom); dst.outset(pad.fRight, pad.fRight); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawTextRSXform& op) const { if (op.cull) { return this->adjustAndMap(*op.cull, nullptr); } else { return fCurrentClipBounds; } } Bounds bounds(const DrawTextBlob& op) const { SkRect dst = op.blob->bounds(); dst.offset(op.x, op.y); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawDrawable& op) const { return this->adjustAndMap(op.worstCaseBounds, nullptr); } Bounds bounds(const DrawAnnotation& op) const { return this->adjustAndMap(op.rect, nullptr); } static void AdjustTextForFontMetrics(SkRect* rect, const SkPaint& paint) { #ifdef SK_DEBUG SkRect correct = *rect; #endif // crbug.com/373785 ~~> xPad = 4x yPad // crbug.com/424824 ~~> bump yPad from 2x text size to 2.5x const SkScalar yPad = 2.5f * paint.getTextSize(), xPad = 4.0f * yPad; rect->outset(xPad, yPad); #ifdef SK_DEBUG SkPaint::FontMetrics metrics; paint.getFontMetrics(&metrics); correct.fLeft += metrics.fXMin; correct.fTop += metrics.fTop; correct.fRight += metrics.fXMax; correct.fBottom += metrics.fBottom; // See skia:2862 for why we ignore small text sizes. SkASSERTF(paint.getTextSize() < 0.001f || rect->contains(correct), "%f %f %f %f vs. %f %f %f %f\n", -xPad, -yPad, +xPad, +yPad, metrics.fXMin, metrics.fTop, metrics.fXMax, metrics.fBottom); #endif } // Returns true if rect was meaningfully adjusted for the effects of paint, // false if the paint could affect the rect in unknown ways. static bool AdjustForPaint(const SkPaint* paint, SkRect* rect) { if (paint) { if (paint->canComputeFastBounds()) { *rect = paint->computeFastBounds(*rect, rect); return true; } return false; } return true; } bool adjustForSaveLayerPaints(SkRect* rect, int savesToIgnore = 0) const { for (int i = fSaveStack.count() - 1 - savesToIgnore; i >= 0; i--) { SkMatrix inverse; if (!fSaveStack[i].ctm.invert(&inverse)) { return false; } inverse.mapRect(rect); if (!AdjustForPaint(fSaveStack[i].paint, rect)) { return false; } fSaveStack[i].ctm.mapRect(rect); } return true; } const int fNumRecords; // We do not guarantee anything for operations outside of the cull rect const SkRect fCullRect; // Conservative identity-space bounds for each op in the SkRecord. Bounds* fBounds; // We walk fCurrentOp through the SkRecord, as we go using updateCTM() // and updateClipBounds() to maintain the exact CTM (fCTM) and conservative // identity-space bounds of the current clip (fCurrentClipBounds). int fCurrentOp; SkMatrix fCTM; Bounds fCurrentClipBounds; // Used to track the bounds of Save/Restore blocks and the control ops inside them. SkTDArray<SaveBounds> fSaveStack; SkTDArray<int> fControlIndices; }; } // namespace SkRecords
namespace SkRecords { // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multiple threads. static SkBitmap shallow_copy(const SkBitmap& bitmap) { return bitmap; } // NoOps draw nothing. template <> void Draw::draw(const NoOp&) {} #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } DRAW(Restore, restore()); DRAW(Save, save()); DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags)); DRAW(PopCull, popCull()); DRAW(PushCull, pushCull(r.rect)); DRAW(Clear, clear(r.color)); DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); DRAW(ClipPath, clipPath(r.path, r.op, r.doAA)); DRAW(ClipRRect, clipRRect(r.rrect, r.op, r.doAA)); DRAW(ClipRect, clipRect(r.rect, r.op, r.doAA)); DRAW(ClipRegion, clipRegion(r.region, r.op)); DRAW(BeginCommentGroup, beginCommentGroup(r.description)); DRAW(AddComment, addComment(r.key, r.value)); DRAW(EndCommentGroup, endCommentGroup()); DRAW(DrawBitmap, drawBitmap(shallow_copy(r.bitmap), r.left, r.top, r.paint)); DRAW(DrawBitmapMatrix, drawBitmapMatrix(shallow_copy(r.bitmap), r.matrix, r.paint)); DRAW(DrawBitmapNine, drawBitmapNine(shallow_copy(r.bitmap), r.center, r.dst, r.paint)); DRAW(DrawBitmapRectToRect, drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, r.flags)); DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint)); DRAW(DrawImage, drawImage(r.image, r.left, r.top, r.paint)); DRAW(DrawImageRect, drawImageRect(r.image, r.src, r.dst, r.paint)); DRAW(DrawOval, drawOval(r.oval, r.paint)); DRAW(DrawPaint, drawPaint(r.paint)); DRAW(DrawPath, drawPath(r.path, r.paint)); DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode, r.paint)); DRAW(DrawPicture, drawPicture(r.picture, r.matrix, r.paint)); DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint)); DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint)); DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); DRAW(DrawRect, drawRect(r.rect, r.paint)); DRAW(DrawSprite, drawSprite(shallow_copy(r.bitmap), r.left, r.top, r.paint)); DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); DRAW(DrawTextBlob, drawTextBlob(r.blob, r.x, r.y, r.paint)); DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, r.matrix, r.paint)); DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, r.xmode.get(), r.indices, r.indexCount, r.paint)); DRAW(DrawData, drawData(r.data, r.length)); #undef DRAW // This is an SkRecord visitor that fills an SkBBoxHierarchy. // // The interesting part here is how to calculate bounds for ops which don't // have intrinsic bounds. What is the bounds of a Save or a Translate? // // We answer this by thinking about a particular definition of bounds: if I // don't execute this op, pixels in this rectangle might draw incorrectly. So // the bounds of a Save, a Translate, a Restore, etc. are the union of the // bounds of Draw* ops that they might have an effect on. For any given // Save/Restore block, the bounds of the Save, the Restore, and any other // non-drawing ("control") ops inside are exactly the union of the bounds of // the drawing ops inside that block. // // To implement this, we keep a stack of active Save blocks. As we consume ops // inside the Save/Restore block, drawing ops are unioned with the bounds of // the block, and control ops are stashed away for later. When we finish the // block with a Restore, our bounds are complete, and we go back and fill them // in for all the control ops we stashed away. class FillBounds : SkNoncopyable { public: FillBounds(const SkRect& cullRect, const SkRecord& record, SkBBoxHierarchy* bbh) : fCullRect(cullRect) , fBounds(record.count()) { // Calculate bounds for all ops. This won't go quite in order, so we'll need // to store the bounds separately then feed them in to the BBH later in order. fCTM = &SkMatrix::I(); fCurrentClipBounds = fCullRect; for (fCurrentOp = 0; fCurrentOp < record.count(); fCurrentOp++) { record.visit<void>(fCurrentOp, *this); } // If we have any lingering unpaired Saves, simulate restores to make // sure all ops in those Save blocks have their bounds calculated. while (!fSaveStack.isEmpty()) { this->popSaveBlock(); } // Any control ops not part of any Save/Restore block draw everywhere. while (!fControlIndices.isEmpty()) { this->popControl(fCullRect); } // Finally feed all stored bounds into the BBH. They'll be returned in this order. SkASSERT(bbh); bbh->insert(&fBounds, record.count()); } template <typename T> void operator()(const T& op) { this->updateCTM(op); this->updateClipBounds(op); this->trackBounds(op); } private: // In this file, SkRect are in local coordinates, Bounds are translated back to identity space. typedef SkRect Bounds; struct SaveBounds { int controlOps; // Number of control ops in this Save block, including the Save. Bounds bounds; // Bounds of everything in the block. const SkPaint* paint; // Unowned. If set, adjusts the bounds of all ops in this block. }; // Only Restore and SetMatrix change the CTM. template <typename T> void updateCTM(const T&) {} void updateCTM(const Restore& op) { fCTM = &op.matrix; } void updateCTM(const SetMatrix& op) { fCTM = &op.matrix; } // Most ops don't change the clip. template <typename T> void updateClipBounds(const T&) {} // Clip{Path,RRect,Rect,Region} obviously change the clip. They all know their bounds already. void updateClipBounds(const ClipPath& op) { this->updateClipBoundsForClipOp(op.devBounds); } void updateClipBounds(const ClipRRect& op) { this->updateClipBoundsForClipOp(op.devBounds); } void updateClipBounds(const ClipRect& op) { this->updateClipBoundsForClipOp(op.devBounds); } void updateClipBounds(const ClipRegion& op) { this->updateClipBoundsForClipOp(op.devBounds); } // The bounds of clip ops need to be adjusted for the paints of saveLayers they're inside. void updateClipBoundsForClipOp(const SkIRect& devBounds) { Bounds clip = SkRect::Make(devBounds); // We don't call adjustAndMap() because as its last step it would intersect the adjusted // clip bounds with the previous clip, exactly what we can't do when the clip grows. fCurrentClipBounds = this->adjustForSaveLayerPaints(&clip) ? clip : fCullRect; } // Restore holds the devBounds for the clip after the {save,saveLayer}/restore block completes. void updateClipBounds(const Restore& op) { // This is just like the clip ops above, but we need to skip the effects (if any) of our // paired saveLayer (if it is one); it has not yet been popped off the save stack. Our // devBounds reflect the state of the world after the saveLayer/restore block is done, // so they are not affected by the saveLayer's paint. const int kSavesToIgnore = 1; Bounds clip = SkRect::Make(op.devBounds); fCurrentClipBounds = this->adjustForSaveLayerPaints(&clip, kSavesToIgnore) ? clip : fCullRect; } // We also take advantage of SaveLayer bounds when present to further cut the clip down. void updateClipBounds(const SaveLayer& op) { if (op.bounds) { // adjustAndMap() intersects these layer bounds with the previous clip for us. fCurrentClipBounds = this->adjustAndMap(*op.bounds, op.paint); } } // The bounds of these ops must be calculated when we hit the Restore // from the bounds of the ops in the same Save block. void trackBounds(const Save&) { this->pushSaveBlock(NULL); } void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); } void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock(); } void trackBounds(const SetMatrix&) { this->pushControl(); } void trackBounds(const ClipRect&) { this->pushControl(); } void trackBounds(const ClipRRect&) { this->pushControl(); } void trackBounds(const ClipPath&) { this->pushControl(); } void trackBounds(const ClipRegion&) { this->pushControl(); } void trackBounds(const PushCull&) { this->pushControl(); } void trackBounds(const PopCull&) { this->pushControl(); } void trackBounds(const BeginCommentGroup&) { this->pushControl(); } void trackBounds(const AddComment&) { this->pushControl(); } void trackBounds(const EndCommentGroup&) { this->pushControl(); } void trackBounds(const DrawData&) { this->pushControl(); } // For all other ops, we can calculate and store the bounds directly now. template <typename T> void trackBounds(const T& op) { fBounds[fCurrentOp] = this->bounds(op); this->updateSaveBounds(fBounds[fCurrentOp]); } void pushSaveBlock(const SkPaint* paint) { // Starting a new Save block. Push a new entry to represent that. SaveBounds sb; sb.controlOps = 0; // If the paint affects transparent black, the bound shouldn't be smaller // than the current clip bounds. sb.bounds = PaintMayAffectTransparentBlack(paint) ? fCurrentClipBounds : Bounds::MakeEmpty(); sb.paint = paint; fSaveStack.push(sb); this->pushControl(); } static bool PaintMayAffectTransparentBlack(const SkPaint* paint) { if (paint) { // FIXME: this is very conservative if (paint->getImageFilter() || paint->getColorFilter()) { return true; } // Unusual Xfermodes require us to process a saved layer // even with operations outisde the clip. // For example, DstIn is used by masking layers. // https://code.google.com/p/skia/issues/detail?id=1291 // https://crbug.com/401593 SkXfermode* xfermode = paint->getXfermode(); SkXfermode::Mode mode; // SrcOver is ok, and is also the common case with a NULL xfermode. // So we should make that the fast path and bypass the mode extraction // and test. if (xfermode && xfermode->asMode(&mode)) { switch (mode) { // For each of the following transfer modes, if the source // alpha is zero (our transparent black), the resulting // blended alpha is not necessarily equal to the original // destination alpha. case SkXfermode::kClear_Mode: case SkXfermode::kSrc_Mode: case SkXfermode::kSrcIn_Mode: case SkXfermode::kDstIn_Mode: case SkXfermode::kSrcOut_Mode: case SkXfermode::kDstATop_Mode: case SkXfermode::kModulate_Mode: return true; break; default: break; } } } return false; } Bounds popSaveBlock() { // We're done the Save block. Apply the block's bounds to all control ops inside it. SaveBounds sb; fSaveStack.pop(&sb); while (sb.controlOps --> 0) { this->popControl(sb.bounds); } // This whole Save block may be part another Save block. this->updateSaveBounds(sb.bounds); // If called from a real Restore (not a phony one for balance), it'll need the bounds. return sb.bounds; } void pushControl() { fControlIndices.push(fCurrentOp); if (!fSaveStack.isEmpty()) { fSaveStack.top().controlOps++; } } void popControl(const Bounds& bounds) { fBounds[fControlIndices.top()] = bounds; fControlIndices.pop(); } void updateSaveBounds(const Bounds& bounds) { // If we're in a Save block, expand its bounds to cover these bounds too. if (!fSaveStack.isEmpty()) { fSaveStack.top().bounds.join(bounds); } } // FIXME: this method could use better bounds Bounds bounds(const DrawText&) const { return fCurrentClipBounds; } Bounds bounds(const Clear&) const { return fCullRect; } // Ignores the clip. Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; } Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOps don't draw. Bounds bounds(const DrawSprite& op) const { const SkBitmap& bm = op.bitmap; return Bounds::MakeXYWH(op.left, op.top, bm.width(), bm.height()); // Ignores the matrix. } Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); } Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval, &op.paint); } Bounds bounds(const DrawRRect& op) const { return this->adjustAndMap(op.rrect.rect(), &op.paint); } Bounds bounds(const DrawDRRect& op) const { return this->adjustAndMap(op.outer.rect(), &op.paint); } Bounds bounds(const DrawImage& op) const { const SkImage* image = op.image; SkRect rect = SkRect::MakeXYWH(op.left, op.top, image->width(), image->height()); return this->adjustAndMap(rect, op.paint); } Bounds bounds(const DrawImageRect& op) const { return this->adjustAndMap(op.dst, op.paint); } Bounds bounds(const DrawBitmapRectToRect& op) const { return this->adjustAndMap(op.dst, op.paint); } Bounds bounds(const DrawBitmapNine& op) const { return this->adjustAndMap(op.dst, op.paint); } Bounds bounds(const DrawBitmap& op) const { const SkBitmap& bm = op.bitmap; return this->adjustAndMap(SkRect::MakeXYWH(op.left, op.top, bm.width(), bm.height()), op.paint); } Bounds bounds(const DrawBitmapMatrix& op) const { const SkBitmap& bm = op.bitmap; SkRect dst = SkRect::MakeWH(bm.width(), bm.height()); op.matrix.mapRect(&dst); return this->adjustAndMap(dst, op.paint); } Bounds bounds(const DrawPath& op) const { return op.path.isInverseFillType() ? fCurrentClipBounds : this->adjustAndMap(op.path.getBounds(), &op.paint); } Bounds bounds(const DrawPoints& op) const { SkRect dst; dst.set(op.pts, op.count); // Pad the bounding box a little to make sure hairline points' bounds aren't empty. SkScalar stroke = SkMaxScalar(op.paint.getStrokeWidth(), 0.01f); dst.outset(stroke/2, stroke/2); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawPatch& op) const { SkRect dst; dst.set(op.cubics, SkPatchUtils::kNumCtrlPts); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawVertices& op) const { SkRect dst; dst.set(op.vertices, op.vertexCount); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawPicture& op) const { SkRect dst = op.picture->cullRect(); if (op.matrix) { op.matrix->mapRect(&dst); } return this->adjustAndMap(dst, op.paint); } Bounds bounds(const DrawPosText& op) const { const int N = op.paint.countText(op.text, op.byteLength); if (N == 0) { return Bounds::MakeEmpty(); } SkRect dst; dst.set(op.pos, N); AdjustTextForFontMetrics(&dst, op.paint); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawPosTextH& op) const { const int N = op.paint.countText(op.text, op.byteLength); if (N == 0) { return Bounds::MakeEmpty(); } SkScalar left = op.xpos[0], right = op.xpos[0]; for (int i = 1; i < N; i++) { left = SkMinScalar(left, op.xpos[i]); right = SkMaxScalar(right, op.xpos[i]); } SkRect dst = { left, op.y, right, op.y }; AdjustTextForFontMetrics(&dst, op.paint); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawTextOnPath& op) const { SkRect dst = op.path.getBounds(); // Pad all sides by the maximum padding in any direction we'd normally apply. SkRect pad = { 0, 0, 0, 0}; AdjustTextForFontMetrics(&pad, op.paint); // That maximum padding happens to always be the right pad today. SkASSERT(pad.fLeft == -pad.fRight); SkASSERT(pad.fTop == -pad.fBottom); SkASSERT(pad.fRight > pad.fBottom); dst.outset(pad.fRight, pad.fRight); return this->adjustAndMap(dst, &op.paint); } Bounds bounds(const DrawTextBlob& op) const { SkRect dst = op.blob->bounds(); dst.offset(op.x, op.y); return this->adjustAndMap(dst, &op.paint); } static void AdjustTextForFontMetrics(SkRect* rect, const SkPaint& paint) { #ifdef SK_DEBUG SkRect correct = *rect; #endif // crbug.com/373785 ~~> xPad = 4x yPad // crbug.com/424824 ~~> bump yPad from 2x text size to 2.5x const SkScalar yPad = 2.5f * paint.getTextSize(), xPad = 4.0f * yPad; rect->outset(xPad, yPad); #ifdef SK_DEBUG SkPaint::FontMetrics metrics; paint.getFontMetrics(&metrics); correct.fLeft += metrics.fXMin; correct.fTop += metrics.fTop; correct.fRight += metrics.fXMax; correct.fBottom += metrics.fBottom; // See skia:2862 for why we ignore small text sizes. SkASSERTF(paint.getTextSize() < 0.001f || rect->contains(correct), "%f %f %f %f vs. %f %f %f %f\n", -xPad, -yPad, +xPad, +yPad, metrics.fXMin, metrics.fTop, metrics.fXMax, metrics.fBottom); #endif } // Returns true if rect was meaningfully adjusted for the effects of paint, // false if the paint could affect the rect in unknown ways. static bool AdjustForPaint(const SkPaint* paint, SkRect* rect) { if (paint) { if (paint->canComputeFastBounds()) { *rect = paint->computeFastBounds(*rect, rect); return true; } return false; } return true; } bool adjustForSaveLayerPaints(SkRect* rect, int savesToIgnore = 0) const { for (int i = fSaveStack.count() - 1 - savesToIgnore; i >= 0; i--) { if (!AdjustForPaint(fSaveStack[i].paint, rect)) { return false; } } return true; } // Adjust rect for all paints that may affect its geometry, then map it to identity space. Bounds adjustAndMap(SkRect rect, const SkPaint* paint) const { // Inverted rectangles really confuse our BBHs. rect.sort(); // Adjust the rect for its own paint. if (!AdjustForPaint(paint, &rect)) { // The paint could do anything to our bounds. The only safe answer is the current clip. return fCurrentClipBounds; } // Adjust rect for all the paints from the SaveLayers we're inside. if (!this->adjustForSaveLayerPaints(&rect)) { // Same deal as above. return fCurrentClipBounds; } // Map the rect back to identity space. fCTM->mapRect(&rect); // Nothing can draw outside the current clip. // (Only bounded ops call into this method, so oddballs like Clear don't matter here.) rect.intersect(fCurrentClipBounds); return rect; } // We do not guarantee anything for operations outside of the cull rect const SkRect fCullRect; // Conservative identity-space bounds for each op in the SkRecord. SkAutoTMalloc<Bounds> fBounds; // We walk fCurrentOp through the SkRecord, as we go using updateCTM() // and updateClipBounds() to maintain the exact CTM (fCTM) and conservative // identity-space bounds of the current clip (fCurrentClipBounds). unsigned fCurrentOp; const SkMatrix* fCTM; Bounds fCurrentClipBounds; // Used to track the bounds of Save/Restore blocks and the control ops inside them. SkTDArray<SaveBounds> fSaveStack; SkTDArray<unsigned> fControlIndices; }; } // namespace SkRecords
void CLapPainter::DrawGeneralGraph(const LAPSUPPLIEROPTIONS& sfLapOpts, bool fHighlightXAxis) { vector<CExtendedLap*> lstLaps = m_pLapSupplier->GetLapsToShow(); DATA_CHANNEL eX; eX = DATA_CHANNEL_DISTANCE; set<DATA_CHANNEL> setY; map<DATA_CHANNEL,float> mapMinY; map<DATA_CHANNEL,float> mapMaxY; float dMaxX = -1e30; float dMinX = 1e30; float dCenterOvalX = 0; float dCenterOvalY = 0; { // figuring out bounds and getting matrices all set up // First lets load up all of the data into an array and determine its size for(int x = 0;x < lstLaps.size(); x++) { CExtendedLap* pLap = lstLaps[x]; DATA_CHANNEL eDataX = m_pLapSupplier->GetXChannel(); const IDataChannel* pDataX = pLap->GetChannel(eDataX); if(!pDataX || !pDataX->IsValid() || pDataX->GetData().size() <= 0) continue; vector<DATA_CHANNEL> lstDataY = m_pLapSupplier->GetYChannels(); for(int y = 0; y < lstDataY.size(); y++) // Loop through the data channels and display them { int ValueDisplay = 0; // Flag if we should display this channel as a graph or not 0 = yes, 1 = no const IDataChannel* pChannel = pLap->GetChannel(lstDataY[y]); if(!pChannel || !pChannel->IsValid()) continue; const DATA_CHANNEL eType = lstDataY[y]; // Determine if this Data Channel is one that we only want to display the values for for (int u = 0; u < sizeof lstDataY; u++) { if (eType == m_pLapSupplier->GetDisplayOptions().m_PlotPrefs[u].iDataChannel && m_pLapSupplier->GetDisplayOptions().m_PlotPrefs[u].iPlotView == false) { // We have found a display only channel. Let's prevent the graph from displaying ValueDisplay = 1; break; } } if(mapMinY.find(eType) == mapMinY.end()) { mapMinY[eType] = min(pChannel->GetMin(),m_pLapSupplier->GetDataHardcodedMin(eType)); mapMaxY[eType] = max(pChannel->GetMax(),m_pLapSupplier->GetDataHardcodedMax(eType)); } else { mapMinY[eType] = min(pChannel->GetMin(),mapMinY[eType]); mapMaxY[eType] = max(pChannel->GetMax(),mapMaxY[eType]); } if (ValueDisplay == 0) { setY.insert(eType); } } if(pDataX) { dMaxX = max(dMaxX, pDataX->GetMax()); dMinX = min(dMinX, pDataX->GetMin()); eX = pDataX->GetChannelType(); } } } if(setY.size() <= 0) { DrawSelectLapsPrompt(); return; } RECT rcSpot; int iSegmentHeight=0; { RECT rcClient; GetClientRect(OGL_GetHWnd(), &rcClient); iSegmentHeight = RECT_HEIGHT(&rcClient) / setY.size(); rcSpot.left = 0; rcSpot.top = 0; rcSpot.right = RECT_WIDTH(&rcClient); rcSpot.bottom = iSegmentHeight; } int iPos = 0; // y-channel graphing loop start for(set<DATA_CHANNEL>::iterator i = setY.begin(); i != setY.end(); i++) { vector<HIGHLIGHTDATA> lstMousePointsToDraw; glViewport(rcSpot.left,rcSpot.top,RECT_WIDTH(&rcSpot),RECT_HEIGHT(&rcSpot)); // now we have the bounds of all the laps we've looked at, so let's draw them glPushMatrix(); glLoadIdentity(); glScalef(1.0f, 0.90f, 1.0f); // Let's scale it so that graphs don't touch each other. glOrtho(dMinX, dMaxX,mapMinY[*i], mapMaxY[*i],-1.0,1.0); // draw horizontal guide lines and text on the background. Yes this should probably go into a function, Art ;) // first draw the starting guideline { float flLine = m_pLapSupplier->GetGuideStart(*i, mapMinY[*i], mapMaxY[*i]); LineColor(); // Pick guideline color, based upon chosen color scheme glLineWidth(1); // Added by KDJ. Skinny lines for guidelines. glBegin(GL_LINE_STRIP); glVertex2f(dMinX,flLine); glVertex2f(dMaxX,flLine); glEnd(); LineColor(); // Pick guideline color, based upon chosen color scheme char szText[256]; GetChannelString(*i, sfLapOpts.eUnitPreference, flLine, szText, NUMCHARS(szText)); DrawText(dMinX, flLine, szText); } // now draw the rest of them for(float flLine = m_pLapSupplier->GetGuideStart(*i, mapMinY[*i], mapMaxY[*i]) + m_pLapSupplier->GetGuideStep(*i, mapMinY[*i], mapMaxY[*i]); flLine < mapMaxY[*i]; flLine += m_pLapSupplier->GetGuideStep(*i, mapMinY[*i], mapMaxY[*i])) { LineColor(); // Pick guideline color, based upon chosen color scheme glLineWidth(1); // Added by KDJ. Skinny lines for guidelines. glBegin(GL_LINE_STRIP); glVertex2f(dMinX,flLine); glVertex2f(dMaxX,flLine); glEnd(); LineColor(); // Pick guideline color, based upon chosen color scheme char szText[256]; GetChannelString(*i, sfLapOpts.eUnitPreference, flLine, szText, NUMCHARS(szText)); DrawText(dMinX, flLine, szText); } // draw vertical guide lines and text on the background only if at 1.0X magnification if (sfLapOpts.iZoomLevels != 0) { } else { // first draw the starting guideline { float flLine = m_pLapSupplier->GetGuideStartX(eX, dMinX, dMaxX); LineColor(); // Pick guideline color, based upon chosen color scheme glLineWidth(1); dCenterOvalX = 0.0f; // Center oval at the origin dCenterOvalY = 0.0f; // dCenterOvalX = (dMaxX - dMinX) / 2.0f + dMinX; // dCenterOvalY = (mapMaxY[*i] - mapMinY[*i]) / 2.0f + mapMinY[*i]; // If this is for drawing the Traction Circle, let's draw a circle as well (Oval really) if (eX == DATA_CHANNEL_X_ACCEL || eX == DATA_CHANNEL_Y_ACCEL || eX == DATA_CHANNEL_Z_ACCEL) { float w, h; w = 3.0f; h = 3.0f; drawOval (dCenterOvalX, dCenterOvalY, w, h); // Draw 1.5G circle w = 1.0f; h = 1.0f; drawOval (dCenterOvalX, dCenterOvalY, w, h); // Draw 0.5G circle w = 2.0f; h = 2.0f; drawOval (dCenterOvalX, dCenterOvalY, w, h); // Draw 1.0G circle // Now let's draw a vertical line at the origin glBegin(GL_LINE_STRIP); glVertex3f(0.0f,mapMinY[*i],0); glVertex3f(0.0f,mapMaxY[*i],0); glEnd(); } else { glBegin(GL_LINE_STRIP); glVertex3f(flLine,mapMinY[*i],0); glVertex3f(flLine,mapMaxY[*i],0); glEnd(); } LineColor(); // Pick guideline color, based upon chosen color scheme char szText[256]; GetChannelString(eX, sfLapOpts.eUnitPreference, flLine, szText, NUMCHARS(szText)); DrawText(flLine, mapMinY[*i]-12, szText); } // now draw the rest of them for(float flLine = m_pLapSupplier->GetGuideStartX(eX, dMinX, dMaxX) + m_pLapSupplier->GetGuideStepX(eX, dMinX, dMaxX); flLine < dMaxX; flLine += m_pLapSupplier->GetGuideStepX(eX, dMinX, dMaxX)) { LineColor(); // Pick guideline color, based upon chosen color scheme glLineWidth(1); glBegin(GL_LINE_STRIP); glVertex3f(flLine,mapMinY[*i],0); glVertex3f(flLine,mapMaxY[*i],0); glEnd(); LineColor(); // Pick guideline color, based upon chosen color scheme char szText[256]; GetChannelString(eX, sfLapOpts.eUnitPreference, flLine, szText, NUMCHARS(szText)); DrawText(flLine, mapMinY[*i]-12, szText); } } // Set up the non-zoomed/panned view for the map GLdouble rgModelviewMatrix[16]; GLdouble rgProjMatrix[16]; GLint rgViewport[4]; { // Now that the matrices are correct, let's graph them. glGetDoublev(GL_MODELVIEW_MATRIX, rgModelviewMatrix); glGetDoublev(GL_PROJECTION_MATRIX, rgProjMatrix); glGetIntegerv(GL_VIEWPORT, rgViewport); POINT ptMouse; if(GetMouse(&ptMouse) && m_pLapSupplier->IsHighlightSource(m_iSupplierId)) { // The mouse is in our window, so panning and zooming are active! const double dCenterX = (dMinX + dMaxX)/2; // Center of X for scaling transformation double dScaleAmt = pow(1.08,sfLapOpts.iZoomLevels); GLdouble dXShift,dYShift,dZShift; // Project the window shift stuff so we know how far to translate the view dYShift = 0; // No Y shift or zoom for Map Plot. gluUnProject(sfLapOpts.flWindowShiftX/dScaleAmt,0,0,rgModelviewMatrix,rgProjMatrix,rgViewport,&dXShift,&dYShift,&dZShift); // Set up to perform the ZOOM function for DATA PLOT. double dTranslateShiftX; dTranslateShiftX= dCenterX; glTranslated(dTranslateShiftX,0,0); // Translate the map to origin on x-axis only glScaled(dScaleAmt,1.0,1.0); // No scaling of Y-axis on Data Plot. glTranslated(-dTranslateShiftX,0,0); // Now put the map back in its place // Panning functionality glTranslated(dXShift-dMinX,0,0); // Offset for this is still slight wrong, but the best for now. // Now having shifted, let's get our new model matrices glGetDoublev(GL_MODELVIEW_MATRIX, rgModelviewMatrix); glGetDoublev(GL_PROJECTION_MATRIX, rgProjMatrix); glGetIntegerv(GL_VIEWPORT, rgViewport); } } Vector2D ptHighlight; // the (x,y) coords in unit-space that we want to highlight. Example: for a speed-distance graph, x would be in distance units, y in velocities. POINT ptMouse; if(GetMouse(&ptMouse) && m_pLapSupplier->IsHighlightSource(m_iSupplierId)) { // The mouse is in our window... we make our own highlighter, ignoring anything that got sent to us GLdouble dX,dY,dZ; gluUnProject(ptMouse.x,ptMouse.y,0,rgModelviewMatrix,rgProjMatrix,rgViewport,&dX,&dY,&dZ); ptHighlight = V2D(dX,0); } for(int x = 0; x < lstLaps.size(); x++) { CExtendedLap* pLap = lstLaps[x]; const IDataChannel* pDataX = pLap->GetChannel(m_pLapSupplier->GetXChannel()); const IDataChannel* pDataY = pLap->GetChannel(*i); if(pDataX && pDataY) { // tracking what we want to highlight float dBestLength = -1; float dTimeToHighlight = -1; const vector<DataPoint>& lstPointsX = pDataX->GetData(); const vector<DataPoint>& lstPointsY = pDataY->GetData(); // srand((int)pLap); // <-- makes sure that we randomize the colours consistently, so that lap plots don't change colour from draw to draw... float r; float g; float b; MakeColor ( pLap, &r, &g, &b ); // Function picks color to use and tells opengl to draw the following in the colour we just made up if(sfLapOpts.fDrawLines) { glLineWidth(2); // Added by KDJ. Sets the width of the line to draw. glBegin(GL_LINE_STRIP); } else { glPointSize(4.0f); glBegin(GL_POINTS); } vector<DataPoint>::const_iterator iX = lstPointsX.begin(); vector<DataPoint>::const_iterator iY = lstPointsY.begin(); while(iX != lstPointsX.end() && iY != lstPointsY.end()) { float dX; float dY; const DataPoint& ptX = *iX; const DataPoint& ptY = *iY; int iTimeUsed = 0; if(ptX.iTimeMs < ptY.iTimeMs) { iTimeUsed = ptX.iTimeMs; dX = ptX.flValue; dY = pDataY->GetValue(ptX.iTimeMs, iY); iX++; } else if(ptX.iTimeMs > ptY.iTimeMs) { iTimeUsed = ptY.iTimeMs; dX = pDataX->GetValue(ptY.iTimeMs, iX); dY = ptY.flValue; iY++; } else { iTimeUsed = ptY.iTimeMs; DASSERT(ptX.iTimeMs == ptY.iTimeMs); dX = ptX.flValue; dY = ptY.flValue; iX++; iY++; } glVertex2f(dX,dY); // if we're a highlight source, try to figure out the closest point for this lap if(m_pLapSupplier->IsHighlightSource(m_iSupplierId)) { Vector2D vPt = V2D(dX,0); Vector2D vDiff = vPt - ptHighlight; if(vDiff.Length() < dBestLength || dBestLength < 0) { dBestLength = vDiff.Length(); dTimeToHighlight = iTimeUsed; } } } glEnd(); // for each lap, draw an indicator of the closest thing to the mouse if(!m_pLapSupplier->IsHighlightSource(m_iSupplierId)) { // if we're not a source, use the given time to highlight dTimeToHighlight = m_pLapSupplier->GetLapHighlightTime(pLap); } else { m_pLapSupplier->SetLapHighlightTime(pLap, (int)dTimeToHighlight); } UpdateHighlightPointList(lstMousePointsToDraw, pLap, rgModelviewMatrix, rgProjMatrix, rgViewport, dTimeToHighlight, pDataX, pDataY); } } // end lap loop if(lstMousePointsToDraw.size() > 0) { glPushMatrix(); // <-- pushes a matrix onto the opengl matrix stack. glLoadIdentity(); // <-- makes it so that the matrix stack just converts all our coordinates directly to window coordinates glOrtho(0, RECT_WIDTH(&rcSpot),0, RECT_HEIGHT(&rcSpot),-1.0,1.0); /* <-- tells OpenGL that it should show us the part of the openGL "world" that corresponds to (0...window width, 0 ... window height). This completes the "hey opengl, just draw where we tell you to plz" part of the function */ for(int x = 0; x < lstMousePointsToDraw.size(); x++) // <-- loops through all the stupid boxes/lines we want to draw { const CExtendedLap* pLap = lstMousePointsToDraw[x].m_pLap; // <-- gets the lap data we want to draw const POINT& ptWindow = lstMousePointsToDraw[x].m_ptWindow; // <-- gets info about where in the window we want to draw the box const IDataChannel* pDataX = lstMousePointsToDraw[x].m_pDataX; // <-- gets the x channel data const IDataChannel* pDataY = lstMousePointsToDraw[x].m_pDataY; // <-- gets the y channel data float r; float g; float b; MakeColor ( pLap, &r, &g, &b ); // Function picks color to use and tells opengl to draw the following in the colour we just made up // For TIME displayed on X-axis, remove all data channel text so that user can see the trends more clearly. if (pDataX->GetChannelType() != DATA_CHANNEL_TIME) { // if we're the main screen, we want to draw some text data for each point TCHAR szLapName[256]; pLap->GetString(szLapName, NUMCHARS(szLapName)); // <-- gets the string "10:11:12 - 1:40.59 - Keith", aka the "lap name" float dTimeToHighlight = m_pLapSupplier->GetLapHighlightTime(pLap); // <-- asks the ILapSupplier interface what we should highlight TCHAR szTypeX[256]; ::GetDataChannelName(eX,szTypeX,NUMCHARS(szTypeX)); // <-- converts the data channel type into a string, like "Oil Temperature" TCHAR szTypeY[256]; ::GetDataChannelName(lstMousePointsToDraw[x].m_eChannelY, szTypeY, NUMCHARS(szTypeY)); // <-- converts the y channel into a string char szYString[256]; GetChannelString(lstMousePointsToDraw[x].m_eChannelY, sfLapOpts.eUnitPreference, pDataY->GetValue(dTimeToHighlight), szYString, NUMCHARS(szYString)); // <-- gets the actual unit string for the data channel. For speed, this might be "100.0km/h" char szXString[256]; GetChannelString(eX, sfLapOpts.eUnitPreference, pDataX->GetValue(dTimeToHighlight), szXString, NUMCHARS(szXString)); // <-- same for x channel char szText[256]; sprintf(szText, "%S - (%S @ %S) %s @ %s", szLapName, szTypeY, szTypeX, szYString, szXString); DrawText(100.0,(x+1)*GetWindowFontSize(),szText); // <-- draws the text from the bottom of the window, working upwards // we also want to draw a highlighted square DrawGLFilledSquare(ptWindow.x, ptWindow.y, 3); // <-- draws the stupid little box at ptWindow.x. // we also want to draw a highlighted LINE for that individual lap/graph combination glLineWidth(1); // Added by KDJ. Skinny line for Distance markers. glBegin(GL_LINE_STRIP); // Added by KDJ glVertex3f(ptWindow.x, 0, 0); // Added by KDJ, modified by Chas glVertex3f(ptWindow.x,rcSpot.bottom,0); // Added by KDJ } glEnd(); // Added by KDJ } glPopMatrix(); glPopMatrix(); // Should there be two of these here? } rcSpot.top += iSegmentHeight; rcSpot.bottom += iSegmentHeight; } // end y-channel data channel loop }
void GDrawingSurface::drawOval(const GRectangle& bounds) { drawOval(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); }
void drawCircle(int x, int y, int radius, int seg, float part,float shift){ drawOval(x,y,radius,radius,seg,part,shift); }