use surface instead of explicitly making gpudevice

TBR=bsalomon

Author: reed@google.com

Review URL: https://codereview.chromium.org/585493002
This commit is contained in:
reed 2014-09-18 06:09:44 -07:00 committed by Commit bot
parent 613d579471
commit 69f6f00fd9
2 changed files with 10 additions and 21 deletions

View File

@ -12,10 +12,10 @@
#include "SkBitmap.h" #include "SkBitmap.h"
#include "SkCanvas.h" #include "SkCanvas.h"
#include "SkColor.h" #include "SkColor.h"
#include "SkGpuDevice.h"
#include "SkPaint.h" #include "SkPaint.h"
#include "SkRRect.h" #include "SkRRect.h"
#include "SkRect.h" #include "SkRect.h"
#include "SkSurface.h"
#include "Test.h" #include "Test.h"
static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) { static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) {
@ -54,20 +54,10 @@ DEF_GPUTEST(GpuDrawPath, reporter, factory) {
static const int sampleCounts[] = { 0, 4, 16 }; static const int sampleCounts[] = { 0, 4, 16 };
for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) { for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) {
const int W = 255; SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
const int H = 255;
GrTextureDesc desc; SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(grContext, info, sampleCounts[i]));
desc.fConfig = kSkia8888_GrPixelConfig; test_drawPathEmpty(reporter, surface->getCanvas());
desc.fFlags = kRenderTarget_GrTextureFlagBit;
desc.fWidth = W;
desc.fHeight = H;
desc.fSampleCnt = sampleCounts[i];
SkAutoTUnref<GrTexture> texture(grContext->createUncachedTexture(desc, NULL, 0));
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(texture.get()));
SkCanvas drawingCanvas(device.get());
test_drawPathEmpty(reporter, &drawingCanvas);
} }
} }
} }

View File

@ -7,9 +7,10 @@
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "SkCanvas.h"
#include "GrContextFactory.h" #include "GrContextFactory.h"
#include "GrResourceCache.h" #include "GrResourceCache.h"
#include "SkGpuDevice.h" #include "SkSurface.h"
#include "Test.h" #include "Test.h"
static const int gWidth = 640; static const int gWidth = 640;
@ -296,12 +297,10 @@ DEF_GPUTEST(ResourceCache, reporter, factory) {
desc.fFlags = kRenderTarget_GrTextureFlagBit; desc.fFlags = kRenderTarget_GrTextureFlagBit;
desc.fWidth = gWidth; desc.fWidth = gWidth;
desc.fHeight = gHeight; desc.fHeight = gHeight;
SkImageInfo info = SkImageInfo::MakeN32Premul(gWidth, gHeight);
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, info, 0));
SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NULL, 0)); test_cache(reporter, context, surface->getCanvas());
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(texture.get()));
SkCanvas canvas(device.get());
test_cache(reporter, context, &canvas);
test_purge_invalidated(reporter, context); test_purge_invalidated(reporter, context);
test_cache_delete_on_destruction(reporter, context); test_cache_delete_on_destruction(reporter, context);
test_resource_size_changed(reporter, context); test_resource_size_changed(reporter, context);