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

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/SkGpuDevice_drawTexture.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGpuDevice.cpp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 36e0342f78b2a522e1c1c47af8e1772f3a5b7b1f..76a3eccaa4d59f01540c21425a6f5bd952a5fa39 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -246,6 +246,7 @@ SkGpuDevice::~SkGpuDevice() {
delete fDrawProcs;
}
+ SkASSERT(!fRenderTarget->fromRawPixels2());
fRenderTarget->unref();
fContext->unref();
}
@@ -281,7 +282,8 @@ bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz
if (kUnpremul_SkAlphaType == info.alphaType()) {
flags = GrContext::kUnpremul_PixelOpsFlag;
}
- fRenderTarget->writePixels(x, y, info.width(), info.height(), config, pixels, rowBytes, flags);
+
+ fRenderTarget->writePixels(fDrawContext, x, y, info.width(), info.height(), config, pixels, rowBytes, flags);
// need to bump our genID for compatibility with clients that "know" we have a bitmap
fLegacyBitmap.notifyPixelsChanged();
@@ -360,6 +362,9 @@ void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) {
if (fRenderTarget->wasDestroyed()) {
return;
}
+ SkASSERT(fRenderTarget->width() == newRT->width());
+ SkASSERT(fRenderTarget->height() == newRT->height());
+
this->context()->copySurface(newRT, fRenderTarget);
}
@@ -386,7 +391,7 @@ void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext);
GrPaint grPaint;
- if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRenderTarget)) {
return;
}
@@ -435,7 +440,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mode) {
GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style);
GrPaint grPaint;
- if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRenderTarget)) {
return;
}
SkPath path;
@@ -455,7 +460,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
}
GrPaint grPaint;
- if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRenderTarget)) {
return;
}
@@ -517,7 +522,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect,
}
GrPaint grPaint;
- if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRenderTarget)) {
return;
}
@@ -533,7 +538,7 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
CHECK_SHOULD_DRAW(draw);
GrPaint grPaint;
- if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRenderTarget)) {
return;
}
@@ -603,7 +608,7 @@ void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
CHECK_SHOULD_DRAW(draw);
GrPaint grPaint;
- if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRenderTarget)) {
return;
}
@@ -655,7 +660,7 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval,
}
GrPaint grPaint;
- if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRenderTarget)) {
return;
}
@@ -1006,9 +1011,12 @@ static void draw_aa_bitmap(GrDrawContext* drawContext, GrContext* context,
// Create and insert texture effect
SkAutoTUnref<const GrFragmentProcessor> fp;
if (doBicubic) {
- fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tm));
+ fp.reset(GrBicubicEffect::Create(texture,
+ SkMatrix::I(),
+ tm, renderTarget));
} else {
- fp.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), params));
+ fp.reset(GrSimpleTextureEffect::Create(texture,
+ SkMatrix::I(), params, kLocal_GrCoordSet, renderTarget));
}
if (kAlpha_8_SkColorType == bitmapPtr->colorType()) {
@@ -1017,7 +1025,7 @@ static void draw_aa_bitmap(GrDrawContext* drawContext, GrContext* context,
fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
}
- if (!SkPaintToGrPaintReplaceShader(context, paint, fp, &grPaint)) {
+ if (!SkPaintToGrPaintReplaceShader(context, paint, fp, &grPaint, renderTarget)) {
return;
}
@@ -1362,20 +1370,24 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
}
textureDomain.setLTRB(left, top, right, bottom);
if (bicubic) {
- fp.reset(GrBicubicEffect::Create(texture, texMatrix, textureDomain));
+
+ fp.reset(GrBicubicEffect::Create(texture,
+ SkMatrix::I(), textureDomain, fRenderTarget));
} else {
fp.reset(GrTextureDomainEffect::Create(texture,
texMatrix,
textureDomain,
GrTextureDomain::kClamp_Mode,
- params.filterMode()));
+ params.filterMode(), kLocal_GrCoordSet, fRenderTarget));
}
} else if (bicubic) {
SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode());
SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTileModeY() };
- fp.reset(GrBicubicEffect::Create(texture, texMatrix, tileModes));
+ fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(),
+ tileModes, fRenderTarget));
} else {
- fp.reset(GrSimpleTextureEffect::Create(texture, texMatrix, params));
+ fp.reset(GrSimpleTextureEffect::Create(texture,
+ SkMatrix::I(), params, kLocal_GrCoordSet, fRenderTarget));
}
SkAutoTUnref<const GrFragmentProcessor> shaderFP;
@@ -1385,7 +1397,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
shaderFP.reset(shader->asFragmentProcessor(this->context(),
viewMatrix,
nullptr,
- paint.getFilterQuality()));
+ paint.getFilterQuality(), fRenderTarget));
if (!shaderFP) {
return;
}
@@ -1398,7 +1410,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
}
- if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) {
+ if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint, fRenderTarget)) {
return;
}
@@ -1418,9 +1430,9 @@ bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture,
SkBitmap* result, SkIPoint* offset) {
SkASSERT(filter);
- SkImageFilter::DeviceProxy proxy(this);
-
if (filter->canFilterImageGPU()) {
+ SkImageFilter::DeviceProxy proxy(this);
+
return filter->filterImageGPU(&proxy, wrap_texture(texture, width, height),
ctx, result, offset);
} else {
@@ -1479,13 +1491,14 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
GrPaint grPaint;
SkAutoTUnref<const GrFragmentProcessor> fp(
- GrSimpleTextureEffect::Create(texture, SkMatrix::I()));
+ GrSimpleTextureEffect::Create(texture, SkMatrix::I(),
+ kLocal_GrCoordSet, fRenderTarget));
if (alphaOnly) {
fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
} else {
fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
}
- if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) {
+ if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint, fRenderTarget)) {
return;
}
@@ -1569,9 +1582,9 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
// drawDevice is defined to be in device coords.
CHECK_SHOULD_DRAW(draw);
- GrRenderTarget* devRT = dev->accessRenderTarget();
- GrTexture* devTex;
- if (nullptr == (devTex = devRT->asTexture())) {
+ GrRenderTarget* srcDevRT = dev->accessRenderTarget();
+ GrTexture* srcDevTex;
+ if (nullptr == (srcDevTex = srcDevRT->asTexture())) {
return;
}
@@ -1587,14 +1600,15 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
SkIPoint offset = SkIPoint::Make(0, 0);
SkMatrix matrix(*draw.fMatrix);
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
- SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height());
+ SkIRect clipBounds = SkIRect::MakeWH(srcDevTex->width(), srcDevTex->height());
// This cache is transient, and is freed (along with all its contained
// textures) when it goes out of scope.
SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache());
SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kApprox_SizeConstraint);
- if (this->filterTexture(fContext, devTex, device->width(), device->height(),
+ if (this->filterTexture(fContext, srcDevTex, device->width(), device->height(),
filter, ctx, &filteredBitmap, &offset)) {
- devTex = filteredBitmap.getTexture();
+ srcDevTex = filteredBitmap.getTexture();
+ srcDevRT = srcDevTex->asRenderTarget();
w = filteredBitmap.width();
h = filteredBitmap.height();
x += offset.fX;
@@ -1606,15 +1620,16 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
GrPaint grPaint;
SkAutoTUnref<const GrFragmentProcessor> fp(
- GrSimpleTextureEffect::Create(devTex, SkMatrix::I()));
- if (GrPixelConfigIsAlphaOnly(devTex->config())) {
+ GrSimpleTextureEffect::Create(srcDevTex, SkMatrix::I(),
+ kLocal_GrCoordSet, fRenderTarget));
+ if (GrPixelConfigIsAlphaOnly(srcDevTex->config())) {
// Can this happen?
fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
- } else {
+ } else {
fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
}
- if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) {
+ if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint, fRenderTarget)) {
return;
}
@@ -1625,12 +1640,17 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
// The device being drawn may not fill up its texture (e.g. saveLayer uses approximate
// scratch texture).
- SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(),
- SK_Scalar1 * h / devTex->height());
+ SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / srcDevTex->width(),
+ SK_Scalar1 * h / srcDevTex->height());
fDrawContext->fillRectToRect(fClip, grPaint, SkMatrix::I(), dstRect, srcRect);
}
+void SkGpuDevice::discard37() {
+ fDrawContext->discard();
+ // TODO: we need to close off the DrawTarget & create a new one
+}
+
bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) {
return filter->canFilterImageGPU();
}
@@ -1724,6 +1744,7 @@ void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
return;
}
}
+
this->drawBitmapRect(draw, bm, src, dst, paint, constraint);
}
@@ -1756,7 +1777,7 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
GrPaint grPaint;
// we ignore the shader if texs is null.
- if (!SkPaintToGrPaintNoShader(this->context(), copy, &grPaint)) {
+ if (!SkPaintToGrPaintNoShader(this->context(), copy, &grPaint, fRenderTarget)) {
return;
}
@@ -1789,6 +1810,7 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
lineIndices[i + 5] = state.f0;
i += 6;
}
+
fDrawContext->drawVertices(fClip,
grPaint,
*draw.fMatrix,
@@ -1828,12 +1850,12 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
colorMode = SkXfermode::kModulate_Mode;
}
if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMatrix, colorMode,
- false, &grPaint)) {
+ false, &grPaint, fRenderTarget)) {
return;
}
} else {
// We have a shader, but no colors to blend it against.
- if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRenderTarget)) {
return;
}
}
@@ -1841,12 +1863,12 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
if (colors) {
// We have colors, but either have no shader or no texture coords (which implies that
// we should ignore the shader).
- if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint, &grPaint)) {
+ if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint, &grPaint, fRenderTarget)) {
return;
}
} else {
// No colors and no shaders. Just draw with the paint color.
- if (!SkPaintToGrPaintNoShader(this->context(), paint, &grPaint)) {
+ if (!SkPaintToGrPaintNoShader(this->context(), paint, &grPaint, fRenderTarget)) {
return;
}
}
@@ -1881,13 +1903,14 @@ void SkGpuDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRS
p.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode))->unref();
GrPaint grPaint;
+
if (colors) {
if (!SkPaintToGrPaintWithXfermode(this->context(), p, *draw.fMatrix, mode, true,
- &grPaint)) {
+ &grPaint, fRenderTarget)) {
return;
}
} else {
- if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix, &grPaint, fRenderTarget)) {
return;
}
}
@@ -1905,7 +1928,7 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext);
GrPaint grPaint;
- if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRenderTarget)) {
return;
}
@@ -1922,7 +1945,7 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
CHECK_SHOULD_DRAW(draw);
GrPaint grPaint;
- if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRenderTarget)) {
return;
}
@@ -1935,6 +1958,10 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
void SkGpuDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint, SkDrawFilter* drawFilter) {
+ if (fContext->abandoned()) {
+ return;
+ }
+
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawTextBlob", fContext);
CHECK_SHOULD_DRAW(draw);
@@ -1952,6 +1979,7 @@ bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const {
void SkGpuDevice::flush() {
DO_DEFERRED_CLEAR();
+
fRenderTarget->prepareForExternalIO();
}
@@ -1996,6 +2024,8 @@ SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps
&props);
}
+#define SK_IGNORE_GPU_LAYER_HOISTING 1
+
bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture* mainPicture,
const SkMatrix* matrix, const SkPaint* paint) {
#ifndef SK_IGNORE_GPU_LAYER_HOISTING
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/SkGpuDevice_drawTexture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698