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

Side by Side Diff: src/core/SkPictureRecord.cpp

Issue 1261433009: Refugee from Dead Machine 11: Add SkCanvas::drawLitAtlas call Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 4 years, 7 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/core/SkPictureRecord.h ('k') | src/core/SkPoint3.cpp » ('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 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "SkPictureRecord.h" 8 #include "SkPictureRecord.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkImage_Base.h" 10 #include "SkImage_Base.h"
11 #include "SkLight.h"
11 #include "SkPatchUtils.h" 12 #include "SkPatchUtils.h"
12 #include "SkPixelRef.h" 13 #include "SkPixelRef.h"
13 #include "SkRRect.h" 14 #include "SkRRect.h"
14 #include "SkRSXform.h" 15 #include "SkRSXform.h"
15 #include "SkTextBlob.h" 16 #include "SkTextBlob.h"
16 #include "SkTSearch.h" 17 #include "SkTSearch.h"
17 18
18 #define HEAP_BLOCK_SIZE 4096 19 #define HEAP_BLOCK_SIZE 4096
19 20
20 enum { 21 enum {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 0, // PUSH_CULL - no paint 97 0, // PUSH_CULL - no paint
97 0, // POP_CULL - no paint 98 0, // POP_CULL - no paint
98 1, // DRAW_PATCH - right after op code 99 1, // DRAW_PATCH - right after op code
99 1, // DRAW_PICTURE_MATRIX_PAINT - right after op code 100 1, // DRAW_PICTURE_MATRIX_PAINT - right after op code
100 1, // DRAW_TEXT_BLOB- right after op code 101 1, // DRAW_TEXT_BLOB- right after op code
101 1, // DRAW_IMAGE - right after op code 102 1, // DRAW_IMAGE - right after op code
102 1, // DRAW_IMAGE_RECT_STRICT - right after op code 103 1, // DRAW_IMAGE_RECT_STRICT - right after op code
103 1, // DRAW_ATLAS - right after op code 104 1, // DRAW_ATLAS - right after op code
104 1, // DRAW_IMAGE_NINE - right after op code 105 1, // DRAW_IMAGE_NINE - right after op code
105 1, // DRAW_IMAGE_RECT - right after op code 106 1, // DRAW_IMAGE_RECT - right after op code
107 1, // DRAW_LIT_ATLAS - right after op code
106 }; 108 };
107 109
108 SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1, 110 SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1,
109 need_to_be_in_sync); 111 need_to_be_in_sync);
110 SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM); 112 SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM);
111 113
112 int overflow = 0; 114 int overflow = 0;
113 if (0 != (opSize & ~MASK_24) || opSize == MASK_24) { 115 if (0 != (opSize & ~MASK_24) || opSize == MASK_24) {
114 // This op's size overflows so an extra uint32_t will be written 116 // This op's size overflows so an extra uint32_t will be written
115 // after the op code 117 // after the op code
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 if (colors) { 883 if (colors) {
882 fWriter.write(colors, count * sizeof(SkColor)); 884 fWriter.write(colors, count * sizeof(SkColor));
883 this->addInt(mode); 885 this->addInt(mode);
884 } 886 }
885 if (cull) { 887 if (cull) {
886 fWriter.write(cull, sizeof(SkRect)); 888 fWriter.write(cull, sizeof(SkRect));
887 } 889 }
888 this->validate(initialOffset, size); 890 this->validate(initialOffset, size);
889 } 891 }
890 892
893 void SkPictureRecord::onDrawLitAtlas(const SkImage* atlas, const SkRSXform xform [],
894 const SkRect diffTex[], const SkRect normTe x[],
895 const SkColor colors[], int count, SkXfermo de::Mode mode,
896 const SkRect* cull, const SkPaint* paint,
897 const SkLight lights[], int numLights) {
898 // [op + paint-index + atlas-index + flags + count + lightCount] + [xform] + [diffTex + normTex] +
899 // [*colors + mode] + cull + [lights]
900 size_t size = 6 * kUInt32Size + count * sizeof(SkRSXform) + 2 * count * size of(SkRect) +
901 numLights * sizeof(SkPoint3);
902 uint32_t flags = 0;
903 if (colors) {
904 flags |= DRAW_ATLAS_HAS_COLORS;
905 size += count * sizeof(SkColor);
906 size += sizeof(uint32_t); // xfermode::mode
907 }
908 if (cull) {
909 flags |= DRAW_ATLAS_HAS_CULL;
910 size += sizeof(SkRect);
911 }
912
913 size_t initialOffset = this->addDraw(DRAW_LIT_ATLAS, &size);
914 SkASSERT(initialOffset+get_paint_offset(DRAW_LIT_ATLAS, size) == fWriter.byt esWritten());
915 this->addPaintPtr(paint);
916 this->addImage(atlas);
917 this->addInt(flags);
918 this->addInt(count);
919 fWriter.write(xform, count * sizeof(SkRSXform));
920 fWriter.write(diffTex, count * sizeof(SkRect));
921 fWriter.write(normTex, count * sizeof(SkRect));
922
923 // write optional parameters
924 if (colors) {
925 fWriter.write(colors, count * sizeof(SkColor));
926 this->addInt(mode);
927 }
928 if (cull) {
929 fWriter.write(cull, sizeof(SkRect));
930 }
931
932 this->addInt(numLights);
933 fWriter.write(lights, numLights* sizeof(SkLight));
934
935 this->validate(initialOffset, size);
936 }
891 /////////////////////////////////////////////////////////////////////////////// 937 ///////////////////////////////////////////////////////////////////////////////
892 938
893 SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfac eProps&) { 939 SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfac eProps&) {
894 return NULL; 940 return NULL;
895 } 941 }
896 942
897 // If we already have a stored, can we reuse it instead of also storing b? 943 // If we already have a stored, can we reuse it instead of also storing b?
898 static bool equivalent(const SkBitmap& a, const SkBitmap& b) { 944 static bool equivalent(const SkBitmap& a, const SkBitmap& b) {
899 if (a.info() != b.info() || a.pixelRefOrigin() != b.pixelRefOrigin()) { 945 if (a.info() != b.info() || a.pixelRefOrigin() != b.pixelRefOrigin()) {
900 // Requiring a.info() == b.info() may be overkill in some cases (alphaty pe mismatch), 946 // Requiring a.info() == b.info() may be overkill in some cases (alphaty pe mismatch),
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { 1110 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) {
1065 int index = fTextBlobRefs.count(); 1111 int index = fTextBlobRefs.count();
1066 *fTextBlobRefs.append() = blob; 1112 *fTextBlobRefs.append() = blob;
1067 blob->ref(); 1113 blob->ref();
1068 // follow the convention of recording a 1-based index 1114 // follow the convention of recording a 1-based index
1069 this->addInt(index + 1); 1115 this->addInt(index + 1);
1070 } 1116 }
1071 1117
1072 /////////////////////////////////////////////////////////////////////////////// 1118 ///////////////////////////////////////////////////////////////////////////////
1073 1119
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/core/SkPoint3.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698