Skip to content

Commit

Permalink
Revert "Move GrGeometryProcessor's textures out of classes and into"
Browse files Browse the repository at this point in the history
This reverts commit af87483.

Revert "GrGeometryProcessor derives from GrNonAtomicRef not GrProgramElement."

This reverts commit 607be37.

Revert "Store GrMeshDrawOps' meshes in GrOpFlushState's arena."

This reverts commit b948572.

Revert "Remove multitexturing support from GrTextureOp."

This reverts commit 986f64c.

Revert "Make result of GrOp::combineIfPossible be an enum."

This reverts commit 641ac7d.

Bug: b/112244393
Change-Id: I579491a3f2f2f2093f1e2a6141fa1e4cc7b760a4
Reviewed-on: https://skia-review.googlesource.com/145646
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
  • Loading branch information
bsalomon authored and Skia Commit-Bot committed Aug 6, 2018
1 parent cadc506 commit fdf05f4
Show file tree
Hide file tree
Showing 86 changed files with 1,403 additions and 1,031 deletions.
99 changes: 0 additions & 99 deletions bench/CompositingImagesBench.cpp

This file was deleted.

94 changes: 0 additions & 94 deletions bench/ImageCycleBench.cpp

This file was deleted.

136 changes: 136 additions & 0 deletions bench/MultitextureImageBench.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

#include "Benchmark.h"

#include "GrContextOptions.h"
#include "SkCanvas.h"
#include "SkImage.h"
#include "SkRandom.h"
#include "SkSurface.h"

class MultitextureImages : public Benchmark {
public:
MultitextureImages(int imageSize, int dstRectSize, bool disableMultitexturing, bool aa)
: fImageSize(imageSize)
, fDstRectSize(dstRectSize)
, fDisableMultitexturing(disableMultitexturing)
, fAA(aa) {
fName.appendf("multitexture_images_%dx%d_image_%dx%d_rect", imageSize, imageSize,
dstRectSize, dstRectSize);
if (aa) {
fName.append("_aa");
}
if (disableMultitexturing) {
fName.append("_disable_multitexturing");
}
}

bool isSuitableFor(Backend backend) override { return kGPU_Backend == backend; }

protected:
const char* onGetName() override { return fName.c_str(); }

void onPerCanvasPreDraw(SkCanvas* canvas) override {
auto ii = SkImageInfo::Make(fImageSize, fImageSize, kRGBA_8888_SkColorType,
kPremul_SkAlphaType, nullptr);
SkRandom random;
for (int i = 0; i < kNumImages; ++i) {
auto surf = canvas->makeSurface(ii);
SkColor color = random.nextU();
surf->getCanvas()->clear(color);
SkPaint paint;
paint.setColor(~color);
paint.setBlendMode(SkBlendMode::kSrc);
surf->getCanvas()->drawRect(SkRect::MakeLTRB(3, 3, fImageSize - 3, fImageSize - 3),
paint);
fImages[i] = surf->makeImageSnapshot();
}
}

void onPerCanvasPostDraw(SkCanvas*) override {
for (int i = 0; i < kNumImages; ++i) {
fImages[i].reset();
}
}

void onDraw(int loops, SkCanvas* canvas) override {
SkRect rect = SkRect::MakeWH(fDstRectSize, fDstRectSize);
SkPaint paint;
paint.setAlpha(0x40);
paint.setFilterQuality(kLow_SkFilterQuality);
paint.setAntiAlias(fAA);
for (int i = 0; i < loops; i++) {
for (int j = 0; j < kNumImages; ++j) {
SkVector translate = this->translation(i * kNumImages + j);
canvas->drawImageRect(fImages[j].get(), rect.makeOffset(translate.fX, translate.fY),
&paint);
}
// Prevent any batching except without multitexturing since we're trying to measure
// drawing distinct images and just repeating images here to increase the workload for
// timing reasons.
canvas->flush();
}
}

void modifyGrContextOptions(GrContextOptions* options) override {
options->fDisableImageMultitexturing = fDisableMultitexturing;
}

private:
SkIPoint onGetSize() override {
// The rows and columns are spaced by kTranslate, but the images may overlap if they are
// larger than kTranslate and extend beyond the last row/column.
return SkIPoint::Make(kTranslate * (kNumColumns - 1) + fDstRectSize,
kTranslate * (kNumRows - 1) + fDstRectSize);
}

SkVector translation(int i) const {
SkVector offset;
// Fractional offsets to ensure we can't ignore antialiasing.
offset.fX = i % kNumColumns * kTranslate + 0.1f;
offset.fY = (i / kNumColumns) % kNumRows * kTranslate + 0.1f;
return offset;
}

static const int kTranslate = 200;
static const int kNumColumns = 5;
static const int kNumRows = 5;
static const int kNumImages = 8;

sk_sp<SkImage> fImages[kNumImages];
SkString fName;
int fImageSize;
int fDstRectSize;
bool fDisableMultitexturing;
bool fAA;

typedef Benchmark INHERITED;
};

// Non-AA
DEF_BENCH(return new MultitextureImages(128, 32, false, false));
DEF_BENCH(return new MultitextureImages(128, 32, true, false));
DEF_BENCH(return new MultitextureImages(128, 128, false, false));
DEF_BENCH(return new MultitextureImages(128, 128, true, false));
DEF_BENCH(return new MultitextureImages(128, 256, false, false));
DEF_BENCH(return new MultitextureImages(128, 256, true, false));

DEF_BENCH(return new MultitextureImages(512, 32, false, false));
DEF_BENCH(return new MultitextureImages(512, 32, true, false));
DEF_BENCH(return new MultitextureImages(512, 128, false, false));
DEF_BENCH(return new MultitextureImages(512, 128, true, false));
DEF_BENCH(return new MultitextureImages(512, 256, false, false));
DEF_BENCH(return new MultitextureImages(512, 256, true, false));
DEF_BENCH(return new MultitextureImages(512, 512, false, false));
DEF_BENCH(return new MultitextureImages(512, 512, true, false));

// AA
DEF_BENCH(return new MultitextureImages(512, 512, true, true));
DEF_BENCH(return new MultitextureImages(512, 512, false, true));
DEF_BENCH(return new MultitextureImages(128, 32, true, true));
DEF_BENCH(return new MultitextureImages(128, 32, false, true));
10 changes: 6 additions & 4 deletions bench/VertexColorSpaceBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ class Op : public GrMeshDrawOp {
private:
friend class ::GrOpMemoryPool;

bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; }

void onPrepareDraws(Target* target) override {
sk_sp<GrGeometryProcessor> gp(new GP(fMode, fColorSpaceXform));

Expand Down Expand Up @@ -197,12 +199,12 @@ class Op : public GrMeshDrawOp {
}
}

GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangleStrip);
mesh->setNonIndexedNonInstanced(kVertexCount);
mesh->setVertexData(vertexBuffer, firstVertex);
GrMesh mesh(GrPrimitiveType::kTriangleStrip);
mesh.setNonIndexedNonInstanced(kVertexCount);
mesh.setVertexData(vertexBuffer, firstVertex);
auto pipe = target->makePipeline(0, GrProcessorSet::MakeEmptySet(),
target->detachAppliedClip());
target->draw(gp, pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}

Mode fMode;
Expand Down
Loading

0 comments on commit fdf05f4

Please sign in to comment.