bd500f09ce
Reason for revert: Need workaround for chrome to build Original issue's description: > Move Budgeted enum out of SkSurface, use in GrTextureProvider > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1728093005 > DOCS_PREVIEW= https://skia.org/?cl=1728093005 > > Committed: https://skia.googlesource.com/skia/+/57599fe6c0336feaeeeb9b1996e77b70219b483c TBR=reed@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1734043002
63 lines
2.2 KiB
C++
63 lines
2.2 KiB
C++
/*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "SkTypes.h"
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
#include "GrContext.h"
|
|
#include "GrTexture.h"
|
|
#include "GrTexturePriv.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkGr.h"
|
|
#include "SkSurface.h"
|
|
#include "Test.h"
|
|
|
|
// Tests that GrSurface::asTexture(), GrSurface::asRenderTarget(), and static upcasting of texture
|
|
// and render targets to GrSurface all work as expected.
|
|
DEF_GPUTEST_FOR_NULL_CONTEXT(GrTextureMipMapInvalidationTest, reporter, context) {
|
|
GrSurfaceDesc desc;
|
|
desc.fConfig = kSkia8888_GrPixelConfig;
|
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
|
desc.fWidth = 256;
|
|
desc.fHeight = 256;
|
|
desc.fSampleCnt = 0;
|
|
GrSurface* texRT1 = context->textureProvider()->createTexture(desc, false, nullptr, 0);
|
|
GrSurface* texRT2 = context->textureProvider()->createTexture(desc, false, nullptr, 0);
|
|
REPORTER_ASSERT(reporter, nullptr != texRT1);
|
|
REPORTER_ASSERT(reporter, nullptr != texRT2);
|
|
GrTexture* tex = texRT1->asTexture();
|
|
REPORTER_ASSERT(reporter, nullptr != tex);
|
|
SkBitmap bitmap;
|
|
GrWrapTextureInBitmap(tex, 256, 256, false, &bitmap);
|
|
|
|
// No mipmaps initially
|
|
REPORTER_ASSERT(reporter, false == tex->texturePriv().hasMipMaps());
|
|
|
|
// Painting with downscale and medium filter quality should result in mipmap creation
|
|
SkSurface* surface = SkSurface::NewRenderTargetDirect(texRT2->asRenderTarget());
|
|
SkPaint paint;
|
|
paint.setFilterQuality(kMedium_SkFilterQuality);
|
|
surface->getCanvas()->scale(0.2f, 0.2f);
|
|
surface->getCanvas()->drawBitmap(bitmap, 0, 0, &paint);
|
|
context->flush();
|
|
|
|
REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps());
|
|
REPORTER_ASSERT(reporter, false == tex->texturePriv().mipMapsAreDirty());
|
|
|
|
// Invalidating the contents of the bitmap should invalidate the mipmap, but not de-allocate
|
|
bitmap.notifyPixelsChanged();
|
|
REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps());
|
|
REPORTER_ASSERT(reporter, true == tex->texturePriv().mipMapsAreDirty());
|
|
|
|
surface->unref();
|
|
texRT1->unref();
|
|
texRT2->unref();
|
|
}
|
|
|
|
#endif
|