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

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

Issue 207683004: Extract most of the mutable state of SkShader into a separate Context object. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: scroggo's comments 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
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 9
10 #ifndef SkComposeShader_DEFINED 10 #ifndef SkComposeShader_DEFINED
(...skipping 16 matching lines...) Expand all
27 "dst", and the result of from shader B as its "src". 27 "dst", and the result of from shader B as its "src".
28 mode->xfer32(sA_result, sB_result, ...) 28 mode->xfer32(sA_result, sB_result, ...)
29 @param shaderA The colors from this shader are seen as the "dst" by the xfermode 29 @param shaderA The colors from this shader are seen as the "dst" by the xfermode
30 @param shaderB The colors from this shader are seen as the "src" by the xfermode 30 @param shaderB The colors from this shader are seen as the "src" by the xfermode
31 @param mode The xfermode that combines the colors from the two shade rs. If mode 31 @param mode The xfermode that combines the colors from the two shade rs. If mode
32 is null, then SRC_OVER is assumed. 32 is null, then SRC_OVER is assumed.
33 */ 33 */
34 SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL); 34 SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL);
35 virtual ~SkComposeShader(); 35 virtual ~SkComposeShader();
36 36
37 virtual bool setContext(const SkBitmap&, const SkPaint&, 37 virtual bool validContext(const SkBitmap&, const SkPaint&,
38 const SkMatrix&) SK_OVERRIDE; 38 const SkMatrix&) const SK_OVERRIDE;
39 virtual void endContext() SK_OVERRIDE; 39 virtual SkShader::Context* createContext(const SkBitmap&, const SkPaint&,
40 virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE; 40 const SkMatrix&, void*) const SK_OV ERRIDE;
41 virtual size_t contextSize() const SK_OVERRIDE;
42
43 class ComposeShaderContext : public SkShader::Context {
44 public:
45 // Takes ownership of contextA and contextB, and calls their destructors .
46 ComposeShaderContext(const SkComposeShader&, const SkBitmap&,
47 const SkPaint&, const SkMatrix&,
48 SkShader::Context* contextA, SkShader::Context* con textB);
49
50 virtual ~ComposeShaderContext();
51
52 virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE ;
53 private:
54 SkShader::Context* fShaderContextA;
55 SkShader::Context* fShaderContextB;
56
57 typedef SkShader::Context INHERITED;
58 };
59
41 60
42 SK_DEVELOPER_TO_STRING() 61 SK_DEVELOPER_TO_STRING()
43 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader) 62 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader)
44 63
45 protected: 64 protected:
46 SkComposeShader(SkReadBuffer& ); 65 SkComposeShader(SkReadBuffer& );
47 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 66 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
48 67
49 private: 68 private:
50 69
51 SkShader* fShaderA; 70 SkShader* fShaderA;
52 SkShader* fShaderB; 71 SkShader* fShaderB;
53 SkXfermode* fMode; 72 SkXfermode* fMode;
54 73
74 friend class ComposeImpl;
75
55 typedef SkShader INHERITED; 76 typedef SkShader INHERITED;
56 }; 77 };
57 78
58 #endif 79 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698