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

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

Issue 1720933002: Add ContextRec param to SkShader::contextSize() (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « gm/SkLinearBitmapPipelineGM.cpp ('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 #ifndef SkShader_DEFINED 8 #ifndef SkShader_DEFINED
9 #define SkShader_DEFINED 9 #define SkShader_DEFINED
10 10
11 #include "SkBitmap.h" 11 #include "SkBitmap.h"
12 #include "SkFlattenable.h" 12 #include "SkFlattenable.h"
13 #include "SkImageInfo.h"
13 #include "SkMask.h" 14 #include "SkMask.h"
14 #include "SkMatrix.h" 15 #include "SkMatrix.h"
15 #include "SkPaint.h" 16 #include "SkPaint.h"
16 #include "../gpu/GrColor.h" 17 #include "../gpu/GrColor.h"
17 18
18 class SkColorFilter; 19 class SkColorFilter;
19 class SkPath; 20 class SkPath;
20 class SkPicture; 21 class SkPicture;
21 class SkXfermode; 22 class SkXfermode;
22 class GrContext; 23 class GrContext;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 * colors, subject to the SkPaint using the shader to apply an opaque 90 * colors, subject to the SkPaint using the shader to apply an opaque
90 * alpha value. Subclasses should override this to allow some 91 * alpha value. Subclasses should override this to allow some
91 * optimizations. 92 * optimizations.
92 */ 93 */
93 virtual bool isOpaque() const { return false; } 94 virtual bool isOpaque() const { return false; }
94 95
95 /** 96 /**
96 * ContextRec acts as a parameter bundle for creating Contexts. 97 * ContextRec acts as a parameter bundle for creating Contexts.
97 */ 98 */
98 struct ContextRec { 99 struct ContextRec {
99 ContextRec(const SkPaint& paint, const SkMatrix& matrix, const SkMatrix* localM) 100 ContextRec(const SkPaint& paint, const SkMatrix& matrix, const SkMatrix* localM,
101 SkColorType devColorType, SkColorProfileType devColorProfile)
100 : fPaint(&paint) 102 : fPaint(&paint)
101 , fMatrix(&matrix) 103 , fMatrix(&matrix)
102 , fLocalMatrix(localM) {} 104 , fLocalMatrix(localM)
105 , fDeviceColorType(devColorType)
106 , fDeviceColorProfile(devColorProfile) {}
103 107
104 const SkPaint* fPaint; // the current paint associated with the draw 108 const SkPaint* fPaint; // the current paint associated with the draw
105 const SkMatrix* fMatrix; // the current matrix in the canvas 109 const SkMatrix* fMatrix; // the current matrix in the canvas
106 const SkMatrix* fLocalMatrix; // optional local matrix 110 const SkMatrix* fLocalMatrix; // optional local matrix
111 const SkColorType fDeviceColorType;
112 const SkColorProfileType fDeviceColorProfile;
f(malita) 2016/02/22 16:09:50 I'm kinda torn on pushing explicit dst color info
f(malita) 2016/02/22 17:08:23 PS#2 implements this alternative approach, replaci
107 }; 113 };
108 114
109 class Context : public ::SkNoncopyable { 115 class Context : public ::SkNoncopyable {
110 public: 116 public:
111 Context(const SkShader& shader, const ContextRec&); 117 Context(const SkShader& shader, const ContextRec&);
112 118
113 virtual ~Context(); 119 virtual ~Context();
114 120
115 /** 121 /**
116 * Called sometimes before drawing with this shader. Return the type of 122 * Called sometimes before drawing with this shader. Return the type of
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 * Size of storage must be >= contextSize. 187 * Size of storage must be >= contextSize.
182 */ 188 */
183 Context* createContext(const ContextRec&, void* storage) const; 189 Context* createContext(const ContextRec&, void* storage) const;
184 190
185 /** 191 /**
186 * Return the size of a Context returned by createContext. 192 * Return the size of a Context returned by createContext.
187 * 193 *
188 * Override this if your subclass overrides createContext, to return the co rrect size of 194 * Override this if your subclass overrides createContext, to return the co rrect size of
189 * your subclass' context. 195 * your subclass' context.
190 */ 196 */
191 virtual size_t contextSize() const; 197 virtual size_t contextSize(const ContextRec&) const;
192 198
193 /** 199 /**
194 * Returns true if this shader is just a bitmap, and if not null, returns t he bitmap, 200 * Returns true if this shader is just a bitmap, and if not null, returns t he bitmap,
195 * localMatrix, and tilemodes. If this is not a bitmap, returns false and i gnores the 201 * localMatrix, and tilemodes. If this is not a bitmap, returns false and i gnores the
196 * out-parameters. 202 * out-parameters.
197 */ 203 */
198 bool isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) co nst { 204 bool isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) co nst {
199 return this->onIsABitmap(outTexture, outMatrix, xy); 205 return this->onIsABitmap(outTexture, outMatrix, xy);
200 } 206 }
201 207
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 SkMatrix fLocalMatrix; 432 SkMatrix fLocalMatrix;
427 433
428 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor. 434 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con structor.
429 friend class SkLocalMatrixShader; 435 friend class SkLocalMatrixShader;
430 friend class SkBitmapProcShader; // for computeTotalInverse() 436 friend class SkBitmapProcShader; // for computeTotalInverse()
431 437
432 typedef SkFlattenable INHERITED; 438 typedef SkFlattenable INHERITED;
433 }; 439 };
434 440
435 #endif 441 #endif
OLDNEW
« no previous file with comments | « gm/SkLinearBitmapPipelineGM.cpp ('k') | include/effects/SkPerlinNoiseShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698