| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkAnnotation.h" | 9 #include "SkAnnotation.h" |
| 10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 const SkPaint*) SK_OVERRIDE; | 242 const SkPaint*) SK_OVERRIDE; |
| 243 virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src, | 243 virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src, |
| 244 const SkRect& dst, const SkPaint* paint, | 244 const SkRect& dst, const SkPaint* paint, |
| 245 DrawBitmapRectFlags flags) SK_OVERRIDE; | 245 DrawBitmapRectFlags flags) SK_OVERRIDE; |
| 246 virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&, | 246 virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&, |
| 247 const SkPaint*) SK_OVERRIDE; | 247 const SkPaint*) SK_OVERRIDE; |
| 248 virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, | 248 virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
| 249 const SkRect& dst, const SkPaint* paint = NULL)
SK_OVERRIDE; | 249 const SkRect& dst, const SkPaint* paint = NULL)
SK_OVERRIDE; |
| 250 virtual void drawSprite(const SkBitmap&, int left, int top, | 250 virtual void drawSprite(const SkBitmap&, int left, int top, |
| 251 const SkPaint*) SK_OVERRIDE; | 251 const SkPaint*) SK_OVERRIDE; |
| 252 virtual void drawText(const void* text, size_t byteLength, SkScalar x, |
| 253 SkScalar y, const SkPaint&) SK_OVERRIDE; |
| 254 virtual void drawPosText(const void* text, size_t byteLength, |
| 255 const SkPoint pos[], const SkPaint&) SK_OVERRIDE; |
| 256 virtual void drawPosTextH(const void* text, size_t byteLength, |
| 257 const SkScalar xpos[], SkScalar constY, |
| 258 const SkPaint&) SK_OVERRIDE; |
| 259 virtual void drawTextOnPath(const void* text, size_t byteLength, |
| 260 const SkPath& path, const SkMatrix* matrix, |
| 261 const SkPaint&) SK_OVERRIDE; |
| 252 virtual void drawPicture(SkPicture& picture) SK_OVERRIDE; | 262 virtual void drawPicture(SkPicture& picture) SK_OVERRIDE; |
| 253 virtual void drawVertices(VertexMode, int vertexCount, | 263 virtual void drawVertices(VertexMode, int vertexCount, |
| 254 const SkPoint vertices[], const SkPoint texs[], | 264 const SkPoint vertices[], const SkPoint texs[], |
| 255 const SkColor colors[], SkXfermode*, | 265 const SkColor colors[], SkXfermode*, |
| 256 const uint16_t indices[], int indexCount, | 266 const uint16_t indices[], int indexCount, |
| 257 const SkPaint&) SK_OVERRIDE; | 267 const SkPaint&) SK_OVERRIDE; |
| 258 virtual void drawData(const void*, size_t) SK_OVERRIDE; | 268 virtual void drawData(const void*, size_t) SK_OVERRIDE; |
| 259 virtual void beginCommentGroup(const char* description) SK_OVERRIDE; | 269 virtual void beginCommentGroup(const char* description) SK_OVERRIDE; |
| 260 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE; | 270 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE; |
| 261 virtual void endCommentGroup() SK_OVERRIDE; | 271 virtual void endCommentGroup() SK_OVERRIDE; |
| 262 | 272 |
| 263 /** | 273 /** |
| 264 * Flatten an SkBitmap to send to the reader, where it will be referenced | 274 * Flatten an SkBitmap to send to the reader, where it will be referenced |
| 265 * according to slot. | 275 * according to slot. |
| 266 */ | 276 */ |
| 267 bool shuttleBitmap(const SkBitmap&, int32_t slot); | 277 bool shuttleBitmap(const SkBitmap&, int32_t slot); |
| 268 | 278 |
| 269 protected: | 279 protected: |
| 270 virtual void willSave(SaveFlags) SK_OVERRIDE; | 280 virtual void willSave(SaveFlags) SK_OVERRIDE; |
| 271 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags) SK_OVERRIDE; | 281 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags) SK_OVERRIDE; |
| 272 virtual void willRestore() SK_OVERRIDE; | 282 virtual void willRestore() SK_OVERRIDE; |
| 273 | 283 |
| 274 virtual void didConcat(const SkMatrix&) SK_OVERRIDE; | 284 virtual void didConcat(const SkMatrix&) SK_OVERRIDE; |
| 275 virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; | 285 virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; |
| 276 | 286 |
| 277 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK
_OVERRIDE; | 287 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK
_OVERRIDE; |
| 278 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkS
calar y, | |
| 279 const SkPaint&) SK_OVERRIDE; | |
| 280 virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoin
t pos[], | |
| 281 const SkPaint&) SK_OVERRIDE; | |
| 282 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkSca
lar xpos[], | |
| 283 SkScalar constY, const SkPaint&) SK_OVERRIDE; | |
| 284 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkP
ath& path, | |
| 285 const SkMatrix* matrix, const SkPaint&) SK_OVE
RRIDE; | |
| 286 | 288 |
| 287 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; | 289 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; |
| 288 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVE
RRIDE; | 290 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVE
RRIDE; |
| 289 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; | 291 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR
IDE; |
| 290 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; | 292 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; |
| 291 | 293 |
| 292 private: | 294 private: |
| 293 void recordTranslate(const SkMatrix&); | 295 void recordTranslate(const SkMatrix&); |
| 294 void recordScale(const SkMatrix&); | 296 void recordScale(const SkMatrix&); |
| 295 void recordConcat(const SkMatrix&); | 297 void recordConcat(const SkMatrix&); |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 const SkPaint* paint) { | 843 const SkPaint* paint) { |
| 842 NOTIFY_SETUP(this); | 844 NOTIFY_SETUP(this); |
| 843 size_t opBytesNeeded = sizeof(int32_t) * 2; | 845 size_t opBytesNeeded = sizeof(int32_t) * 2; |
| 844 | 846 |
| 845 if (this->commonDrawBitmap(bm, kDrawSprite_DrawOp, 0, opBytesNeeded, paint))
{ | 847 if (this->commonDrawBitmap(bm, kDrawSprite_DrawOp, 0, opBytesNeeded, paint))
{ |
| 846 fWriter.write32(left); | 848 fWriter.write32(left); |
| 847 fWriter.write32(top); | 849 fWriter.write32(top); |
| 848 } | 850 } |
| 849 } | 851 } |
| 850 | 852 |
| 851 void SkGPipeCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x,
SkScalar y, | 853 void SkGPipeCanvas::drawText(const void* text, size_t byteLength, SkScalar x, |
| 852 const SkPaint& paint) { | 854 SkScalar y, const SkPaint& paint) { |
| 853 if (byteLength) { | 855 if (byteLength) { |
| 854 NOTIFY_SETUP(this); | 856 NOTIFY_SETUP(this); |
| 855 this->writePaint(paint); | 857 this->writePaint(paint); |
| 856 if (this->needOpBytes(4 + SkAlign4(byteLength) + 2 * sizeof(SkScalar)))
{ | 858 if (this->needOpBytes(4 + SkAlign4(byteLength) + 2 * sizeof(SkScalar)))
{ |
| 857 this->writeOp(kDrawText_DrawOp); | 859 this->writeOp(kDrawText_DrawOp); |
| 858 fWriter.write32(byteLength); | 860 fWriter.write32(byteLength); |
| 859 fWriter.writePad(text, byteLength); | 861 fWriter.writePad(text, byteLength); |
| 860 fWriter.writeScalar(x); | 862 fWriter.writeScalar(x); |
| 861 fWriter.writeScalar(y); | 863 fWriter.writeScalar(y); |
| 862 } | 864 } |
| 863 } | 865 } |
| 864 } | 866 } |
| 865 | 867 |
| 866 void SkGPipeCanvas::onDrawPosText(const void* text, size_t byteLength, const SkP
oint pos[], | 868 void SkGPipeCanvas::drawPosText(const void* text, size_t byteLength, |
| 867 const SkPaint& paint) { | 869 const SkPoint pos[], const SkPaint& paint) { |
| 868 if (byteLength) { | 870 if (byteLength) { |
| 869 NOTIFY_SETUP(this); | 871 NOTIFY_SETUP(this); |
| 870 this->writePaint(paint); | 872 this->writePaint(paint); |
| 871 int count = paint.textToGlyphs(text, byteLength, NULL); | 873 int count = paint.textToGlyphs(text, byteLength, NULL); |
| 872 if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkPo
int))) { | 874 if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkPo
int))) { |
| 873 this->writeOp(kDrawPosText_DrawOp); | 875 this->writeOp(kDrawPosText_DrawOp); |
| 874 fWriter.write32(byteLength); | 876 fWriter.write32(byteLength); |
| 875 fWriter.writePad(text, byteLength); | 877 fWriter.writePad(text, byteLength); |
| 876 fWriter.write32(count); | 878 fWriter.write32(count); |
| 877 fWriter.write(pos, count * sizeof(SkPoint)); | 879 fWriter.write(pos, count * sizeof(SkPoint)); |
| 878 } | 880 } |
| 879 } | 881 } |
| 880 } | 882 } |
| 881 | 883 |
| 882 void SkGPipeCanvas::onDrawPosTextH(const void* text, size_t byteLength, const Sk
Scalar xpos[], | 884 void SkGPipeCanvas::drawPosTextH(const void* text, size_t byteLength, |
| 883 SkScalar constY, const SkPaint& paint) { | 885 const SkScalar xpos[], SkScalar constY, |
| 886 const SkPaint& paint) { |
| 884 if (byteLength) { | 887 if (byteLength) { |
| 885 NOTIFY_SETUP(this); | 888 NOTIFY_SETUP(this); |
| 886 this->writePaint(paint); | 889 this->writePaint(paint); |
| 887 int count = paint.textToGlyphs(text, byteLength, NULL); | 890 int count = paint.textToGlyphs(text, byteLength, NULL); |
| 888 if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkSc
alar) + 4)) { | 891 if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkSc
alar) + 4)) { |
| 889 this->writeOp(kDrawPosTextH_DrawOp); | 892 this->writeOp(kDrawPosTextH_DrawOp); |
| 890 fWriter.write32(byteLength); | 893 fWriter.write32(byteLength); |
| 891 fWriter.writePad(text, byteLength); | 894 fWriter.writePad(text, byteLength); |
| 892 fWriter.write32(count); | 895 fWriter.write32(count); |
| 893 fWriter.write(xpos, count * sizeof(SkScalar)); | 896 fWriter.write(xpos, count * sizeof(SkScalar)); |
| 894 fWriter.writeScalar(constY); | 897 fWriter.writeScalar(constY); |
| 895 } | 898 } |
| 896 } | 899 } |
| 897 } | 900 } |
| 898 | 901 |
| 899 void SkGPipeCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const
SkPath& path, | 902 void SkGPipeCanvas::drawTextOnPath(const void* text, size_t byteLength, |
| 900 const SkMatrix* matrix, const SkPaint& pain
t) { | 903 const SkPath& path, const SkMatrix* matrix, |
| 904 const SkPaint& paint) { |
| 901 if (byteLength) { | 905 if (byteLength) { |
| 902 NOTIFY_SETUP(this); | 906 NOTIFY_SETUP(this); |
| 903 unsigned flags = 0; | 907 unsigned flags = 0; |
| 904 size_t size = 4 + SkAlign4(byteLength) + path.writeToMemory(NULL); | 908 size_t size = 4 + SkAlign4(byteLength) + path.writeToMemory(NULL); |
| 905 if (matrix) { | 909 if (matrix) { |
| 906 flags |= kDrawTextOnPath_HasMatrix_DrawOpFlag; | 910 flags |= kDrawTextOnPath_HasMatrix_DrawOpFlag; |
| 907 size += matrix->writeToMemory(NULL); | 911 size += matrix->writeToMemory(NULL); |
| 908 } | 912 } |
| 909 this->writePaint(paint); | 913 this->writePaint(paint); |
| 910 if (this->needOpBytes(size)) { | 914 if (this->needOpBytes(size)) { |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 return fCanvas->shuttleBitmap(bitmap, slot); | 1246 return fCanvas->shuttleBitmap(bitmap, slot); |
| 1243 } | 1247 } |
| 1244 | 1248 |
| 1245 void BitmapShuttle::removeCanvas() { | 1249 void BitmapShuttle::removeCanvas() { |
| 1246 if (NULL == fCanvas) { | 1250 if (NULL == fCanvas) { |
| 1247 return; | 1251 return; |
| 1248 } | 1252 } |
| 1249 fCanvas->unref(); | 1253 fCanvas->unref(); |
| 1250 fCanvas = NULL; | 1254 fCanvas = NULL; |
| 1251 } | 1255 } |
| OLD | NEW |