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 "SkBBoxHierarchy.h" | 8 #include "SkBBoxHierarchy.h" |
9 #include "SkBitmapDevice.h" | 9 #include "SkBitmapDevice.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 class GatherPixelRefDevice : public SkBaseDevice { | 53 class GatherPixelRefDevice : public SkBaseDevice { |
54 public: | 54 public: |
55 SK_DECLARE_INST_COUNT(GatherPixelRefDevice) | 55 SK_DECLARE_INST_COUNT(GatherPixelRefDevice) |
56 | 56 |
57 GatherPixelRefDevice(int width, int height, PixelRefSet* prset) { | 57 GatherPixelRefDevice(int width, int height, PixelRefSet* prset) { |
58 fSize.set(width, height); | 58 fSize.set(width, height); |
59 fEmptyBitmap.setInfo(SkImageInfo::MakeUnknown(width, height)); | 59 fEmptyBitmap.setInfo(SkImageInfo::MakeUnknown(width, height)); |
60 fPRSet = prset; | 60 fPRSet = prset; |
61 } | 61 } |
62 | 62 |
63 virtual SkImageInfo imageInfo() const SK_OVERRIDE { | 63 SkImageInfo imageInfo() const SK_OVERRIDE { |
64 return SkImageInfo::MakeUnknown(fSize.width(), fSize.height()); | 64 return SkImageInfo::MakeUnknown(fSize.width(), fSize.height()); |
65 } | 65 } |
66 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE { return NULL; } | 66 GrRenderTarget* accessRenderTarget() SK_OVERRIDE { return NULL; } |
67 // TODO: allow this call to return failure, or move to SkBitmapDevice only. | 67 // TODO: allow this call to return failure, or move to SkBitmapDevice only. |
68 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE { | 68 const SkBitmap& onAccessBitmap() SK_OVERRIDE { |
69 return fEmptyBitmap; | 69 return fEmptyBitmap; |
70 } | 70 } |
71 virtual void lockPixels() SK_OVERRIDE { nothing_to_do(); } | 71 void lockPixels() SK_OVERRIDE { nothing_to_do(); } |
72 virtual void unlockPixels() SK_OVERRIDE { nothing_to_do(); } | 72 void unlockPixels() SK_OVERRIDE { nothing_to_do(); } |
73 virtual bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE { return fal
se; } | 73 bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE { return false; } |
74 virtual bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE { return
false; } | 74 bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE { return false;
} |
75 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, const SkImag
eFilter::Context&, | 75 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, const SkImag
eFilter::Context&, |
76 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE { | 76 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE { |
77 return false; | 77 return false; |
78 } | 78 } |
79 | 79 |
80 virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE { | 80 void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE { |
81 this->addBitmapFromPaint(paint); | 81 this->addBitmapFromPaint(paint); |
82 } | 82 } |
83 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, | 83 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, |
84 const SkPoint[], const SkPaint& paint) SK_OVERRIDE { | 84 const SkPoint[], const SkPaint& paint) SK_OVERRIDE { |
85 this->addBitmapFromPaint(paint); | 85 this->addBitmapFromPaint(paint); |
86 } | 86 } |
87 virtual void drawRect(const SkDraw&, const SkRect&, | 87 virtual void drawRect(const SkDraw&, const SkRect&, |
88 const SkPaint& paint) SK_OVERRIDE { | 88 const SkPaint& paint) SK_OVERRIDE { |
89 this->addBitmapFromPaint(paint); | 89 this->addBitmapFromPaint(paint); |
90 } | 90 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 const uint16_t indices[], int indexCount, | 142 const uint16_t indices[], int indexCount, |
143 const SkPaint& paint) SK_OVERRIDE { | 143 const SkPaint& paint) SK_OVERRIDE { |
144 this->addBitmapFromPaint(paint); | 144 this->addBitmapFromPaint(paint); |
145 } | 145 } |
146 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, | 146 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
147 const SkPaint&) SK_OVERRIDE { | 147 const SkPaint&) SK_OVERRIDE { |
148 nothing_to_do(); | 148 nothing_to_do(); |
149 } | 149 } |
150 | 150 |
151 protected: | 151 protected: |
152 virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRI
DE { | 152 void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRIDE { |
153 not_supported(); | 153 not_supported(); |
154 } | 154 } |
155 virtual SkBaseDevice* onCreateCompatibleDevice(const CreateInfo& cinfo) SK_O
VERRIDE { | 155 SkBaseDevice* onCreateCompatibleDevice(const CreateInfo& cinfo) SK_OVERRIDE
{ |
156 // we expect to only get called via savelayer, in which case it is fine. | 156 // we expect to only get called via savelayer, in which case it is fine. |
157 SkASSERT(kSaveLayer_Usage == cinfo.fUsage); | 157 SkASSERT(kSaveLayer_Usage == cinfo.fUsage); |
158 return SkNEW_ARGS(GatherPixelRefDevice, (cinfo.fInfo.width(), cinfo.fInf
o.height(), fPRSet)); | 158 return SkNEW_ARGS(GatherPixelRefDevice, (cinfo.fInfo.width(), cinfo.fInf
o.height(), fPRSet)); |
159 } | 159 } |
160 virtual void flush() SK_OVERRIDE {} | 160 void flush() SK_OVERRIDE {} |
161 | 161 |
162 private: | 162 private: |
163 PixelRefSet* fPRSet; | 163 PixelRefSet* fPRSet; |
164 SkBitmap fEmptyBitmap; // legacy -- need to remove the need for this guy | 164 SkBitmap fEmptyBitmap; // legacy -- need to remove the need for this guy |
165 SkISize fSize; | 165 SkISize fSize; |
166 | 166 |
167 void addBitmap(const SkBitmap& bm) { | 167 void addBitmap(const SkBitmap& bm) { |
168 fPRSet->add(bm.pixelRef()); | 168 fPRSet->add(bm.pixelRef()); |
169 } | 169 } |
170 | 170 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 if (pict->fBBH.get()) { | 228 if (pict->fBBH.get()) { |
229 byteCount += pict->fBBH->bytesUsed(); | 229 byteCount += pict->fBBH->bytesUsed(); |
230 } | 230 } |
231 MeasureRecords visitor; | 231 MeasureRecords visitor; |
232 for (unsigned curOp = 0; curOp < pict->fRecord->count(); curOp++) { | 232 for (unsigned curOp = 0; curOp < pict->fRecord->count(); curOp++) { |
233 byteCount += pict->fRecord->visit<size_t>(curOp, visitor); | 233 byteCount += pict->fRecord->visit<size_t>(curOp, visitor); |
234 } | 234 } |
235 | 235 |
236 return byteCount; | 236 return byteCount; |
237 } | 237 } |
OLD | NEW |