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

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

Issue 261773005: Remove SkShader virtual method validContext (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: correctly call shaderA/B in composeshader Created 6 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkEmptyShader.h ('k') | include/effects/SkPerlinNoiseShader.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
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 private: 207 private:
208 SkMatrix fTotalInverse; 208 SkMatrix fTotalInverse;
209 uint8_t fPaintAlpha; 209 uint8_t fPaintAlpha;
210 uint8_t fTotalInverseClass; 210 uint8_t fTotalInverseClass;
211 211
212 typedef SkNoncopyable INHERITED; 212 typedef SkNoncopyable INHERITED;
213 }; 213 };
214 214
215 /** 215 /**
216 * Subclasses should be sure to call their INHERITED::validContext() if 216 * Create the actual object that does the shading.
217 * they override this method. 217 * Size of storage must be >= contextSize.
218 */ 218 */
219 virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL) const; 219 Context* createContext(const ContextRec&, void* storage) const;
220
221 /**
222 * Create the actual object that does the shading.
223 * Returns NULL if validContext() returns false.
224 * Size of storage must be >= contextSize.
225 * Your subclass must also override contextSize() if it overrides createCon text().
226 *
227 * Base class implementation returns NULL.
228 */
229 virtual Context* createContext(const ContextRec&, void* storage) const;
230 220
231 /** 221 /**
232 * Return the size of a Context returned by createContext. 222 * Return the size of a Context returned by createContext.
233 * 223 *
234 * Override this if your subclass overrides createContext, to return the co rrect size of 224 * Override this if your subclass overrides createContext, to return the co rrect size of
235 * your subclass' context. 225 * your subclass' context.
236 */ 226 */
237 virtual size_t contextSize() const; 227 virtual size_t contextSize() const;
238 228
239 /** 229 /**
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 * The incoming color to the effect has r=g=b=a all extracted from the SkPa int's alpha. 357 * The incoming color to the effect has r=g=b=a all extracted from the SkPa int's alpha.
368 * The output color should be the computed SkShader premul color modulated by the incoming 358 * The output color should be the computed SkShader premul color modulated by the incoming
369 * color. The GrContext may be used by the effect to create textures. The G PU device does not 359 * color. The GrContext may be used by the effect to create textures. The G PU device does not
370 * call createContext. Instead we pass the SkPaint here in case the shader needs paint info. 360 * call createContext. Instead we pass the SkPaint here in case the shader needs paint info.
371 */ 361 */
372 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) c onst; 362 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) c onst;
373 363
374 ////////////////////////////////////////////////////////////////////////// 364 //////////////////////////////////////////////////////////////////////////
375 // Factory methods for stock shaders 365 // Factory methods for stock shaders
376 366
367 /**
368 * Call this to create a new "empty" shader, that will not draw anything.
369 */
370 static SkShader* CreateEmptyShader();
371
377 /** Call this to create a new shader that will draw with the specified bitma p. 372 /** Call this to create a new shader that will draw with the specified bitma p.
378 * 373 *
379 * If the bitmap cannot be used (e.g. has no pixels, or its dimensions 374 * If the bitmap cannot be used (e.g. has no pixels, or its dimensions
380 * exceed implementation limits (currently at 64K - 1)) then SkEmptyShader 375 * exceed implementation limits (currently at 64K - 1)) then SkEmptyShader
381 * may be returned. 376 * may be returned.
382 * 377 *
383 * If the src is kA8_Config then that mask will be colorized using the colo r on 378 * If the src is kA8_Config then that mask will be colorized using the colo r on
384 * the paint. 379 * the paint.
385 * 380 *
386 * @param src The bitmap to use inside the shader 381 * @param src The bitmap to use inside the shader
(...skipping 15 matching lines...) Expand all
402 * @param tmy The tiling mode to use when sampling the bitmap in the y-dir ection. 397 * @param tmy The tiling mode to use when sampling the bitmap in the y-dir ection.
403 * @return Returns a new shader object. Note: this function never retur ns null. 398 * @return Returns a new shader object. Note: this function never retur ns null.
404 */ 399 */
405 static SkShader* CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy, 400 static SkShader* CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy,
406 const SkMatrix* localMatrix = NULL); 401 const SkMatrix* localMatrix = NULL);
407 402
408 SK_TO_STRING_VIRT() 403 SK_TO_STRING_VIRT()
409 SK_DEFINE_FLATTENABLE_TYPE(SkShader) 404 SK_DEFINE_FLATTENABLE_TYPE(SkShader)
410 405
411 protected: 406 protected:
412
413 SkShader(SkReadBuffer& ); 407 SkShader(SkReadBuffer& );
414 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 408 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
415 409
410 bool computeTotalInverse(const ContextRec&, SkMatrix* totalInverse) const;
411
412 /**
413 * Your subclass must also override contextSize() if it overrides onCreateC ontext().
414 * Base class impl returns NULL.
415 */
416 virtual Context* onCreateContext(const ContextRec&, void* storage) const;
417
416 private: 418 private:
417 SkMatrix fLocalMatrix; 419 SkMatrix fLocalMatrix;
418
419 bool computeTotalInverse(const SkMatrix& matrix, SkMatrix* totalInverse) con st;
420 420
421 typedef SkFlattenable INHERITED; 421 typedef SkFlattenable INHERITED;
422 }; 422 };
423 423
424 #endif 424 #endif
OLDNEW
« no previous file with comments | « include/core/SkEmptyShader.h ('k') | include/effects/SkPerlinNoiseShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698