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

Side by Side Diff: include/core/SkCanvas.h

Issue 2167223002: Revert of Creating framework for drawShadowedPicture (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 5 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 | « gyp/common_variables.gypi ('k') | include/core/SkLights.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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 #ifndef SkCanvas_DEFINED 8 #ifndef SkCanvas_DEFINED
9 #define SkCanvas_DEFINED 9 #define SkCanvas_DEFINED
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 #include "SkBitmap.h" 12 #include "SkBitmap.h"
13 #include "SkDeque.h" 13 #include "SkDeque.h"
14 #include "SkImage.h" 14 #include "SkImage.h"
15 #include "SkPaint.h" 15 #include "SkPaint.h"
16 #include "SkRefCnt.h" 16 #include "SkRefCnt.h"
17 #include "SkRegion.h" 17 #include "SkRegion.h"
18 #include "SkSurfaceProps.h" 18 #include "SkSurfaceProps.h"
19 #include "SkXfermode.h" 19 #include "SkXfermode.h"
20 #include "SkLights.h"
21 20
22 class GrContext; 21 class GrContext;
23 class GrDrawContext; 22 class GrDrawContext;
24 class SkBaseDevice; 23 class SkBaseDevice;
25 class SkCanvasClipVisitor; 24 class SkCanvasClipVisitor;
26 class SkClipStack; 25 class SkClipStack;
27 class SkData; 26 class SkData;
28 class SkDraw; 27 class SkDraw;
29 class SkDrawable; 28 class SkDrawable;
30 class SkDrawFilter; 29 class SkDrawFilter;
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 444
446 /** Replace the current matrix with a copy of the specified matrix. 445 /** Replace the current matrix with a copy of the specified matrix.
447 @param matrix The matrix that will be copied into the current matrix. 446 @param matrix The matrix that will be copied into the current matrix.
448 */ 447 */
449 void setMatrix(const SkMatrix& matrix); 448 void setMatrix(const SkMatrix& matrix);
450 449
451 /** Helper for setMatrix(identity). Sets the current matrix to identity. 450 /** Helper for setMatrix(identity). Sets the current matrix to identity.
452 */ 451 */
453 void resetMatrix(); 452 void resetMatrix();
454 453
455 #ifdef SK_EXPERIMENTAL_SHADOWING
456 /** Add the specified translation to the current draw depth of the canvas. 454 /** Add the specified translation to the current draw depth of the canvas.
457 @param z The distance to translate in Z. 455 @param z The distance to translate in Z.
458 Negative into screen, positive out of screen. 456 Negative into screen, positive out of screen.
459 Without translation, the draw depth defaults to 0. 457 Without translation, the draw depth defaults to 0.
460 */ 458 */
461 void translateZ(SkScalar z); 459 void translateZ(SkScalar z);
462 460
463 /** Set the current set of lights in the canvas.
464 @param lights The lights that we want the canvas to have.
465 */
466 void setLights(sk_sp<SkLights> lights);
467
468 /** Returns the current set of lights the canvas uses
469 */
470 sk_sp<SkLights> getLights() const;
471 #endif
472
473 /** 461 /**
474 * Modify the current clip with the specified rectangle. 462 * Modify the current clip with the specified rectangle.
475 * @param rect The rect to combine with the current clip 463 * @param rect The rect to combine with the current clip
476 * @param op The region op to apply to the current clip 464 * @param op The region op to apply to the current clip
477 * @param doAntiAlias true if the clip should be antialiased 465 * @param doAntiAlias true if the clip should be antialiased
478 */ 466 */
479 void clipRect(const SkRect& rect, 467 void clipRect(const SkRect& rect,
480 SkRegion::Op op = SkRegion::kIntersect_Op, 468 SkRegion::Op op = SkRegion::kIntersect_Op,
481 bool doAntiAlias = false); 469 bool doAntiAlias = false);
482 470
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 * If paint is non-null, draw the picture into a temporary buffer, and then apply the paint's 1042 * If paint is non-null, draw the picture into a temporary buffer, and then apply the paint's
1055 * alpha/colorfilter/imagefilter/xfermode to that buffer as it is drawn to the canvas. 1043 * alpha/colorfilter/imagefilter/xfermode to that buffer as it is drawn to the canvas.
1056 * This is logically equivalent to 1044 * This is logically equivalent to
1057 * saveLayer(paint)/drawPicture/restore 1045 * saveLayer(paint)/drawPicture/restore
1058 */ 1046 */
1059 void drawPicture(const SkPicture*, const SkMatrix* matrix, const SkPaint* pa int); 1047 void drawPicture(const SkPicture*, const SkMatrix* matrix, const SkPaint* pa int);
1060 void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix, co nst SkPaint* paint) { 1048 void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix, co nst SkPaint* paint) {
1061 this->drawPicture(picture.get(), matrix, paint); 1049 this->drawPicture(picture.get(), matrix, paint);
1062 } 1050 }
1063 1051
1064 #ifdef SK_EXPERIMENTAL_SHADOWING
1065 /**
1066 * Draw the picture into this canvas.
1067 *
1068 * We will use the canvas's lights along with the picture information (draw depths of
1069 * objects, etc) to first create a set of shadowmaps for the light-picture pairs, and
1070 * then use that set of shadowmaps to render the scene with shadows.
1071 *
1072 * If matrix is non-null, apply that matrix to the CTM when drawing this pi cture. This is
1073 * logically equivalent to
1074 * save/concat/drawPicture/restore
1075 *
1076 * If paint is non-null, draw the picture into a temporary buffer, and then apply the paint's
1077 * alpha/colorfilter/imagefilter/xfermode to that buffer as it is drawn to the canvas.
1078 * This is logically equivalent to
1079 * saveLayer(paint)/drawPicture/restore
1080 *
1081 */
1082 void drawShadowedPicture(const SkPicture*,
1083 const SkMatrix* matrix,
1084 const SkPaint* paint);
1085 void drawShadowedPicture(const sk_sp<SkPicture>& picture,
1086 const SkMatrix* matrix,
1087 const SkPaint* paint) {
1088 this->drawShadowedPicture(picture.get(), matrix, paint);
1089 }
1090 #endif
1091
1092 enum VertexMode { 1052 enum VertexMode {
1093 kTriangles_VertexMode, 1053 kTriangles_VertexMode,
1094 kTriangleStrip_VertexMode, 1054 kTriangleStrip_VertexMode,
1095 kTriangleFan_VertexMode 1055 kTriangleFan_VertexMode
1096 }; 1056 };
1097 1057
1098 /** Draw the array of vertices, interpreted as triangles (based on mode). 1058 /** Draw the array of vertices, interpreted as triangles (based on mode).
1099 1059
1100 If both textures and vertex-colors are NULL, it strokes hairlines with 1060 If both textures and vertex-colors are NULL, it strokes hairlines with
1101 the paint's color. This behavior is a useful debugging mode to visualize 1061 the paint's color. This behavior is a useful debugging mode to visualize
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 const SkPaint* paint, 1260 const SkPaint* paint,
1301 SrcRectConstraint constraint = kStrict_SrcRectCon straint); 1261 SrcRectConstraint constraint = kStrict_SrcRectCon straint);
1302 1262
1303 // expose minimum amount of information necessary for transitional refactori ng 1263 // expose minimum amount of information necessary for transitional refactori ng
1304 /** 1264 /**
1305 * Returns CTM and clip bounds, translated from canvas coordinates to top la yer coordinates. 1265 * Returns CTM and clip bounds, translated from canvas coordinates to top la yer coordinates.
1306 */ 1266 */
1307 void temporary_internal_describeTopLayer(SkMatrix* matrix, SkIRect* clip_bou nds); 1267 void temporary_internal_describeTopLayer(SkMatrix* matrix, SkIRect* clip_bou nds);
1308 1268
1309 protected: 1269 protected:
1310 #ifdef SK_EXPERIMENTAL_SHADOWING
1311 /** Returns the current (cumulative) draw depth of the canvas. 1270 /** Returns the current (cumulative) draw depth of the canvas.
1312 */ 1271 */
1313 SkScalar getZ() const; 1272 SkScalar getZ() const;
1314 1273
1315 sk_sp<SkLights> fLights;
1316 #endif
1317
1318 /** After calling saveLayer(), there can be any number of devices that make 1274 /** After calling saveLayer(), there can be any number of devices that make
1319 up the top-most drawing area. LayerIter can be used to iterate through 1275 up the top-most drawing area. LayerIter can be used to iterate through
1320 those devices. Note that the iterator is only valid until the next API 1276 those devices. Note that the iterator is only valid until the next API
1321 call made on the canvas. Ownership of all pointers in the iterator stays 1277 call made on the canvas. Ownership of all pointers in the iterator stays
1322 with the canvas, so none of them should be modified or deleted. 1278 with the canvas, so none of them should be modified or deleted.
1323 */ 1279 */
1324 class LayerIter /*: SkNoncopyable*/ { 1280 class LayerIter /*: SkNoncopyable*/ {
1325 public: 1281 public:
1326 /** Initialize iterator with canvas, and set values for 1st device */ 1282 /** Initialize iterator with canvas, and set values for 1st device */
1327 LayerIter(SkCanvas*, bool skipEmptyClips); 1283 LayerIter(SkCanvas*, bool skipEmptyClips);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 1329
1374 virtual void willSave() {} 1330 virtual void willSave() {}
1375 // Overriders should call the corresponding INHERITED method up the inherita nce chain. 1331 // Overriders should call the corresponding INHERITED method up the inherita nce chain.
1376 virtual SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) { 1332 virtual SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) {
1377 return kFullLayer_SaveLayerStrategy; 1333 return kFullLayer_SaveLayerStrategy;
1378 } 1334 }
1379 virtual void willRestore() {} 1335 virtual void willRestore() {}
1380 virtual void didRestore() {} 1336 virtual void didRestore() {}
1381 virtual void didConcat(const SkMatrix&) {} 1337 virtual void didConcat(const SkMatrix&) {}
1382 virtual void didSetMatrix(const SkMatrix&) {} 1338 virtual void didSetMatrix(const SkMatrix&) {}
1383
1384 #ifdef SK_EXPERIMENTAL_SHADOWING
1385 virtual void didTranslateZ(SkScalar) {} 1339 virtual void didTranslateZ(SkScalar) {}
1386 #endif
1387 1340
1388 virtual void onDrawAnnotation(const SkRect&, const char key[], SkData* value ); 1341 virtual void onDrawAnnotation(const SkRect&, const char key[], SkData* value );
1389 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&); 1342 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
1390 1343
1391 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, 1344 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x,
1392 SkScalar y, const SkPaint& paint); 1345 SkScalar y, const SkPaint& paint);
1393 1346
1394 virtual void onDrawPosText(const void* text, size_t byteLength, 1347 virtual void onDrawPosText(const void* text, size_t byteLength,
1395 const SkPoint pos[], const SkPaint& paint); 1348 const SkPoint pos[], const SkPaint& paint);
1396 1349
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 1396
1444 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e dgeStyle); 1397 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e dgeStyle);
1445 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl e edgeStyle); 1398 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl e edgeStyle);
1446 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e dgeStyle); 1399 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e dgeStyle);
1447 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); 1400 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op);
1448 1401
1449 virtual void onDiscard(); 1402 virtual void onDiscard();
1450 1403
1451 virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint* ); 1404 virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint* );
1452 1405
1453 #ifdef SK_EXPERIMENTAL_SHADOWING
1454 virtual void onDrawShadowedPicture(const SkPicture*,
1455 const SkMatrix*,
1456 const SkPaint*);
1457 #endif
1458
1459 // Returns the canvas to be used by DrawIter. Default implementation 1406 // Returns the canvas to be used by DrawIter. Default implementation
1460 // returns this. Subclasses that encapsulate an indirect canvas may 1407 // returns this. Subclasses that encapsulate an indirect canvas may
1461 // need to overload this method. The impl must keep track of this, as it 1408 // need to overload this method. The impl must keep track of this, as it
1462 // is not released or deleted by the caller. 1409 // is not released or deleted by the caller.
1463 virtual SkCanvas* canvasForDrawIter(); 1410 virtual SkCanvas* canvasForDrawIter();
1464 1411
1465 // Clip rectangle bounds. Called internally by saveLayer. 1412 // Clip rectangle bounds. Called internally by saveLayer.
1466 // returns false if the entire rectangle is entirely clipped out 1413 // returns false if the entire rectangle is entirely clipped out
1467 // If non-NULL, The imageFilter parameter will be used to expand the clip 1414 // If non-NULL, The imageFilter parameter will be used to expand the clip
1468 // and offscreen bounds for any margin required by the filter DAG. 1415 // and offscreen bounds for any margin required by the filter DAG.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 1617
1671 class SkCanvasClipVisitor { 1618 class SkCanvasClipVisitor {
1672 public: 1619 public:
1673 virtual ~SkCanvasClipVisitor(); 1620 virtual ~SkCanvasClipVisitor();
1674 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; 1621 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0;
1675 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; 1622 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0;
1676 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; 1623 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0;
1677 }; 1624 };
1678 1625
1679 #endif 1626 #endif
OLDNEW
« no previous file with comments | « gyp/common_variables.gypi ('k') | include/core/SkLights.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698