2014-04-08 15:19:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SkPictureShader.h"
|
|
|
|
|
|
|
|
#include "SkBitmap.h"
|
|
|
|
#include "SkBitmapProcShader.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkMatrixUtils.h"
|
|
|
|
#include "SkPicture.h"
|
|
|
|
#include "SkReadBuffer.h"
|
2014-10-22 14:39:08 +00:00
|
|
|
#include "SkResourceCache.h"
|
2014-04-08 15:19:34 +00:00
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
#include "GrContext.h"
|
2015-05-29 15:02:10 +00:00
|
|
|
#include "GrCaps.h"
|
2014-04-08 15:19:34 +00:00
|
|
|
#endif
|
|
|
|
|
2014-10-22 18:20:40 +00:00
|
|
|
namespace {
|
|
|
|
static unsigned gBitmapSkaderKeyNamespaceLabel;
|
|
|
|
|
2014-10-22 14:39:08 +00:00
|
|
|
struct BitmapShaderKey : public SkResourceCache::Key {
|
|
|
|
public:
|
|
|
|
BitmapShaderKey(uint32_t pictureID,
|
|
|
|
const SkRect& tile,
|
|
|
|
SkShader::TileMode tmx,
|
|
|
|
SkShader::TileMode tmy,
|
|
|
|
const SkSize& scale,
|
|
|
|
const SkMatrix& localMatrix)
|
|
|
|
: fPictureID(pictureID)
|
|
|
|
, fTile(tile)
|
|
|
|
, fTmx(tmx)
|
|
|
|
, fTmy(tmy)
|
2014-12-10 21:01:43 +00:00
|
|
|
, fScale(scale) {
|
|
|
|
|
|
|
|
for (int i = 0; i < 9; ++i) {
|
|
|
|
fLocalMatrixStorage[i] = localMatrix[i];
|
|
|
|
}
|
2014-10-22 14:39:08 +00:00
|
|
|
|
|
|
|
static const size_t keySize = sizeof(fPictureID) +
|
|
|
|
sizeof(fTile) +
|
|
|
|
sizeof(fTmx) + sizeof(fTmy) +
|
|
|
|
sizeof(fScale) +
|
2014-12-10 21:01:43 +00:00
|
|
|
sizeof(fLocalMatrixStorage);
|
2014-10-22 14:39:08 +00:00
|
|
|
// This better be packed.
|
|
|
|
SkASSERT(sizeof(uint32_t) * (&fEndOfStruct - &fPictureID) == keySize);
|
2015-02-24 21:54:23 +00:00
|
|
|
this->init(&gBitmapSkaderKeyNamespaceLabel, 0, keySize);
|
2014-10-22 14:39:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint32_t fPictureID;
|
|
|
|
SkRect fTile;
|
|
|
|
SkShader::TileMode fTmx, fTmy;
|
|
|
|
SkSize fScale;
|
2014-12-10 21:01:43 +00:00
|
|
|
SkScalar fLocalMatrixStorage[9];
|
2014-10-22 14:39:08 +00:00
|
|
|
|
|
|
|
SkDEBUGCODE(uint32_t fEndOfStruct;)
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BitmapShaderRec : public SkResourceCache::Rec {
|
|
|
|
BitmapShaderRec(const BitmapShaderKey& key, SkShader* tileShader, size_t bitmapBytes)
|
|
|
|
: fKey(key)
|
|
|
|
, fShader(SkRef(tileShader))
|
|
|
|
, fBitmapBytes(bitmapBytes) {}
|
|
|
|
|
|
|
|
BitmapShaderKey fKey;
|
|
|
|
SkAutoTUnref<SkShader> fShader;
|
|
|
|
size_t fBitmapBytes;
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
const Key& getKey() const override { return fKey; }
|
|
|
|
size_t bytesUsed() const override {
|
2014-10-22 14:39:08 +00:00
|
|
|
return sizeof(fKey) + sizeof(SkShader) + fBitmapBytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextShader) {
|
|
|
|
const BitmapShaderRec& rec = static_cast<const BitmapShaderRec&>(baseRec);
|
|
|
|
SkAutoTUnref<SkShader>* result = reinterpret_cast<SkAutoTUnref<SkShader>*>(contextShader);
|
|
|
|
|
|
|
|
result->reset(SkRef(rec.fShader.get()));
|
2014-12-10 20:17:58 +00:00
|
|
|
|
2015-02-26 01:47:06 +00:00
|
|
|
SkBitmap tile;
|
|
|
|
rec.fShader.get()->asABitmap(&tile, NULL, NULL);
|
|
|
|
// FIXME: this doesn't protect the pixels from being discarded as soon as we unlock.
|
|
|
|
// Should be handled via a pixel ref generator instead
|
|
|
|
// (https://code.google.com/p/skia/issues/detail?id=3220).
|
|
|
|
SkAutoLockPixels alp(tile, true);
|
|
|
|
return tile.getPixels() != NULL;
|
2014-10-22 14:39:08 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-02-26 01:47:06 +00:00
|
|
|
static bool cache_try_alloc_pixels(SkBitmap* bitmap) {
|
|
|
|
SkBitmap::Allocator* allocator = SkResourceCache::GetAllocator();
|
|
|
|
|
|
|
|
return NULL != allocator
|
|
|
|
? allocator->allocPixelRef(bitmap, NULL)
|
|
|
|
: bitmap->tryAllocPixels();
|
|
|
|
}
|
|
|
|
|
2014-10-22 18:20:40 +00:00
|
|
|
} // namespace
|
|
|
|
|
2014-07-14 14:53:26 +00:00
|
|
|
SkPictureShader::SkPictureShader(const SkPicture* picture, TileMode tmx, TileMode tmy,
|
2014-08-06 20:07:15 +00:00
|
|
|
const SkMatrix* localMatrix, const SkRect* tile)
|
2014-05-02 21:23:52 +00:00
|
|
|
: INHERITED(localMatrix)
|
|
|
|
, fPicture(SkRef(picture))
|
2014-09-05 20:34:00 +00:00
|
|
|
, fTile(tile ? *tile : picture->cullRect())
|
2014-04-08 15:19:34 +00:00
|
|
|
, fTmx(tmx)
|
2014-08-06 20:07:15 +00:00
|
|
|
, fTmy(tmy) {
|
|
|
|
}
|
2014-04-08 15:19:34 +00:00
|
|
|
|
2015-02-26 01:47:06 +00:00
|
|
|
SkPictureShader::~SkPictureShader() {
|
|
|
|
fPicture->unref();
|
|
|
|
}
|
|
|
|
|
2015-05-18 20:44:35 +00:00
|
|
|
SkShader* SkPictureShader::Create(const SkPicture* picture, TileMode tmx, TileMode tmy,
|
2014-08-06 20:07:15 +00:00
|
|
|
const SkMatrix* localMatrix, const SkRect* tile) {
|
2014-09-05 20:34:00 +00:00
|
|
|
if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty())) {
|
2015-05-18 20:44:35 +00:00
|
|
|
return SkShader::CreateEmptyShader();
|
2014-04-21 19:33:12 +00:00
|
|
|
}
|
2014-08-06 20:07:15 +00:00
|
|
|
return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy, localMatrix, tile));
|
2014-04-08 15:19:34 +00:00
|
|
|
}
|
|
|
|
|
2014-08-21 14:59:51 +00:00
|
|
|
SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) {
|
|
|
|
SkMatrix lm;
|
|
|
|
buffer.readMatrix(&lm);
|
|
|
|
TileMode mx = (TileMode)buffer.read32();
|
|
|
|
TileMode my = (TileMode)buffer.read32();
|
|
|
|
SkRect tile;
|
|
|
|
buffer.readRect(&tile);
|
2015-05-20 19:05:15 +00:00
|
|
|
|
|
|
|
SkAutoTUnref<SkPicture> picture;
|
2015-06-16 16:28:37 +00:00
|
|
|
|
|
|
|
if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnabled()) {
|
2015-05-20 19:05:15 +00:00
|
|
|
if (buffer.isVersionLT(SkReadBuffer::kPictureShaderHasPictureBool_Version)) {
|
|
|
|
// Older code blindly serialized pictures. We don't trust them.
|
|
|
|
buffer.validate(false);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
// Newer code won't serialize pictures in disallow-cross-process-picture mode.
|
|
|
|
// Assert that they didn't serialize anything except a false here.
|
|
|
|
buffer.validate(!buffer.readBool());
|
2015-06-16 16:28:37 +00:00
|
|
|
} else {
|
2015-05-20 19:05:15 +00:00
|
|
|
// Old code always serialized the picture. New code writes a 'true' first if it did.
|
|
|
|
if (buffer.isVersionLT(SkReadBuffer::kPictureShaderHasPictureBool_Version) ||
|
|
|
|
buffer.readBool()) {
|
|
|
|
picture.reset(SkPicture::CreateFromBuffer(buffer));
|
|
|
|
}
|
|
|
|
}
|
2014-08-21 14:59:51 +00:00
|
|
|
return SkPictureShader::Create(picture, mx, my, &lm, &tile);
|
|
|
|
}
|
2014-04-08 15:19:34 +00:00
|
|
|
|
2014-08-21 14:59:51 +00:00
|
|
|
void SkPictureShader::flatten(SkWriteBuffer& buffer) const {
|
|
|
|
buffer.writeMatrix(this->getLocalMatrix());
|
2014-04-08 15:19:34 +00:00
|
|
|
buffer.write32(fTmx);
|
|
|
|
buffer.write32(fTmy);
|
2014-08-06 20:07:15 +00:00
|
|
|
buffer.writeRect(fTile);
|
2015-05-20 19:05:15 +00:00
|
|
|
|
|
|
|
// The deserialization code won't trust that our serialized picture is safe to deserialize.
|
|
|
|
// So write a 'false' telling it that we're not serializing a picture.
|
2015-06-16 16:28:37 +00:00
|
|
|
if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnabled()) {
|
2015-05-20 19:05:15 +00:00
|
|
|
buffer.writeBool(false);
|
2015-06-16 16:28:37 +00:00
|
|
|
} else {
|
2015-05-20 19:05:15 +00:00
|
|
|
buffer.writeBool(true);
|
|
|
|
fPicture->flatten(buffer);
|
|
|
|
}
|
2014-04-08 15:19:34 +00:00
|
|
|
}
|
|
|
|
|
2015-05-04 05:36:30 +00:00
|
|
|
SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatrix* localM,
|
|
|
|
const int maxTextureSize) const {
|
2014-08-29 15:03:56 +00:00
|
|
|
SkASSERT(fPicture && !fPicture->cullRect().isEmpty());
|
2014-04-08 15:19:34 +00:00
|
|
|
|
|
|
|
SkMatrix m;
|
2014-05-12 20:42:21 +00:00
|
|
|
m.setConcat(matrix, this->getLocalMatrix());
|
2014-05-06 17:16:03 +00:00
|
|
|
if (localM) {
|
|
|
|
m.preConcat(*localM);
|
|
|
|
}
|
2014-04-08 15:19:34 +00:00
|
|
|
|
|
|
|
// Use a rotation-invariant scale
|
|
|
|
SkPoint scale;
|
2015-03-19 23:10:54 +00:00
|
|
|
//
|
|
|
|
// TODO: replace this with decomposeScale() -- but beware LayoutTest rebaselines!
|
|
|
|
//
|
2014-04-08 15:19:34 +00:00
|
|
|
if (!SkDecomposeUpper2x2(m, NULL, &scale, NULL)) {
|
|
|
|
// Decomposition failed, use an approximation.
|
|
|
|
scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m.getSkewX()),
|
|
|
|
SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m.getSkewY()));
|
|
|
|
}
|
2015-01-15 18:45:56 +00:00
|
|
|
SkSize scaledSize = SkSize::Make(SkScalarAbs(scale.x() * fTile.width()),
|
|
|
|
SkScalarAbs(scale.y() * fTile.height()));
|
2014-04-08 15:19:34 +00:00
|
|
|
|
2015-03-13 13:50:44 +00:00
|
|
|
// Clamp the tile size to about 4M pixels
|
|
|
|
static const SkScalar kMaxTileArea = 2048 * 2048;
|
2014-08-07 15:39:24 +00:00
|
|
|
SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height());
|
|
|
|
if (tileArea > kMaxTileArea) {
|
2015-05-12 17:37:34 +00:00
|
|
|
SkScalar clampScale = SkScalarSqrt(kMaxTileArea / tileArea);
|
2014-08-07 15:39:24 +00:00
|
|
|
scaledSize.set(SkScalarMul(scaledSize.width(), clampScale),
|
|
|
|
SkScalarMul(scaledSize.height(), clampScale));
|
|
|
|
}
|
2015-05-04 05:36:30 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
// Scale down the tile size if larger than maxTextureSize for GPU Path or it should fail on create texture
|
|
|
|
if (maxTextureSize) {
|
|
|
|
if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxTextureSize) {
|
2015-05-12 17:37:34 +00:00
|
|
|
SkScalar downScale = maxTextureSize / SkMax32(scaledSize.width(), scaledSize.height());
|
2015-05-11 01:33:29 +00:00
|
|
|
scaledSize.set(SkScalarFloorToScalar(SkScalarMul(scaledSize.width(), downScale)),
|
|
|
|
SkScalarFloorToScalar(SkScalarMul(scaledSize.height(), downScale)));
|
2015-05-04 05:36:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2014-08-07 15:39:24 +00:00
|
|
|
|
2014-04-08 15:19:34 +00:00
|
|
|
SkISize tileSize = scaledSize.toRound();
|
|
|
|
if (tileSize.isEmpty()) {
|
2015-05-18 20:44:35 +00:00
|
|
|
return SkShader::CreateEmptyShader();
|
2014-04-08 15:19:34 +00:00
|
|
|
}
|
|
|
|
|
2014-08-07 15:39:24 +00:00
|
|
|
// The actual scale, compensating for rounding & clamping.
|
2014-08-06 20:07:15 +00:00
|
|
|
SkSize tileScale = SkSize::Make(SkIntToScalar(tileSize.width()) / fTile.width(),
|
|
|
|
SkIntToScalar(tileSize.height()) / fTile.height());
|
2014-04-08 15:19:34 +00:00
|
|
|
|
2014-10-22 14:39:08 +00:00
|
|
|
SkAutoTUnref<SkShader> tileShader;
|
|
|
|
BitmapShaderKey key(fPicture->uniqueID(),
|
|
|
|
fTile,
|
|
|
|
fTmx,
|
|
|
|
fTmy,
|
|
|
|
tileScale,
|
|
|
|
this->getLocalMatrix());
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
|
2014-10-22 18:20:40 +00:00
|
|
|
if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) {
|
2014-04-08 15:19:34 +00:00
|
|
|
SkBitmap bm;
|
2015-02-26 01:47:06 +00:00
|
|
|
bm.setInfo(SkImageInfo::MakeN32Premul(tileSize));
|
|
|
|
if (!cache_try_alloc_pixels(&bm)) {
|
2015-05-18 20:44:35 +00:00
|
|
|
return SkShader::CreateEmptyShader();
|
2014-04-08 15:19:34 +00:00
|
|
|
}
|
2015-02-26 01:47:06 +00:00
|
|
|
bm.eraseColor(SK_ColorTRANSPARENT);
|
|
|
|
|
|
|
|
// Always disable LCD text, since we can't assume our image will be opaque.
|
|
|
|
SkCanvas canvas(bm, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
|
|
|
|
|
|
|
|
canvas.scale(tileScale.width(), tileScale.height());
|
|
|
|
canvas.translate(-fTile.x(), -fTile.y());
|
|
|
|
canvas.drawPicture(fPicture);
|
2014-04-08 15:19:34 +00:00
|
|
|
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
SkMatrix shaderMatrix = this->getLocalMatrix();
|
|
|
|
shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height());
|
2014-10-22 14:39:08 +00:00
|
|
|
tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix));
|
|
|
|
|
2014-10-22 18:20:40 +00:00
|
|
|
SkResourceCache::Add(SkNEW_ARGS(BitmapShaderRec, (key, tileShader.get(), bm.getSize())));
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
}
|
Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
Reason for revert:
This is blocking the DEPS roll into Chromium. Failures can be seen here:
http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
Original issue's description:
> Extract most of the mutable state of SkShader into a separate Context object.
>
> SkShader currently stores some state during draw calls via setContext(...).
> Move that mutable state into a separate SkShader::Context class that is
> constructed on demand for the duration of the draw.
>
> Calls to setContext() are replaced with createContext() which returns a context
> corresponding to the shader object or NULL if the parameters to createContext
> are invalid.
>
> TEST=out/Debug/dm
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14216
>
> Committed: http://code.google.com/p/skia/source/detail?r=14323
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/249643002
git-svn-id: http://skia.googlecode.com/svn/trunk@14326 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 16:16:55 +00:00
|
|
|
|
2014-10-22 14:39:08 +00:00
|
|
|
return tileShader.detach();
|
Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
Reason for revert:
Causing memory leaks in Chromium.
Original issue's description:
> Extract most of the mutable state of SkShader into a separate Context object.
>
> SkShader currently stores some state during draw calls via setContext(...).
> Move that mutable state into a separate SkShader::Context class that is
> constructed on demand for the duration of the draw.
>
> Calls to setContext() are replaced with createContext() which returns a context
> corresponding to the shader object or NULL if the parameters to createContext
> are invalid.
>
> TEST=out/Debug/dm
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14216
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, dominikg@chromium.org
TBR=dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bungeman@google.com
Review URL: https://codereview.chromium.org/241283003
git-svn-id: http://skia.googlecode.com/svn/trunk@14247 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-17 21:09:49 +00:00
|
|
|
}
|
2014-04-08 15:19:34 +00:00
|
|
|
|
2014-05-05 18:39:18 +00:00
|
|
|
size_t SkPictureShader::contextSize() const {
|
|
|
|
return sizeof(PictureShaderContext);
|
|
|
|
}
|
2014-04-17 21:02:29 +00:00
|
|
|
|
2014-05-05 18:39:18 +00:00
|
|
|
SkShader::Context* SkPictureShader::onCreateContext(const ContextRec& rec, void* storage) const {
|
2014-05-06 17:16:03 +00:00
|
|
|
SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(*rec.fMatrix, rec.fLocalMatrix));
|
2014-05-05 18:39:18 +00:00
|
|
|
if (NULL == bitmapShader.get()) {
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
return NULL;
|
2014-04-08 15:19:34 +00:00
|
|
|
}
|
2014-05-06 13:43:17 +00:00
|
|
|
return PictureShaderContext::Create(storage, *this, rec, bitmapShader);
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
}
|
|
|
|
|
2014-05-05 18:39:18 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
|
2014-05-05 18:39:18 +00:00
|
|
|
SkShader::Context* SkPictureShader::PictureShaderContext::Create(void* storage,
|
|
|
|
const SkPictureShader& shader, const ContextRec& rec, SkShader* bitmapShader) {
|
|
|
|
PictureShaderContext* ctx = SkNEW_PLACEMENT_ARGS(storage, PictureShaderContext,
|
|
|
|
(shader, rec, bitmapShader));
|
|
|
|
if (NULL == ctx->fBitmapShaderContext) {
|
|
|
|
ctx->~PictureShaderContext();
|
|
|
|
ctx = NULL;
|
2014-04-08 15:19:34 +00:00
|
|
|
}
|
2014-05-05 18:39:18 +00:00
|
|
|
return ctx;
|
2014-04-08 15:19:34 +00:00
|
|
|
}
|
|
|
|
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
SkPictureShader::PictureShaderContext::PictureShaderContext(
|
2014-05-01 19:31:31 +00:00
|
|
|
const SkPictureShader& shader, const ContextRec& rec, SkShader* bitmapShader)
|
|
|
|
: INHERITED(shader, rec)
|
2014-05-05 18:39:18 +00:00
|
|
|
, fBitmapShader(SkRef(bitmapShader))
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
{
|
2014-05-05 18:39:18 +00:00
|
|
|
fBitmapShaderContextStorage = sk_malloc_throw(bitmapShader->contextSize());
|
|
|
|
fBitmapShaderContext = bitmapShader->createContext(rec, fBitmapShaderContextStorage);
|
|
|
|
//if fBitmapShaderContext is null, we are invalid
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
}
|
2014-04-16 10:16:39 +00:00
|
|
|
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
SkPictureShader::PictureShaderContext::~PictureShaderContext() {
|
2014-05-05 18:39:18 +00:00
|
|
|
if (fBitmapShaderContext) {
|
|
|
|
fBitmapShaderContext->~Context();
|
|
|
|
}
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
sk_free(fBitmapShaderContextStorage);
|
2014-04-16 10:16:39 +00:00
|
|
|
}
|
|
|
|
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
uint32_t SkPictureShader::PictureShaderContext::getFlags() const {
|
2014-05-05 18:39:18 +00:00
|
|
|
SkASSERT(fBitmapShaderContext);
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
return fBitmapShaderContext->getFlags();
|
2014-04-16 10:16:39 +00:00
|
|
|
}
|
|
|
|
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
SkShader::Context::ShadeProc SkPictureShader::PictureShaderContext::asAShadeProc(void** ctx) {
|
2014-05-05 18:39:18 +00:00
|
|
|
SkASSERT(fBitmapShaderContext);
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
return fBitmapShaderContext->asAShadeProc(ctx);
|
2014-04-08 15:19:34 +00:00
|
|
|
}
|
|
|
|
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
void SkPictureShader::PictureShaderContext::shadeSpan(int x, int y, SkPMColor dstC[], int count) {
|
|
|
|
SkASSERT(fBitmapShaderContext);
|
|
|
|
fBitmapShaderContext->shadeSpan(x, y, dstC, count);
|
2014-04-08 15:19:34 +00:00
|
|
|
}
|
|
|
|
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
void SkPictureShader::PictureShaderContext::shadeSpan16(int x, int y, uint16_t dstC[], int count) {
|
|
|
|
SkASSERT(fBitmapShaderContext);
|
|
|
|
fBitmapShaderContext->shadeSpan16(x, y, dstC, count);
|
2014-04-08 15:19:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef SK_IGNORE_TO_STRING
|
|
|
|
void SkPictureShader::toString(SkString* str) const {
|
|
|
|
static const char* gTileModeName[SkShader::kTileModeCount] = {
|
|
|
|
"clamp", "repeat", "mirror"
|
|
|
|
};
|
|
|
|
|
2014-08-29 15:03:56 +00:00
|
|
|
str->appendf("PictureShader: [%f:%f:%f:%f] ",
|
2015-02-26 01:47:06 +00:00
|
|
|
fPicture ? fPicture->cullRect().fLeft : 0,
|
|
|
|
fPicture ? fPicture->cullRect().fTop : 0,
|
|
|
|
fPicture ? fPicture->cullRect().fRight : 0,
|
|
|
|
fPicture ? fPicture->cullRect().fBottom : 0);
|
2014-04-08 15:19:34 +00:00
|
|
|
|
|
|
|
str->appendf("(%s, %s)", gTileModeName[fTmx], gTileModeName[fTmy]);
|
|
|
|
|
|
|
|
this->INHERITED::toString(str);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
2014-09-23 16:50:21 +00:00
|
|
|
bool SkPictureShader::asFragmentProcessor(GrContext* context, const SkPaint& paint,
|
2014-12-17 23:50:11 +00:00
|
|
|
const SkMatrix& viewM, const SkMatrix* localMatrix,
|
|
|
|
GrColor* paintColor,
|
2014-09-23 16:50:21 +00:00
|
|
|
GrFragmentProcessor** fp) const {
|
2015-05-04 05:36:30 +00:00
|
|
|
int maxTextureSize = 0;
|
|
|
|
if (context) {
|
2015-05-29 15:02:10 +00:00
|
|
|
maxTextureSize = context->caps()->maxTextureSize();
|
2015-05-04 05:36:30 +00:00
|
|
|
}
|
|
|
|
SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix, maxTextureSize));
|
Revert of Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/249643002/)
Reason for revert:
Chromium side change landed along side DEPS roll that includes r14323.
Original issue's description:
> Revert of Extract most of the mutable state of SkShader into a separate Context object. (https://codereview.chromium.org/207683004/)
>
> Reason for revert:
> This is blocking the DEPS roll into Chromium. Failures can be seen here:
>
> http://build.chromium.org/p/tryserver.chromium/builders/android_dbg/builds/174333
>
> Original issue's description:
> > Extract most of the mutable state of SkShader into a separate Context object.
> >
> > SkShader currently stores some state during draw calls via setContext(...).
> > Move that mutable state into a separate SkShader::Context class that is
> > constructed on demand for the duration of the draw.
> >
> > Calls to setContext() are replaced with createContext() which returns a context
> > corresponding to the shader object or NULL if the parameters to createContext
> > are invalid.
> >
> > TEST=out/Debug/dm
> > BUG=skia:1976
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14216
> >
> > Committed: http://code.google.com/p/skia/source/detail?r=14323
>
> TBR=scroggo@google.com,skyostil@chromium.org,tomhudson@chromium.org,senorblanco@chromium.org,reed@google.com,bungeman@google.com,dominikg@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:1976
>
> Committed: http://code.google.com/p/skia/source/detail?r=14326
R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com, dominikg@chromium.org
TBR=bungeman@google.com, dominikg@chromium.org, reed@google.com, scroggo@google.com, senorblanco@chromium.org, skyostil@chromium.org, tomhudson@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:1976
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/246403013
git-svn-id: http://skia.googlecode.com/svn/trunk@14328 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-23 19:10:51 +00:00
|
|
|
if (!bitmapShader) {
|
2014-06-10 21:38:28 +00:00
|
|
|
return false;
|
2014-04-08 15:19:34 +00:00
|
|
|
}
|
2014-12-17 23:50:11 +00:00
|
|
|
return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintColor, fp);
|
2014-06-10 21:38:28 +00:00
|
|
|
}
|
|
|
|
#else
|
2014-12-17 23:50:11 +00:00
|
|
|
bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&,
|
|
|
|
const SkMatrix*, GrColor*,
|
2014-09-23 16:50:21 +00:00
|
|
|
GrFragmentProcessor**) const {
|
2014-06-10 21:38:28 +00:00
|
|
|
SkDEBUGFAIL("Should not call in GPU-less build");
|
|
|
|
return false;
|
2014-04-08 15:19:34 +00:00
|
|
|
}
|
|
|
|
#endif
|