OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 if (fSkipEmptyClips) { | 342 if (fSkipEmptyClips) { |
343 while (fCurrLayer && fCurrLayer->fClip.isEmpty()) { | 343 while (fCurrLayer && fCurrLayer->fClip.isEmpty()) { |
344 fCurrLayer = fCurrLayer->fNext; | 344 fCurrLayer = fCurrLayer->fNext; |
345 } | 345 } |
346 } | 346 } |
347 | 347 |
348 const DeviceCM* rec = fCurrLayer; | 348 const DeviceCM* rec = fCurrLayer; |
349 if (rec && rec->fDevice) { | 349 if (rec && rec->fDevice) { |
350 | 350 |
351 fMatrix = rec->fMatrix; | 351 fMatrix = rec->fMatrix; |
352 fClip = &((SkRasterClip*)&rec->fClip)->forceGetBW(); | |
353 fRC = &rec->fClip; | 352 fRC = &rec->fClip; |
354 fDevice = rec->fDevice; | 353 fDevice = rec->fDevice; |
355 if (!fDevice->accessPixels(&fDst)) { | 354 if (!fDevice->accessPixels(&fDst)) { |
356 fDst.reset(fDevice->imageInfo(), nullptr, 0); | 355 fDst.reset(fDevice->imageInfo(), nullptr, 0); |
357 } | 356 } |
358 fPaint = rec->fPaint; | 357 fPaint = rec->fPaint; |
359 SkDEBUGCODE(this->validate();) | 358 SkDEBUGCODE(this->validate();) |
360 | 359 |
361 fCurrLayer = rec->fNext; | 360 fCurrLayer = rec->fNext; |
362 // fCurrLayer may be nullptr now | 361 // fCurrLayer may be nullptr now |
363 | 362 |
364 return true; | 363 return true; |
365 } | 364 } |
366 return false; | 365 return false; |
367 } | 366 } |
368 | 367 |
369 SkBaseDevice* getDevice() const { return fDevice; } | 368 SkBaseDevice* getDevice() const { return fDevice; } |
| 369 const SkRasterClip& getClip() const { return *fRC; } |
370 int getX() const { return fDevice->getOrigin().x(); } | 370 int getX() const { return fDevice->getOrigin().x(); } |
371 int getY() const { return fDevice->getOrigin().y(); } | 371 int getY() const { return fDevice->getOrigin().y(); } |
372 const SkMatrix& getMatrix() const { return *fMatrix; } | 372 const SkMatrix& getMatrix() const { return *fMatrix; } |
373 const SkRegion& getClip() const { return *fClip; } | |
374 const SkPaint* getPaint() const { return fPaint; } | 373 const SkPaint* getPaint() const { return fPaint; } |
375 | 374 |
376 private: | 375 private: |
377 SkCanvas* fCanvas; | 376 SkCanvas* fCanvas; |
378 const DeviceCM* fCurrLayer; | 377 const DeviceCM* fCurrLayer; |
379 const SkPaint* fPaint; // May be null. | 378 const SkPaint* fPaint; // May be null. |
380 SkBool8 fSkipEmptyClips; | 379 SkBool8 fSkipEmptyClips; |
381 | 380 |
382 typedef SkDraw INHERITED; | 381 typedef SkDraw INHERITED; |
383 }; | 382 }; |
(...skipping 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2496 } | 2495 } |
2497 } | 2496 } |
2498 | 2497 |
2499 void SkCanvas::DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, | 2498 void SkCanvas::DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, |
2500 const char text[], size_t byteLength, | 2499 const char text[], size_t byteLength, |
2501 SkScalar x, SkScalar y) { | 2500 SkScalar x, SkScalar y) { |
2502 SkASSERT(byteLength == 0 || text != nullptr); | 2501 SkASSERT(byteLength == 0 || text != nullptr); |
2503 | 2502 |
2504 // nothing to draw | 2503 // nothing to draw |
2505 if (text == nullptr || byteLength == 0 || | 2504 if (text == nullptr || byteLength == 0 || |
2506 draw.fClip->isEmpty() || | 2505 draw.fRC->isEmpty() || |
2507 (paint.getAlpha() == 0 && paint.getXfermode() == nullptr)) { | 2506 (paint.getAlpha() == 0 && paint.getXfermode() == nullptr)) { |
2508 return; | 2507 return; |
2509 } | 2508 } |
2510 | 2509 |
2511 SkScalar width = 0; | 2510 SkScalar width = 0; |
2512 SkPoint start; | 2511 SkPoint start; |
2513 | 2512 |
2514 start.set(0, 0); // to avoid warning | 2513 start.set(0, 0); // to avoid warning |
2515 if (paint.getFlags() & (SkPaint::kUnderlineText_Flag | | 2514 if (paint.getFlags() & (SkPaint::kUnderlineText_Flag | |
2516 SkPaint::kStrikeThruText_Flag)) { | 2515 SkPaint::kStrikeThruText_Flag)) { |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2987 } | 2986 } |
2988 | 2987 |
2989 const SkPaint& SkCanvas::LayerIter::paint() const { | 2988 const SkPaint& SkCanvas::LayerIter::paint() const { |
2990 const SkPaint* paint = fImpl->getPaint(); | 2989 const SkPaint* paint = fImpl->getPaint(); |
2991 if (nullptr == paint) { | 2990 if (nullptr == paint) { |
2992 paint = &fDefaultPaint; | 2991 paint = &fDefaultPaint; |
2993 } | 2992 } |
2994 return *paint; | 2993 return *paint; |
2995 } | 2994 } |
2996 | 2995 |
2997 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } | 2996 const SkRasterClip& SkCanvas::LayerIter::clip() const { return fImpl->getClip();
} |
2998 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } | 2997 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } |
2999 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } | 2998 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } |
3000 | 2999 |
3001 /////////////////////////////////////////////////////////////////////////////// | 3000 /////////////////////////////////////////////////////////////////////////////// |
3002 | 3001 |
3003 SkCanvasClipVisitor::~SkCanvasClipVisitor() { } | 3002 SkCanvasClipVisitor::~SkCanvasClipVisitor() { } |
3004 | 3003 |
3005 /////////////////////////////////////////////////////////////////////////////// | 3004 /////////////////////////////////////////////////////////////////////////////// |
3006 | 3005 |
3007 static bool supported_for_raster_canvas(const SkImageInfo& info) { | 3006 static bool supported_for_raster_canvas(const SkImageInfo& info) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3061 | 3060 |
3062 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3061 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3063 fCanvas->restoreToCount(fSaveCount); | 3062 fCanvas->restoreToCount(fSaveCount); |
3064 } | 3063 } |
3065 | 3064 |
3066 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3065 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
3067 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3066 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
3068 return this->makeSurface(info, props).release(); | 3067 return this->makeSurface(info, props).release(); |
3069 } | 3068 } |
3070 #endif | 3069 #endif |
OLD | NEW |