f41b2bd449
This reverts commitf21bf9e50b
. Reason for revert: relanding with infra fix Original change's description: > Revert "Merge GrOpList and GrRTOpList and rename to GrOpsTask." > > This reverts commit2a5954140b
. > > Reason for revert: breaking everything > > Original change's description: > > Merge GrOpList and GrRTOpList and rename to GrOpsTask. > > > > Change-Id: I8f4f2218a30fd0541a8f79f7bb9850f9500cd243 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/236343 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com > > Change-Id: I27840ea0343e8e6b388556afb7bd2e76386d611d > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/236349 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Greg Daniel <egdaniel@google.com> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com Change-Id: Ibd3a06e4a91dbb1f225dcc8d17d0db3967b6f85f No-Presubmit: true No-Tree-Checks: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/236350 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
83 lines
2.8 KiB
C++
83 lines
2.8 KiB
C++
/*
|
|
* Copyright 2018 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkSurface.h"
|
|
#include "include/gpu/GrContext.h"
|
|
#include "src/gpu/GrContextPriv.h"
|
|
#include "src/gpu/GrGpu.h"
|
|
#include "tests/Test.h"
|
|
|
|
static bool check_read(skiatest::Reporter* reporter, const SkBitmap& bitmap) {
|
|
bool result = true;
|
|
for (int x = 0; x < 1000 && result; ++x) {
|
|
const uint32_t srcPixel = *bitmap.getAddr32(x, 0);
|
|
if (srcPixel != SK_ColorGREEN) {
|
|
ERRORF(reporter, "Expected color of Green, but got 0x%08x, at pixel (%d, 0).",
|
|
x, srcPixel);
|
|
result = false;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrOpsTaskFlushCount, reporter, ctxInfo) {
|
|
GrContext* context = ctxInfo.grContext();
|
|
GrGpu* gpu = context->priv().getGpu();
|
|
|
|
SkImageInfo imageInfo = SkImageInfo::Make(1000, 1, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
|
|
|
sk_sp<SkSurface> surface1 = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, imageInfo);
|
|
if (!surface1) {
|
|
return;
|
|
}
|
|
sk_sp<SkSurface> surface2 = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, imageInfo);
|
|
if (!surface2) {
|
|
return;
|
|
}
|
|
|
|
SkCanvas* canvas1 = surface1->getCanvas();
|
|
SkCanvas* canvas2 = surface2->getCanvas();
|
|
|
|
canvas1->clear(SK_ColorRED);
|
|
canvas2->clear(SK_ColorRED);
|
|
|
|
SkIRect srcRect = SkIRect::MakeWH(1, 1);
|
|
SkRect dstRect = SkRect::MakeWH(1, 1);
|
|
SkPaint paint;
|
|
paint.setColor(SK_ColorGREEN);
|
|
canvas1->drawRect(dstRect, paint);
|
|
|
|
for (int i = 0; i < 1000; ++i) {
|
|
srcRect.fLeft = i;
|
|
srcRect.fRight = srcRect.fLeft + 1;
|
|
|
|
sk_sp<SkImage> image = surface1->makeImageSnapshot();
|
|
canvas2->drawImageRect(image.get(), srcRect, dstRect, nullptr);
|
|
if (i != 999) {
|
|
dstRect.fLeft = i+1;
|
|
dstRect.fRight = dstRect.fLeft + 1;
|
|
image = surface2->makeImageSnapshot();
|
|
canvas1->drawImageRect(image.get(), srcRect, dstRect, nullptr);
|
|
}
|
|
}
|
|
context->flush();
|
|
|
|
// In total we make 2000 oplists. Our current limit on max oplists between flushes is 100, so we
|
|
// should do 20 flushes while executing oplists. Additionaly we always do 1 flush at the end of
|
|
// executing all oplists. So in total we should see 21 flushes here.
|
|
REPORTER_ASSERT(reporter, gpu->stats()->numFinishFlushes() == 21);
|
|
|
|
SkBitmap readbackBitmap;
|
|
readbackBitmap.allocN32Pixels(1000, 1);
|
|
REPORTER_ASSERT(reporter, surface1->readPixels(readbackBitmap, 0, 0));
|
|
REPORTER_ASSERT(reporter, check_read(reporter, readbackBitmap));
|
|
|
|
REPORTER_ASSERT(reporter, surface2->readPixels(readbackBitmap, 0, 0));
|
|
REPORTER_ASSERT(reporter, check_read(reporter, readbackBitmap));
|
|
}
|