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

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

Issue 221923007: Initial picture shader implementation (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Use SVD for tile scaling. 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 | « gyp/gmslides.gypi ('k') | src/core/SkPictureShader.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 8
9 #ifndef SkShader_DEFINED 9 #ifndef SkShader_DEFINED
10 #define SkShader_DEFINED 10 #define SkShader_DEFINED
11 11
12 #include "SkBitmap.h" 12 #include "SkBitmap.h"
13 #include "SkFlattenable.h" 13 #include "SkFlattenable.h"
14 #include "SkMask.h" 14 #include "SkMask.h"
15 #include "SkMatrix.h" 15 #include "SkMatrix.h"
16 #include "SkPaint.h" 16 #include "SkPaint.h"
17 17
18 class SkPath; 18 class SkPath;
19 class SkPicture;
19 class GrContext; 20 class GrContext;
20 class GrEffectRef; 21 class GrEffectRef;
21 22
22 /** \class SkShader 23 /** \class SkShader
23 * 24 *
24 * Shaders specify the source color(s) for what is being drawn. If a paint 25 * Shaders specify the source color(s) for what is being drawn. If a paint
25 * has no shader, then the paint's color is used. If the paint has a 26 * has no shader, then the paint's color is used. If the paint has a
26 * shader, then the shader's color(s) are use instead, but they are 27 * shader, then the shader's color(s) are use instead, but they are
27 * modulated by the paint's alpha. This makes it easy to create a shader 28 * modulated by the paint's alpha. This makes it easy to create a shader
28 * once (e.g. bitmap tiling or gradient) and then change its transparency 29 * once (e.g. bitmap tiling or gradient) and then change its transparency
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 * the paint. 339 * the paint.
339 * 340 *
340 * @param src The bitmap to use inside the shader 341 * @param src The bitmap to use inside the shader
341 * @param tmx The tiling mode to use when sampling the bitmap in the x-dir ection. 342 * @param tmx The tiling mode to use when sampling the bitmap in the x-dir ection.
342 * @param tmy The tiling mode to use when sampling the bitmap in the y-dir ection. 343 * @param tmy The tiling mode to use when sampling the bitmap in the y-dir ection.
343 * @return Returns a new shader object. Note: this function never retur ns null. 344 * @return Returns a new shader object. Note: this function never retur ns null.
344 */ 345 */
345 static SkShader* CreateBitmapShader(const SkBitmap& src, 346 static SkShader* CreateBitmapShader(const SkBitmap& src,
346 TileMode tmx, TileMode tmy); 347 TileMode tmx, TileMode tmy);
347 348
349 /** Call this to create a new shader that will draw with the specified pictu re.
350 *
351 * @param src The picture to use inside the shader
reed1 2014/04/07 15:30:09 // Do we ref() the argument?
f(malita) 2014/04/07 15:45:29 Done.
352 * @param tmx The tiling mode to use when sampling the bitmap in the x-dir ection.
353 * @param tmy The tiling mode to use when sampling the bitmap in the y-dir ection.
354 * @return Returns a new shader object. Note: this function never retur ns null.
355 */
356 static SkShader* CreatePictureShader(SkPicture& src, TileMode tmx, TileMode tmy);
reed1 2014/04/07 15:30:09 I know drawPicture takes a &, but I think that is
f(malita) 2014/04/07 15:45:29 Done.
357
348 SK_TO_STRING_VIRT() 358 SK_TO_STRING_VIRT()
349 SK_DEFINE_FLATTENABLE_TYPE(SkShader) 359 SK_DEFINE_FLATTENABLE_TYPE(SkShader)
350 360
351 protected: 361 protected:
352 enum MatrixClass { 362 enum MatrixClass {
353 kLinear_MatrixClass, // no perspective 363 kLinear_MatrixClass, // no perspective
354 kFixedStepInX_MatrixClass, // fast perspective, need to call fixedS tepInX() each scanline 364 kFixedStepInX_MatrixClass, // fast perspective, need to call fixedS tepInX() each scanline
355 kPerspective_MatrixClass // slow perspective, need to mappoints e ach pixel 365 kPerspective_MatrixClass // slow perspective, need to mappoints e ach pixel
356 }; 366 };
357 static MatrixClass ComputeMatrixClass(const SkMatrix&); 367 static MatrixClass ComputeMatrixClass(const SkMatrix&);
358 368
359 // These can be called by your subclass after setContext() has been called 369 // These can be called by your subclass after setContext() has been called
360 uint8_t getPaintAlpha() const { return fPaintAlpha; } 370 uint8_t getPaintAlpha() const { return fPaintAlpha; }
361 const SkMatrix& getTotalInverse() const { return fTotalInverse; } 371 const SkMatrix& getTotalInverse() const { return fTotalInverse; }
362 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve rseClass; } 372 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve rseClass; }
363 373
364 SkShader(SkReadBuffer& ); 374 SkShader(SkReadBuffer& );
365 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 375 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
366 private: 376 private:
367 SkMatrix fLocalMatrix; 377 SkMatrix fLocalMatrix;
368 SkMatrix fTotalInverse; 378 SkMatrix fTotalInverse;
369 uint8_t fPaintAlpha; 379 uint8_t fPaintAlpha;
370 uint8_t fTotalInverseClass; 380 uint8_t fTotalInverseClass;
371 SkDEBUGCODE(SkBool8 fInSetContext;) 381 SkDEBUGCODE(SkBool8 fInSetContext;)
372 382
373 typedef SkFlattenable INHERITED; 383 typedef SkFlattenable INHERITED;
374 }; 384 };
375 385
376 #endif 386 #endif
OLDNEW
« no previous file with comments | « gyp/gmslides.gypi ('k') | src/core/SkPictureShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698