Retract SkDevice a bit more
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1905383002 Review URL: https://codereview.chromium.org/1905383002
This commit is contained in:
parent
272aa12c63
commit
7715e06b68
@ -11,10 +11,6 @@
|
||||
#include "SkPath.h"
|
||||
#include "SkSurface.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "SkGpuDevice.h"
|
||||
#endif
|
||||
|
||||
#define W SkIntToScalar(80)
|
||||
#define H SkIntToScalar(60)
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrContext.h"
|
||||
#include "SkGpuDevice.h"
|
||||
#endif
|
||||
|
||||
namespace skiagm {
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
class GrContext;
|
||||
class GrFragmentProcessor;
|
||||
class SkBaseDevice;
|
||||
class SkColorFilter;
|
||||
struct SkIPoint;
|
||||
class SkSpecialImage;
|
||||
|
@ -37,7 +37,7 @@
|
||||
# include "gl/GrGLUtil.h"
|
||||
# include "GrRenderTarget.h"
|
||||
# include "GrContext.h"
|
||||
# include "SkGpuDevice.h"
|
||||
# include "SkGr.h"
|
||||
# if SK_ANGLE
|
||||
# include "gl/angle/GLTestContext_angle.h"
|
||||
# endif
|
||||
|
@ -5,18 +5,17 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "GrContext.h"
|
||||
#include "GrLayerCache.h"
|
||||
#include "GrLayerHoister.h"
|
||||
#include "GrRecordReplaceDraw.h"
|
||||
|
||||
#include "SkBigPicture.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGpuDevice.h"
|
||||
#include "SkLayerInfo.h"
|
||||
#include "SkRecordDraw.h"
|
||||
#include "SkSpecialImage.h"
|
||||
#include "SkSurface.h"
|
||||
#include "SkSurface_Gpu.h"
|
||||
|
||||
// Create the layer information for the hoisted layer and secure the
|
||||
// required texture/render target resources.
|
||||
@ -278,7 +277,7 @@ void GrLayerHoister::DrawLayersToAtlas(GrContext* context,
|
||||
}
|
||||
|
||||
void GrLayerHoister::FilterLayer(GrContext* context,
|
||||
SkGpuDevice* device,
|
||||
const SkSurfaceProps* props,
|
||||
const GrHoistedLayer& info) {
|
||||
GrCachedLayer* layer = info.fLayer;
|
||||
|
||||
@ -305,7 +304,7 @@ void GrLayerHoister::FilterLayer(GrContext* context,
|
||||
sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromGpu(subset,
|
||||
kNeedNewImageUniqueID_SpecialImage,
|
||||
layer->texture(),
|
||||
&device->surfaceProps()));
|
||||
props));
|
||||
|
||||
SkIPoint offset = SkIPoint::Make(0, 0);
|
||||
sk_sp<SkSpecialImage> result(layer->filter()->filterImage(img.get(),
|
||||
@ -358,9 +357,7 @@ void GrLayerHoister::DrawLayers(GrContext* context, const SkTDArray<GrHoistedLay
|
||||
layerCanvas->flush();
|
||||
|
||||
if (layer->filter()) {
|
||||
SkSurface_Gpu* gpuSurf = static_cast<SkSurface_Gpu*>(surface.get());
|
||||
|
||||
FilterLayer(context, gpuSurf->getDevice(), layers[i]);
|
||||
FilterLayer(context, &surface->props(), layers[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,10 +114,10 @@ public:
|
||||
private:
|
||||
/** Update the GrTexture in 'layer' with its filtered version
|
||||
@param context Owner of the layer cache (and thus the layers)
|
||||
@param device Required by the filtering code
|
||||
@param props Surface properties
|
||||
@param info Layer info for a layer needing filtering prior to being composited
|
||||
*/
|
||||
static void FilterLayer(GrContext* context, SkGpuDevice* device, const GrHoistedLayer& info);
|
||||
static void FilterLayer(GrContext* context, const SkSurfaceProps*, const GrHoistedLayer& info);
|
||||
|
||||
};
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "GrStencilAndCoverTextContext.h"
|
||||
#include "GrAtlasTextContext.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrDrawContext.h"
|
||||
#include "GrPath.h"
|
||||
#include "GrPathRange.h"
|
||||
@ -16,7 +17,6 @@
|
||||
#include "SkDraw.h"
|
||||
#include "SkDrawProcs.h"
|
||||
#include "SkGlyphCache.h"
|
||||
#include "SkGpuDevice.h"
|
||||
#include "SkGrPriv.h"
|
||||
#include "SkDrawFilter.h"
|
||||
#include "SkPath.h"
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "effects/GrYUVEffect.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkBitmapCache.h"
|
||||
#include "SkGpuDevice.h"
|
||||
#include "SkGrPixelRef.h"
|
||||
#include "SkGrPriv.h"
|
||||
#include "SkImage_Gpu.h"
|
||||
|
@ -5,15 +5,14 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkConfig8888.h"
|
||||
#include "SkSurface.h"
|
||||
#include "Test.h"
|
||||
#include "sk_tool_utils.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrContext.h"
|
||||
#include "SkGpuDevice.h"
|
||||
#endif
|
||||
|
||||
static uint32_t pack_unpremul_rgba(SkColor c) {
|
||||
@ -46,7 +45,7 @@ const struct {
|
||||
{ kBGRA_8888_SkColorType, pack_unpremul_bgra },
|
||||
};
|
||||
|
||||
static void fillCanvas(SkCanvas* canvas, SkColorType colorType, PackUnpremulProc proc) {
|
||||
static void fill_canvas(SkCanvas* canvas, SkColorType colorType, PackUnpremulProc proc) {
|
||||
// Don't strictly need a bitmap, but its a handy way to allocate the pixels
|
||||
SkBitmap bmp;
|
||||
bmp.allocN32Pixels(256, 256);
|
||||
@ -63,10 +62,10 @@ static void fillCanvas(SkCanvas* canvas, SkColorType colorType, PackUnpremulProc
|
||||
canvas->writePixels(info, bmp.getPixels(), bmp.rowBytes(), 0, 0);
|
||||
}
|
||||
|
||||
static void test_premul_alpha_roundtrip(skiatest::Reporter* reporter, SkBaseDevice* device) {
|
||||
SkCanvas canvas(device);
|
||||
static void test_premul_alpha_roundtrip(skiatest::Reporter* reporter, SkSurface* surf) {
|
||||
SkCanvas* canvas = surf->getCanvas();
|
||||
for (size_t upmaIdx = 0; upmaIdx < SK_ARRAY_COUNT(gUnpremul); ++upmaIdx) {
|
||||
fillCanvas(&canvas, gUnpremul[upmaIdx].fColorType, gUnpremul[upmaIdx].fPackProc);
|
||||
fill_canvas(canvas, gUnpremul[upmaIdx].fColorType, gUnpremul[upmaIdx].fPackProc);
|
||||
|
||||
const SkImageInfo info = SkImageInfo::Make(256, 256, gUnpremul[upmaIdx].fColorType,
|
||||
kUnpremul_SkAlphaType);
|
||||
@ -78,10 +77,10 @@ static void test_premul_alpha_roundtrip(skiatest::Reporter* reporter, SkBaseDevi
|
||||
readBmp1.eraseColor(0);
|
||||
readBmp2.eraseColor(0);
|
||||
|
||||
canvas.readPixels(&readBmp1, 0, 0);
|
||||
sk_tool_utils::write_pixels(&canvas, readBmp1, 0, 0, gUnpremul[upmaIdx].fColorType,
|
||||
canvas->readPixels(&readBmp1, 0, 0);
|
||||
sk_tool_utils::write_pixels(canvas, readBmp1, 0, 0, gUnpremul[upmaIdx].fColorType,
|
||||
kUnpremul_SkAlphaType);
|
||||
canvas.readPixels(&readBmp2, 0, 0);
|
||||
canvas->readPixels(&readBmp2, 0, 0);
|
||||
|
||||
bool success = true;
|
||||
for (int y = 0; y < 256 && success; ++y) {
|
||||
@ -100,17 +99,18 @@ static void test_premul_alpha_roundtrip(skiatest::Reporter* reporter, SkBaseDevi
|
||||
|
||||
DEF_TEST(PremulAlphaRoundTrip, reporter) {
|
||||
const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256);
|
||||
SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props));
|
||||
test_premul_alpha_roundtrip(reporter, device);
|
||||
|
||||
sk_sp<SkSurface> surf(SkSurface::MakeRaster(info));
|
||||
|
||||
test_premul_alpha_roundtrip(reporter, surf.get());
|
||||
}
|
||||
#if SK_SUPPORT_GPU
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PremulAlphaRoundTrip_Gpu, reporter, ctxInfo) {
|
||||
const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256);
|
||||
SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
SkAutoTUnref<SkBaseDevice> device(
|
||||
SkGpuDevice::Create(ctxInfo.fGrContext, SkBudgeted::kNo, info, 0, &props,
|
||||
SkGpuDevice::kUninit_InitContents));
|
||||
test_premul_alpha_roundtrip(reporter, device);
|
||||
|
||||
sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(ctxInfo.fGrContext,
|
||||
SkBudgeted::kNo,
|
||||
info));
|
||||
test_premul_alpha_roundtrip(reporter, surf.get());
|
||||
}
|
||||
#endif
|
||||
|
@ -11,7 +11,8 @@
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "GrContext.h"
|
||||
#include "SkGpuDevice.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkSurface.h"
|
||||
|
||||
// This was made indivisible by 4 to ensure we test setting GL_PACK_ALIGNMENT properly.
|
||||
static const int X_SIZE = 13;
|
||||
@ -92,10 +93,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
|
||||
|
||||
// Now try writing on the single channel texture (if we could create as a RT).
|
||||
if (texture->asRenderTarget()) {
|
||||
SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(
|
||||
texture->asRenderTarget(), &props, SkGpuDevice::kUninit_InitContents));
|
||||
SkCanvas canvas(device);
|
||||
sk_sp<SkSurface> surf(SkSurface::MakeRenderTargetDirect(texture->asRenderTarget()));
|
||||
SkCanvas* canvas = surf->getCanvas();
|
||||
|
||||
SkPaint paint;
|
||||
|
||||
@ -103,7 +102,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
|
||||
|
||||
paint.setColor(SK_ColorWHITE);
|
||||
|
||||
canvas.drawRect(rect, paint);
|
||||
canvas->drawRect(rect, paint);
|
||||
|
||||
memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE);
|
||||
result = texture->readPixels(0, 0, desc.fWidth, desc.fHeight,
|
||||
|
Loading…
Reference in New Issue
Block a user