Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: src/pipe/SkGPipeWrite.cpp

Issue 248083002: Make drawText calls non-virtual, to ease SkFont and TextBlob (https://codereview.chromium.org/24385… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | src/record/SkRecorder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
262 virtual void drawPicture(SkPicture& picture) SK_OVERRIDE; 252 virtual void drawPicture(SkPicture& picture) SK_OVERRIDE;
263 virtual void drawVertices(VertexMode, int vertexCount, 253 virtual void drawVertices(VertexMode, int vertexCount,
264 const SkPoint vertices[], const SkPoint texs[], 254 const SkPoint vertices[], const SkPoint texs[],
265 const SkColor colors[], SkXfermode*, 255 const SkColor colors[], SkXfermode*,
266 const uint16_t indices[], int indexCount, 256 const uint16_t indices[], int indexCount,
267 const SkPaint&) SK_OVERRIDE; 257 const SkPaint&) SK_OVERRIDE;
268 virtual void drawData(const void*, size_t) SK_OVERRIDE; 258 virtual void drawData(const void*, size_t) SK_OVERRIDE;
269 virtual void beginCommentGroup(const char* description) SK_OVERRIDE; 259 virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
270 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE; 260 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
271 virtual void endCommentGroup() SK_OVERRIDE; 261 virtual void endCommentGroup() SK_OVERRIDE;
272 262
273 /** 263 /**
274 * Flatten an SkBitmap to send to the reader, where it will be referenced 264 * Flatten an SkBitmap to send to the reader, where it will be referenced
275 * according to slot. 265 * according to slot.
276 */ 266 */
277 bool shuttleBitmap(const SkBitmap&, int32_t slot); 267 bool shuttleBitmap(const SkBitmap&, int32_t slot);
278 268
279 protected: 269 protected:
280 virtual void willSave(SaveFlags) SK_OVERRIDE; 270 virtual void willSave(SaveFlags) SK_OVERRIDE;
281 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF lags) SK_OVERRIDE; 271 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF lags) SK_OVERRIDE;
282 virtual void willRestore() SK_OVERRIDE; 272 virtual void willRestore() SK_OVERRIDE;
283 273
284 virtual void didConcat(const SkMatrix&) SK_OVERRIDE; 274 virtual void didConcat(const SkMatrix&) SK_OVERRIDE;
285 virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; 275 virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
286 276
287 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK _OVERRIDE; 277 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;
288 286
289 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERR IDE; 287 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERR IDE;
290 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVE RRIDE; 288 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVE RRIDE;
291 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR IDE; 289 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR IDE;
292 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; 290 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
293 291
294 private: 292 private:
295 void recordTranslate(const SkMatrix&); 293 void recordTranslate(const SkMatrix&);
296 void recordScale(const SkMatrix&); 294 void recordScale(const SkMatrix&);
297 void recordConcat(const SkMatrix&); 295 void recordConcat(const SkMatrix&);
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 const SkPaint* paint) { 841 const SkPaint* paint) {
844 NOTIFY_SETUP(this); 842 NOTIFY_SETUP(this);
845 size_t opBytesNeeded = sizeof(int32_t) * 2; 843 size_t opBytesNeeded = sizeof(int32_t) * 2;
846 844
847 if (this->commonDrawBitmap(bm, kDrawSprite_DrawOp, 0, opBytesNeeded, paint)) { 845 if (this->commonDrawBitmap(bm, kDrawSprite_DrawOp, 0, opBytesNeeded, paint)) {
848 fWriter.write32(left); 846 fWriter.write32(left);
849 fWriter.write32(top); 847 fWriter.write32(top);
850 } 848 }
851 } 849 }
852 850
853 void SkGPipeCanvas::drawText(const void* text, size_t byteLength, SkScalar x, 851 void SkGPipeCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
854 SkScalar y, const SkPaint& paint) { 852 const SkPaint& paint) {
855 if (byteLength) { 853 if (byteLength) {
856 NOTIFY_SETUP(this); 854 NOTIFY_SETUP(this);
857 this->writePaint(paint); 855 this->writePaint(paint);
858 if (this->needOpBytes(4 + SkAlign4(byteLength) + 2 * sizeof(SkScalar))) { 856 if (this->needOpBytes(4 + SkAlign4(byteLength) + 2 * sizeof(SkScalar))) {
859 this->writeOp(kDrawText_DrawOp); 857 this->writeOp(kDrawText_DrawOp);
860 fWriter.write32(byteLength); 858 fWriter.write32(byteLength);
861 fWriter.writePad(text, byteLength); 859 fWriter.writePad(text, byteLength);
862 fWriter.writeScalar(x); 860 fWriter.writeScalar(x);
863 fWriter.writeScalar(y); 861 fWriter.writeScalar(y);
864 } 862 }
865 } 863 }
866 } 864 }
867 865
868 void SkGPipeCanvas::drawPosText(const void* text, size_t byteLength, 866 void SkGPipeCanvas::onDrawPosText(const void* text, size_t byteLength, const SkP oint pos[],
869 const SkPoint pos[], const SkPaint& paint) { 867 const SkPaint& paint) {
870 if (byteLength) { 868 if (byteLength) {
871 NOTIFY_SETUP(this); 869 NOTIFY_SETUP(this);
872 this->writePaint(paint); 870 this->writePaint(paint);
873 int count = paint.textToGlyphs(text, byteLength, NULL); 871 int count = paint.textToGlyphs(text, byteLength, NULL);
874 if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkPo int))) { 872 if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkPo int))) {
875 this->writeOp(kDrawPosText_DrawOp); 873 this->writeOp(kDrawPosText_DrawOp);
876 fWriter.write32(byteLength); 874 fWriter.write32(byteLength);
877 fWriter.writePad(text, byteLength); 875 fWriter.writePad(text, byteLength);
878 fWriter.write32(count); 876 fWriter.write32(count);
879 fWriter.write(pos, count * sizeof(SkPoint)); 877 fWriter.write(pos, count * sizeof(SkPoint));
880 } 878 }
881 } 879 }
882 } 880 }
883 881
884 void SkGPipeCanvas::drawPosTextH(const void* text, size_t byteLength, 882 void SkGPipeCanvas::onDrawPosTextH(const void* text, size_t byteLength, const Sk Scalar xpos[],
885 const SkScalar xpos[], SkScalar constY, 883 SkScalar constY, const SkPaint& paint) {
886 const SkPaint& paint) {
887 if (byteLength) { 884 if (byteLength) {
888 NOTIFY_SETUP(this); 885 NOTIFY_SETUP(this);
889 this->writePaint(paint); 886 this->writePaint(paint);
890 int count = paint.textToGlyphs(text, byteLength, NULL); 887 int count = paint.textToGlyphs(text, byteLength, NULL);
891 if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkSc alar) + 4)) { 888 if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkSc alar) + 4)) {
892 this->writeOp(kDrawPosTextH_DrawOp); 889 this->writeOp(kDrawPosTextH_DrawOp);
893 fWriter.write32(byteLength); 890 fWriter.write32(byteLength);
894 fWriter.writePad(text, byteLength); 891 fWriter.writePad(text, byteLength);
895 fWriter.write32(count); 892 fWriter.write32(count);
896 fWriter.write(xpos, count * sizeof(SkScalar)); 893 fWriter.write(xpos, count * sizeof(SkScalar));
897 fWriter.writeScalar(constY); 894 fWriter.writeScalar(constY);
898 } 895 }
899 } 896 }
900 } 897 }
901 898
902 void SkGPipeCanvas::drawTextOnPath(const void* text, size_t byteLength, 899 void SkGPipeCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
903 const SkPath& path, const SkMatrix* matrix, 900 const SkMatrix* matrix, const SkPaint& pain t) {
904 const SkPaint& paint) {
905 if (byteLength) { 901 if (byteLength) {
906 NOTIFY_SETUP(this); 902 NOTIFY_SETUP(this);
907 unsigned flags = 0; 903 unsigned flags = 0;
908 size_t size = 4 + SkAlign4(byteLength) + path.writeToMemory(NULL); 904 size_t size = 4 + SkAlign4(byteLength) + path.writeToMemory(NULL);
909 if (matrix) { 905 if (matrix) {
910 flags |= kDrawTextOnPath_HasMatrix_DrawOpFlag; 906 flags |= kDrawTextOnPath_HasMatrix_DrawOpFlag;
911 size += matrix->writeToMemory(NULL); 907 size += matrix->writeToMemory(NULL);
912 } 908 }
913 this->writePaint(paint); 909 this->writePaint(paint);
914 if (this->needOpBytes(size)) { 910 if (this->needOpBytes(size)) {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 return fCanvas->shuttleBitmap(bitmap, slot); 1242 return fCanvas->shuttleBitmap(bitmap, slot);
1247 } 1243 }
1248 1244
1249 void BitmapShuttle::removeCanvas() { 1245 void BitmapShuttle::removeCanvas() {
1250 if (NULL == fCanvas) { 1246 if (NULL == fCanvas) {
1251 return; 1247 return;
1252 } 1248 }
1253 fCanvas->unref(); 1249 fCanvas->unref();
1254 fCanvas = NULL; 1250 fCanvas = NULL;
1255 } 1251 }
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | src/record/SkRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698