6d2febd632
This reverts commit1ff415d5a1
. Reason for revert: relanding with fix Original change's description: > Revert "Add create backend texture with color upload bench." > > This reverts commit690b4c4644
. > > Reason for revert: breaking bots > > Original change's description: > > Add create backend texture with color upload bench. > > > > Change-Id: Id4994cb809d6e19ca511b63dba71b45257eca927 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287618 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > TBR=egdaniel@google.com,robertphillips@google.com > > Change-Id: I2ac38977abc0004b38a94dacf0a235ae4fbac5d3 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287636 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Greg Daniel <egdaniel@google.com> TBR=egdaniel@google.com,robertphillips@google.com Change-Id: I287a1d829d4d861d149b0f1d9adf556a38e44abb No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287638 Reviewed-by: Greg Daniel <egdaniel@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
59 lines
1.8 KiB
C++
59 lines
1.8 KiB
C++
/*
|
|
* Copyright 2020 Google LLC
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "bench/Benchmark.h"
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/gpu/GrContext.h"
|
|
|
|
class CreateBackendTextureBench : public Benchmark {
|
|
private:
|
|
SkString fName;
|
|
SkTArray<GrBackendTexture> fBackendTextures;
|
|
GrMipMapped fMipMapped;
|
|
|
|
public:
|
|
CreateBackendTextureBench(GrMipMapped mipMapped) : fMipMapped(mipMapped) {
|
|
fName.printf("create_backend_texture%s", mipMapped == GrMipMapped::kYes ? "_mipped" : "");
|
|
}
|
|
|
|
private:
|
|
bool isSuitableFor(Backend backend) override { return kGPU_Backend == backend; }
|
|
|
|
const char* onGetName() override { return fName.c_str(); }
|
|
|
|
void onDraw(int loops, SkCanvas* canvas) override {
|
|
GrContext* context = canvas->getGrContext();
|
|
|
|
fBackendTextures.reserve(loops);
|
|
|
|
static const int kSize = 16;
|
|
for (int i = 0; i < loops; ++i) {
|
|
fBackendTextures.push_back(context->createBackendTexture(
|
|
kSize, kSize, kRGBA_8888_SkColorType, SkColors::kRed, fMipMapped,
|
|
GrRenderable::kNo, GrProtected::kNo));
|
|
}
|
|
}
|
|
|
|
void onPerCanvasPostDraw(SkCanvas* canvas) override {
|
|
GrContext* context = canvas->getGrContext();
|
|
|
|
GrFlushInfo info;
|
|
info.fFlags = kSyncCpu_GrFlushFlag;
|
|
context->flush(info);
|
|
|
|
for (int i = 0; i < fBackendTextures.count(); ++i) {
|
|
if (fBackendTextures[i].isValid()) {
|
|
context->deleteBackendTexture(fBackendTextures[i]);
|
|
}
|
|
}
|
|
fBackendTextures.reset();
|
|
}
|
|
};
|
|
|
|
DEF_BENCH(return new CreateBackendTextureBench(GrMipMapped::kNo);)
|
|
DEF_BENCH(return new CreateBackendTextureBench(GrMipMapped::kYes);)
|