| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 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 "SkData.h" | 10 #include "SkData.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 static void not_supported() { | 39 static void not_supported() { |
| 40 SkDEBUGFAIL("this method should never be called"); | 40 SkDEBUGFAIL("this method should never be called"); |
| 41 } | 41 } |
| 42 | 42 |
| 43 static void nothing_to_do() {} | 43 static void nothing_to_do() {} |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * This device will route all bitmaps (primitives and in shaders) to its PRSet. | 46 * This device will route all bitmaps (primitives and in shaders) to its PRSet. |
| 47 * It should never actually draw anything, so there need not be any pixels | 47 * It should never actually draw anything, so there need not be any pixels |
| 48 * behind its device-bitmap. | 48 * behind its device-bitmap. |
| 49 * FIXME: Derive from SkBaseDevice. |
| 49 */ | 50 */ |
| 50 class GatherPixelRefDevice : public SkBitmapDevice { | 51 class GatherPixelRefDevice : public SkBitmapDevice { |
| 51 private: | 52 private: |
| 52 PixelRefSet* fPRSet; | 53 PixelRefSet* fPRSet; |
| 53 | 54 |
| 54 void addBitmap(const SkBitmap& bm) { | 55 void addBitmap(const SkBitmap& bm) { |
| 55 fPRSet->add(bm.pixelRef()); | 56 fPRSet->add(bm.pixelRef()); |
| 56 } | 57 } |
| 57 | 58 |
| 58 void addBitmapFromPaint(const SkPaint& paint) { | 59 void addBitmapFromPaint(const SkPaint& paint) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 86 this->addBitmapFromPaint(paint); | 87 this->addBitmapFromPaint(paint); |
| 87 } | 88 } |
| 88 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, | 89 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, |
| 89 const SkPoint[], const SkPaint& paint) SK_OVERRIDE { | 90 const SkPoint[], const SkPaint& paint) SK_OVERRIDE { |
| 90 this->addBitmapFromPaint(paint); | 91 this->addBitmapFromPaint(paint); |
| 91 } | 92 } |
| 92 virtual void drawRect(const SkDraw&, const SkRect&, | 93 virtual void drawRect(const SkDraw&, const SkRect&, |
| 93 const SkPaint& paint) SK_OVERRIDE { | 94 const SkPaint& paint) SK_OVERRIDE { |
| 94 this->addBitmapFromPaint(paint); | 95 this->addBitmapFromPaint(paint); |
| 95 } | 96 } |
| 97 virtual void drawRRect(const SkDraw&, const SkRRect&, |
| 98 const SkPaint& paint) SK_OVERRIDE { |
| 99 this->addBitmapFromPaint(paint); |
| 100 } |
| 96 virtual void drawOval(const SkDraw&, const SkRect&, | 101 virtual void drawOval(const SkDraw&, const SkRect&, |
| 97 const SkPaint& paint) SK_OVERRIDE { | 102 const SkPaint& paint) SK_OVERRIDE { |
| 98 this->addBitmapFromPaint(paint); | 103 this->addBitmapFromPaint(paint); |
| 99 } | 104 } |
| 100 virtual void drawPath(const SkDraw&, const SkPath& path, | 105 virtual void drawPath(const SkDraw&, const SkPath& path, |
| 101 const SkPaint& paint, const SkMatrix* prePathMatrix, | 106 const SkPaint& paint, const SkMatrix* prePathMatrix, |
| 102 bool pathIsMutable) SK_OVERRIDE { | 107 bool pathIsMutable) SK_OVERRIDE { |
| 103 this->addBitmapFromPaint(paint); | 108 this->addBitmapFromPaint(paint); |
| 104 } | 109 } |
| 105 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, | 110 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 canvas.clipRect(area, SkRegion::kIntersect_Op, false); | 224 canvas.clipRect(area, SkRegion::kIntersect_Op, false); |
| 220 canvas.drawPicture(*pict); | 225 canvas.drawPicture(*pict); |
| 221 | 226 |
| 222 SkData* data = NULL; | 227 SkData* data = NULL; |
| 223 int count = array.count(); | 228 int count = array.count(); |
| 224 if (count > 0) { | 229 if (count > 0) { |
| 225 data = SkData::NewFromMalloc(array.detach(), count * sizeof(SkPixelRef*)
); | 230 data = SkData::NewFromMalloc(array.detach(), count * sizeof(SkPixelRef*)
); |
| 226 } | 231 } |
| 227 return data; | 232 return data; |
| 228 } | 233 } |
| OLD | NEW |