First implementation of GrTextureRenderTarget.

Change-Id: I0e6bc516eb43e7f7062f9d19e7ef8093324b551d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/233997
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Stephen White 2019-08-14 15:07:42 -04:00 committed by Skia Commit-Bot
parent 7bfc9139c6
commit 9d4219229b
4 changed files with 100 additions and 1 deletions

View File

@ -732,6 +732,8 @@ skia_dawn_sources = [
"$_src/gpu/dawn/GrDawnStencilAttachment.h",
"$_src/gpu/dawn/GrDawnTexture.cpp",
"$_src/gpu/dawn/GrDawnTexture.h",
"$_src/gpu/dawn/GrDawnTextureRenderTarget.cpp",
"$_src/gpu/dawn/GrDawnTextureRenderTarget.h",
"$_src/gpu/dawn/GrDawnUniformHandler.cpp",
"$_src/gpu/dawn/GrDawnUniformHandler.h",
"$_src/gpu/dawn/GrDawnUtil.cpp",

View File

@ -8,6 +8,7 @@
#include "src/gpu/dawn/GrDawnTexture.h"
#include "src/gpu/dawn/GrDawnGpu.h"
#include "src/gpu/dawn/GrDawnTextureRenderTarget.h"
#include "src/gpu/dawn/GrDawnUtil.h"
GrDawnTexture::GrDawnTexture(GrDawnGpu* gpu,
@ -63,7 +64,13 @@ sk_sp<GrDawnTexture> GrDawnTexture::Make(GrDawnGpu* gpu, const SkISize& size, Gr
info.fLevelCount = mipLevels;
sk_sp<GrDawnTexture> result;
if (renderTarget) {
SkASSERT(!"unimplemented");
result = sk_sp<GrDawnTextureRenderTarget>(new GrDawnTextureRenderTarget(gpu,
size,
config,
textureView,
sampleCnt,
info,
status));
} else {
result = sk_sp<GrDawnTexture>(new GrDawnTexture(gpu, size, config, textureView, info,
status));

View File

@ -0,0 +1,35 @@
/*
* Copyright 2019 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "src/gpu/dawn/GrDawnTextureRenderTarget.h"
#include "include/core/SkTraceMemoryDump.h"
#include "include/gpu/GrContext.h"
#include "src/gpu/GrTexturePriv.h"
#include "src/gpu/dawn/GrDawnGpu.h"
GrDawnTextureRenderTarget::GrDawnTextureRenderTarget(GrDawnGpu* gpu,
const SkISize& size,
GrPixelConfig config,
dawn::TextureView textureView,
int sampleCnt,
const GrDawnImageInfo& info,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, size, config, GrProtected::kNo)
, GrDawnTexture(gpu, size, config, textureView, info, mipMapsStatus)
, GrDawnRenderTarget(gpu, size, config, sampleCnt, info) {
}
bool GrDawnTextureRenderTarget::canAttemptStencilAttachment() const {
return true;
}
size_t GrDawnTextureRenderTarget::onGpuMemorySize() const {
return GrSurface::ComputeSize(this->config(), this->width(), this->height(),
1, // FIXME: for MSAA
this->texturePriv().mipMapped());
}

View File

@ -0,0 +1,55 @@
/*
* Copyright 2019 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrDawnTextureRenderTarget_DEFINED
#define GrDawnTextureRenderTarget_DEFINED
#include "src/gpu/dawn/GrDawnRenderTarget.h"
#include "src/gpu/dawn/GrDawnTexture.h"
class GrDawnGpu;
#ifdef SK_BUILD_FOR_WIN
// Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
#pragma warning(push)
#pragma warning(disable: 4250)
#endif
class GrDawnTextureRenderTarget : public GrDawnTexture, public GrDawnRenderTarget {
public:
GrDawnTextureRenderTarget(GrDawnGpu* gpu,
const SkISize& size,
GrPixelConfig config,
const dawn::TextureView textureView,
int sampleCnt,
const GrDawnImageInfo& info,
GrMipMapsStatus mipMapsStatus);
bool canAttemptStencilAttachment() const override;
GrBackendFormat backendFormat() const override { return GrDawnTexture::backendFormat(); }
protected:
void onAbandon() override {
GrDawnRenderTarget::onAbandon();
GrDawnTexture::onAbandon();
}
void onRelease() override {
GrDawnRenderTarget::onRelease();
GrDawnTexture::onRelease();
}
private:
size_t onGpuMemorySize() const override;
};
#ifdef SK_BUILD_FOR_WIN
#pragma warning(pop)
#endif
#endif