Index: src/core/SkShader.cpp |
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp |
index 40e52a05cbf59e217a644195fa7a957c5c543719..ff6b7528dc8f9411b2961bba7b71e410fc717e27 100644 |
--- a/src/core/SkShader.cpp |
+++ b/src/core/SkShader.cpp |
@@ -15,8 +15,12 @@ |
#include "SkShader.h" |
#include "SkWriteBuffer.h" |
-SkShader::SkShader() { |
- fLocalMatrix.reset(); |
+SkShader::SkShader(const SkMatrix* localMatrix) { |
+ if (localMatrix) { |
+ fLocalMatrix = *localMatrix; |
+ } else { |
+ fLocalMatrix.reset(); |
+ } |
} |
SkShader::SkShader(SkReadBuffer& buffer) |
@@ -180,15 +184,19 @@ GrEffectRef* SkShader::asNewEffect(GrContext*, const SkPaint&) const { |
return NULL; |
} |
-SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, |
- TileMode tmx, TileMode tmy) { |
- return ::CreateBitmapShader(src, tmx, tmy, NULL); |
+SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy, |
+ const SkMatrix* localMatrix) { |
+ return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL); |
} |
SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy) { |
return SkPictureShader::Create(src, tmx, tmy); |
} |
+SkShader* SkShader::CreateLocalMatrixWrapper(SkShader* shader, const SkMatrix& localMatrix) { |
+ return SkLocalMatrixShaderWrapper::Create(shader, localMatrix); |
+} |
+ |
#ifndef SK_IGNORE_TO_STRING |
void SkShader::toString(SkString* str) const { |
if (this->hasLocalMatrix()) { |
@@ -200,16 +208,39 @@ void SkShader::toString(SkString* str) const { |
////////////////////////////////////////////////////////////////////////////// |
+SkLocalMatrixShaderWrapper::SkLocalMatrixShaderWrapper(SkShader* shader, |
+ const SkMatrix& localMatrix) |
+ : INHERITED(&localMatrix) |
+ , fShader(shader) { |
scroggo
2014/04/24 17:02:53
nit: Brace should go on the next line.
Dominik Grewe
2014/04/24 17:16:47
Done.
|
+ SkASSERT(shader); |
+ shader->ref(); |
+} |
+ |
+SkLocalMatrixShaderWrapper::SkLocalMatrixShaderWrapper(SkReadBuffer& buffer) |
+ : INHERITED(buffer) { |
scroggo
2014/04/24 17:02:53
ditto
Dominik Grewe
2014/04/24 17:16:47
Done.
|
+ fShader.reset(buffer.readShader()); |
+} |
+ |
+void SkLocalMatrixShaderWrapper::flatten(SkWriteBuffer& buffer) { |
+ this->INHERITED::flatten(buffer); |
+ buffer.writeFlattenable(fShader); |
+} |
+ |
+ |
+////////////////////////////////////////////////////////////////////////////// |
+ |
#include "SkColorShader.h" |
#include "SkUtils.h" |
-SkColorShader::SkColorShader() |
- : fColor() |
+SkColorShader::SkColorShader(const SkMatrix* localMatrix) |
+ : INHERITED(localMatrix) |
+ , fColor() |
, fInheritColor(true) { |
} |
-SkColorShader::SkColorShader(SkColor c) |
- : fColor(c) |
+SkColorShader::SkColorShader(SkColor c, const SkMatrix* localMatrix) |
+ : INHERITED(localMatrix) |
+ , fColor(c) |
, fInheritColor(false) { |
} |