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

Side by Side Diff: src/pipe/SkGPipeWrite.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/pipe/SkGPipeRead.cpp ('k') | src/ports/SkGlobalInitialization_default.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 /* 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 "SkBitmapHeap.h" 10 #include "SkBitmapHeap.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkColorFilter.h" 12 #include "SkColorFilter.h"
13 #include "SkData.h" 13 #include "SkData.h"
14 #include "SkDrawLooper.h" 14 #include "SkDrawLooper.h"
15 #include "SkGPipe.h" 15 #include "SkGPipe.h"
16 #include "SkGPipePriv.h" 16 #include "SkGPipePriv.h"
17 #include "SkImageFilter.h" 17 #include "SkImageFilter.h"
18 #include "SkLight.h"
18 #include "SkMaskFilter.h" 19 #include "SkMaskFilter.h"
19 #include "SkRSXform.h" 20 #include "SkRSXform.h"
20 #include "SkWriteBuffer.h" 21 #include "SkWriteBuffer.h"
21 #include "SkPaint.h" 22 #include "SkPaint.h"
22 #include "SkPatchUtils.h" 23 #include "SkPatchUtils.h"
23 #include "SkPathEffect.h" 24 #include "SkPathEffect.h"
24 #include "SkPictureFlat.h" 25 #include "SkPictureFlat.h"
25 #include "SkPtrRecorder.h" 26 #include "SkPtrRecorder.h"
26 #include "SkRasterizer.h" 27 #include "SkRasterizer.h"
27 #include "SkRRect.h" 28 #include "SkRRect.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, 286 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
286 const SkPaint*) override; 287 const SkPaint*) override;
287 void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) overri de; 288 void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) overri de;
288 void onDrawVertices(VertexMode vmode, int vertexCount, 289 void onDrawVertices(VertexMode vmode, int vertexCount,
289 const SkPoint vertices[], const SkPoint texs[], 290 const SkPoint vertices[], const SkPoint texs[],
290 const SkColor colors[], SkXfermode* xmode, 291 const SkColor colors[], SkXfermode* xmode,
291 const uint16_t indices[], int indexCount, 292 const uint16_t indices[], int indexCount,
292 const SkPaint&) override; 293 const SkPaint&) override;
293 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const Sk Color[], 294 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const Sk Color[],
294 int count, SkXfermode::Mode, const SkRect* cull, const SkPa int*) override; 295 int count, SkXfermode::Mode, const SkRect* cull, const SkPa int*) override;
296 void onDrawLitAtlas(const SkImage*, const SkRSXform[],
297 const SkRect diffTex[], const SkRect normTex[], const Sk Color[],
298 int count, SkXfermode::Mode, const SkRect* cull,
299 const SkPaint*, const SkLight lights[], int numLights) o verride;
295 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; 300 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
296 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; 301 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
297 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; 302 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;
298 void onClipRegion(const SkRegion&, SkRegion::Op) override; 303 void onClipRegion(const SkRegion&, SkRegion::Op) override;
299 304
300 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri de; 305 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri de;
301 306
302 private: 307 private:
303 void recordTranslate(const SkMatrix&); 308 void recordTranslate(const SkMatrix&);
304 void recordScale(const SkMatrix&); 309 void recordScale(const SkMatrix&);
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 fWriter.write(tex, count * sizeof(SkRect)); 1152 fWriter.write(tex, count * sizeof(SkRect));
1148 if (colors) { 1153 if (colors) {
1149 fWriter.write(colors, count * sizeof(SkColor)); 1154 fWriter.write(colors, count * sizeof(SkColor));
1150 } 1155 }
1151 if (cull) { 1156 if (cull) {
1152 fWriter.writeRect(*cull); 1157 fWriter.writeRect(*cull);
1153 } 1158 }
1154 } 1159 }
1155 } 1160 }
1156 1161
1162
1163 void SkGPipeCanvas::onDrawLitAtlas(const SkImage* atlas, const SkRSXform xform[] ,
1164 const SkRect diffTex[], const SkRect normTex[ ],
1165 const SkColor colors[], int count,
1166 SkXfermode::Mode mode, const SkRect* cull,
1167 const SkPaint* paint,
1168 const SkLight lights[], int numLights) {
1169 NOTIFY_SETUP(this);
1170 unsigned flags = 0; // packs with the op, so needs no extra space
1171
1172 if (paint) {
1173 flags |= kDrawAtlas_HasPaint_DrawOpFlag;
1174 this->writePaint(*paint);
1175 }
1176
1177 size_t size = 4; // image-slot
1178 size += 4; // count
1179 size += 4; // mode
1180 size += 4; // num lights
1181 size += count * sizeof(SkRSXform); // xform
1182 size += 2 * count * sizeof(SkRect); // diffTex + normTex
1183 if (colors) {
1184 flags |= kDrawAtlas_HasColors_DrawOpFlag;
1185 size += count * sizeof(SkColor); // colors
1186 }
1187 if (cull) {
1188 flags |= kDrawAtlas_HasCull_DrawOpFlag;
1189 size += sizeof(SkRect); // cull
1190 }
1191 size += numLights * sizeof(SkLight); // lights
1192
1193 if (this->needOpBytes(size)) {
1194 this->writeOp(kDrawLitAtlas_DrawOp, flags, 0);
1195 int32_t slot = fImageHeap->insert(atlas);
1196 fWriter.write32(slot);
1197 fWriter.write32(count);
1198 fWriter.write32(mode);
1199 fWriter.write(xform, count * sizeof(SkRSXform));
1200 fWriter.write(diffTex, count * sizeof(SkRect));
1201 fWriter.write(normTex, count * sizeof(SkRect));
1202 if (colors) {
1203 fWriter.write(colors, count * sizeof(SkColor));
1204 }
1205 if (cull) {
1206 fWriter.writeRect(*cull);
1207 }
1208 fWriter.write32(numLights);
1209 fWriter.write(lights, numLights * sizeof(SkLight));
1210 }
1211 }
1212
1157 void SkGPipeCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4 ], 1213 void SkGPipeCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4 ],
1158 const SkPoint texCoords[4], SkXfermode* xmode, 1214 const SkPoint texCoords[4], SkXfermode* xmode,
1159 const SkPaint& paint) { 1215 const SkPaint& paint) {
1160 NOTIFY_SETUP(this); 1216 NOTIFY_SETUP(this);
1161 1217
1162 size_t size = SkPatchUtils::kNumCtrlPts * sizeof(SkPoint); 1218 size_t size = SkPatchUtils::kNumCtrlPts * sizeof(SkPoint);
1163 unsigned flags = 0; 1219 unsigned flags = 0;
1164 if (colors) { 1220 if (colors) {
1165 flags |= kDrawVertices_HasColors_DrawOpFlag; 1221 flags |= kDrawVertices_HasColors_DrawOpFlag;
1166 size += SkPatchUtils::kNumCorners * sizeof(SkColor); 1222 size += SkPatchUtils::kNumCorners * sizeof(SkColor);
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 int32_t slot = this->find(img); 1542 int32_t slot = this->find(img);
1487 if (slot) { 1543 if (slot) {
1488 return slot; 1544 return slot;
1489 } 1545 }
1490 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. 1546 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess.
1491 fBytesInCache += img->width() * img->height() * 4; 1547 fBytesInCache += img->width() * img->height() * 4;
1492 *fArray.append() = SkRef(img); 1548 *fArray.append() = SkRef(img);
1493 return fArray.count(); // slot is always index+1 1549 return fArray.count(); // slot is always index+1
1494 } 1550 }
1495 1551
OLDNEW
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | src/ports/SkGlobalInitialization_default.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698