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

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

Issue 511783005: SkTextBlob GPipe serialization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: review comments Created 6 years, 3 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
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | no next file » | 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"
11 #include "SkBitmapHeap.h" 11 #include "SkBitmapHeap.h"
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 #include "SkColorFilter.h" 13 #include "SkColorFilter.h"
14 #include "SkData.h" 14 #include "SkData.h"
15 #include "SkDrawLooper.h" 15 #include "SkDrawLooper.h"
16 #include "SkGPipe.h" 16 #include "SkGPipe.h"
17 #include "SkGPipePriv.h" 17 #include "SkGPipePriv.h"
18 #include "SkImageFilter.h" 18 #include "SkImageFilter.h"
19 #include "SkMaskFilter.h" 19 #include "SkMaskFilter.h"
20 #include "SkWriteBuffer.h" 20 #include "SkWriteBuffer.h"
21 #include "SkPaint.h" 21 #include "SkPaint.h"
22 #include "SkPatchUtils.h" 22 #include "SkPatchUtils.h"
23 #include "SkPathEffect.h" 23 #include "SkPathEffect.h"
24 #include "SkPictureFlat.h" 24 #include "SkPictureFlat.h"
25 #include "SkRasterizer.h" 25 #include "SkRasterizer.h"
26 #include "SkRRect.h" 26 #include "SkRRect.h"
27 #include "SkShader.h" 27 #include "SkShader.h"
28 #include "SkStream.h" 28 #include "SkStream.h"
29 #include "SkTextBlob.h"
29 #include "SkTSearch.h" 30 #include "SkTSearch.h"
30 #include "SkTypeface.h" 31 #include "SkTypeface.h"
31 #include "SkWriter32.h" 32 #include "SkWriter32.h"
32 33
33 enum { 34 enum {
34 kSizeOfFlatRRect = sizeof(SkRect) + 4 * sizeof(SkVector) 35 kSizeOfFlatRRect = sizeof(SkRect) + 4 * sizeof(SkVector)
35 }; 36 };
36 37
37 static bool isCrossProcess(uint32_t flags) { 38 static bool isCrossProcess(uint32_t flags) {
38 return SkToBool(flags & SkGPipeWriter::kCrossProcess_Flag); 39 return SkToBool(flags & SkGPipeWriter::kCrossProcess_Flag);
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 fWriter.writePath(path); 933 fWriter.writePath(path);
933 if (matrix) { 934 if (matrix) {
934 fWriter.writeMatrix(*matrix); 935 fWriter.writeMatrix(*matrix);
935 } 936 }
936 } 937 }
937 } 938 }
938 } 939 }
939 940
940 void SkGPipeCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 941 void SkGPipeCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
941 const SkPaint& paint) { 942 const SkPaint& paint) {
942 // FIXME: blob serialization only supports SkWriteBuffers 943 NOTIFY_SETUP(this);
943 // -- convert to SkWriter32 to avoid unrolling? 944 this->writePaint(paint);
944 this->INHERITED::onDrawTextBlob(blob, x, y, paint); 945
946 // FIXME: this is inefficient but avoids duplicating the blob serialization logic.
947 SkWriteBuffer blobBuffer;
948 blob->flatten(blobBuffer);
949
950 size_t size = sizeof(uint32_t) + 2 * sizeof(SkScalar) + blobBuffer.bytesWrit ten();
951 if (this->needOpBytes(size)) {
952 this->writeOp(kDrawTextBlob_DrawOp);
953 fWriter.writeScalar(x);
954 fWriter.writeScalar(y);
955 fWriter.write32(SkToU32(blobBuffer.bytesWritten()));
956 uint32_t* pad = fWriter.reservePad(blobBuffer.bytesWritten());
957 blobBuffer.writeToMemory(pad);
958 }
945 } 959 }
946 960
947 void SkGPipeCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matr ix, 961 void SkGPipeCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matr ix,
948 const SkPaint* paint) { 962 const SkPaint* paint) {
949 // we want to playback the picture into individual draw calls 963 // we want to playback the picture into individual draw calls
950 // 964 //
951 // todo: do we always have to unroll? If the pipe is not cross-process, seem s like 965 // todo: do we always have to unroll? If the pipe is not cross-process, seem s like
952 // we could just ref the picture and move on...? <reed, scroggo> 966 // we could just ref the picture and move on...? <reed, scroggo>
953 // 967 //
954 this->INHERITED::onDrawPicture(picture, matrix, paint); 968 this->INHERITED::onDrawPicture(picture, matrix, paint);
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 return fCanvas->shuttleBitmap(bitmap, slot); 1336 return fCanvas->shuttleBitmap(bitmap, slot);
1323 } 1337 }
1324 1338
1325 void BitmapShuttle::removeCanvas() { 1339 void BitmapShuttle::removeCanvas() {
1326 if (NULL == fCanvas) { 1340 if (NULL == fCanvas) {
1327 return; 1341 return;
1328 } 1342 }
1329 fCanvas->unref(); 1343 fCanvas->unref();
1330 fCanvas = NULL; 1344 fCanvas = NULL;
1331 } 1345 }
OLDNEW
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698