14dc791bc4
This reverts commit74b83a4ea9
. Reason for revert: Flutter is updated Original change's description: > Revert "Migrate SkImage::MakeFromTexture to GrRecordingContext" > > This reverts commitdaa9e7455d
. > > Reason for revert: Broke Build-Debian9-Clang-arm-Release-Flutter_Android_Docker > > Original change's description: > > Migrate SkImage::MakeFromTexture to GrRecordingContext > > > > Android migration landed in Android CL 12234077 > > Chrome migration is landing in Chrome CL 2335812 > > > > Note: makeFromCompressedTexture is not used by Chrome. > > > > Bug: skia:104662 > > Change-Id: Ibbe6d412cf22e87188926383d10b21f780208e48 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305102 > > Commit-Queue: Adlai Holler <adlai@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Auto-Submit: Adlai Holler <adlai@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com > > Change-Id: I570945521c6cd78dfeea81e492b7e2b31dd0e6f5 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:104662 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308505 > Reviewed-by: Adlai Holler <adlai@google.com> > Commit-Queue: Adlai Holler <adlai@google.com> TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: skia:104662 Change-Id: Ie1d7fd9e597e6e6e5bd91bec086e83a8c1f45a37 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309321 Reviewed-by: Adlai Holler <adlai@google.com> Commit-Queue: Adlai Holler <adlai@google.com> Auto-Submit: Adlai Holler <adlai@google.com>
63 lines
2.4 KiB
C++
63 lines
2.4 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 "include/core/SkImage.h"
|
|
#include "include/core/SkSurface.h"
|
|
#include "include/core/SkSurfaceCharacterization.h"
|
|
#include "tests/Test.h"
|
|
|
|
DEF_GPUTEST(GrDDLImage_MakeSubset, reporter, options) {
|
|
sk_gpu_test::GrContextFactory factory(options);
|
|
for (int ct = 0; ct < sk_gpu_test::GrContextFactory::kContextTypeCnt; ++ct) {
|
|
auto contextType = static_cast<sk_gpu_test::GrContextFactory::ContextType>(ct);
|
|
auto dContext = factory.get(contextType);
|
|
if (!dContext) {
|
|
continue;
|
|
}
|
|
SkIRect subsetBounds = SkIRect::MakeLTRB(4,4,8,8);
|
|
SkImageInfo ii = SkImageInfo::Make(16, 16, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
|
|
|
// Raster image:
|
|
SkBitmap bm;
|
|
bm.setInfo(ii);
|
|
bm.allocPixels();
|
|
bm.eraseColor(SK_ColorBLACK);
|
|
bm.setImmutable();
|
|
auto rasterImg = SkImage::MakeFromBitmap(bm);
|
|
REPORTER_ASSERT(reporter, rasterImg->isValid(static_cast<GrRecordingContext*>(nullptr)));
|
|
|
|
// raster + context:
|
|
auto subImg1 = rasterImg->makeSubset(subsetBounds, dContext);
|
|
REPORTER_ASSERT(reporter, subImg1->isValid(dContext));
|
|
|
|
// raster + no context:
|
|
auto subImg2 = rasterImg->makeSubset(subsetBounds, nullptr);
|
|
REPORTER_ASSERT(reporter, subImg2->isValid(static_cast<GrRecordingContext*>(nullptr)));
|
|
|
|
// Texture image:
|
|
auto surf = SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, ii);
|
|
SkSurfaceCharacterization sc;
|
|
REPORTER_ASSERT(reporter, surf->characterize(&sc));
|
|
GrBackendTexture tex = dContext->createBackendTexture(sc);
|
|
auto gpuImage = SkImage::MakeFromTexture(dContext, tex, kTopLeft_GrSurfaceOrigin,
|
|
ii.colorType(), ii.alphaType(),
|
|
ii.refColorSpace());
|
|
REPORTER_ASSERT(reporter, gpuImage->isValid(dContext));
|
|
|
|
// gpu image + context:
|
|
auto subImg5 = gpuImage->makeSubset(subsetBounds, dContext);
|
|
REPORTER_ASSERT(reporter, subImg5->isValid(dContext));
|
|
|
|
// gpu image + nullptr:
|
|
REPORTER_ASSERT(reporter, !gpuImage->makeSubset(subsetBounds, nullptr));
|
|
|
|
dContext->flush();
|
|
dContext->submit(true);
|
|
dContext->deleteBackendTexture(tex);
|
|
}
|
|
}
|