Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Side by Side Diff: tests/DeferredCanvasTest.cpp

Issue 433463003: Fix way-over-allocation in pipe. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pipe/SkGPipeWrite.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "../src/image/SkImagePriv.h" 8 #include "../src/image/SkImagePriv.h"
9 #include "../src/image/SkSurface_Base.h" 9 #include "../src/image/SkSurface_Base.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 REPORTER_ASSERT(reporter, 1 == notificationCounter.fPrepareForDrawCount); 525 REPORTER_ASSERT(reporter, 1 == notificationCounter.fPrepareForDrawCount);
526 REPORTER_ASSERT(reporter, canvas->storageAllocatedForRecording() >= bitmapSi ze); 526 REPORTER_ASSERT(reporter, canvas->storageAllocatedForRecording() >= bitmapSi ze);
527 527
528 // verify that after a flush, cached image can be freed 528 // verify that after a flush, cached image can be freed
529 REPORTER_ASSERT(reporter, canvas->freeMemoryIfPossible(~0U) >= bitmapSize); 529 REPORTER_ASSERT(reporter, canvas->freeMemoryIfPossible(~0U) >= bitmapSize);
530 530
531 // Verify that caching works for avoiding multiple copies of the same bitmap 531 // Verify that caching works for avoiding multiple copies of the same bitmap
532 canvas->drawBitmap(sourceImages[0], 0, 0, NULL); 532 canvas->drawBitmap(sourceImages[0], 0, 0, NULL);
533 REPORTER_ASSERT(reporter, 2 == notificationCounter.fStorageAllocatedChangedC ount); 533 REPORTER_ASSERT(reporter, 2 == notificationCounter.fStorageAllocatedChangedC ount);
534 canvas->drawBitmap(sourceImages[0], 0, 0, NULL); 534 canvas->drawBitmap(sourceImages[0], 0, 0, NULL);
535 REPORTER_ASSERT(reporter, 3 == notificationCounter.fStorageAllocatedChangedC ount); 535 REPORTER_ASSERT(reporter, 2 == notificationCounter.fStorageAllocatedChangedC ount);
536 REPORTER_ASSERT(reporter, 1 == notificationCounter.fFlushedDrawCommandsCount ); 536 REPORTER_ASSERT(reporter, 1 == notificationCounter.fFlushedDrawCommandsCount );
537 REPORTER_ASSERT(reporter, canvas->storageAllocatedForRecording() < 2 * bitma pSize); 537 REPORTER_ASSERT(reporter, canvas->storageAllocatedForRecording() < 2 * bitma pSize);
538 538
539 // Verify partial eviction based on bytesToFree 539 // Verify partial eviction based on bytesToFree
540 canvas->drawBitmap(sourceImages[1], 0, 0, NULL); 540 canvas->drawBitmap(sourceImages[1], 0, 0, NULL);
541 REPORTER_ASSERT(reporter, 1 == notificationCounter.fFlushedDrawCommandsCount ); 541 REPORTER_ASSERT(reporter, 1 == notificationCounter.fFlushedDrawCommandsCount );
542 canvas->flush(); 542 canvas->flush();
543 REPORTER_ASSERT(reporter, 2 == notificationCounter.fFlushedDrawCommandsCount ); 543 REPORTER_ASSERT(reporter, 2 == notificationCounter.fFlushedDrawCommandsCount );
544 REPORTER_ASSERT(reporter, canvas->storageAllocatedForRecording() > 2 * bitma pSize); 544 REPORTER_ASSERT(reporter, canvas->storageAllocatedForRecording() > 2 * bitma pSize);
545 size_t bytesFreed = canvas->freeMemoryIfPossible(1); 545 size_t bytesFreed = canvas->freeMemoryIfPossible(1);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLCon textType) i; 783 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLCon textType) i;
784 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { 784 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
785 continue; 785 continue;
786 } 786 }
787 GrContext* context = factory->get(glCtxType); 787 GrContext* context = factory->get(glCtxType);
788 if (NULL == context) { 788 if (NULL == context) {
789 continue; 789 continue;
790 } 790 }
791 surface = SkSurface::NewRenderTarget(context, imageSpec); 791 surface = SkSurface::NewRenderTarget(context, imageSpec);
792 alternateSurface = SkSurface::NewRenderTarget(context, imageSpec); 792 alternateSurface = SkSurface::NewRenderTarget(context, imageSpec);
793 } else 793 } else
794 #endif 794 #endif
795 { 795 {
796 surface = SkSurface::NewRaster(imageSpec); 796 surface = SkSurface::NewRaster(imageSpec);
797 alternateSurface = SkSurface::NewRaster(imageSpec); 797 alternateSurface = SkSurface::NewRaster(imageSpec);
798 } 798 }
799 SkASSERT(NULL != surface); 799 SkASSERT(NULL != surface);
800 SkASSERT(NULL != alternateSurface); 800 SkASSERT(NULL != alternateSurface);
801 SkAutoTUnref<SkSurface> aur1(surface); 801 SkAutoTUnref<SkSurface> aur1(surface);
802 SkAutoTUnref<SkSurface> aur2(alternateSurface); 802 SkAutoTUnref<SkSurface> aur2(alternateSurface);
803 PixelPtr pixels1 = get_surface_ptr(surface, useGpu); 803 PixelPtr pixels1 = get_surface_ptr(surface, useGpu);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 TestDeferredCanvasSurface(reporter, NULL); 853 TestDeferredCanvasSurface(reporter, NULL);
854 TestDeferredCanvasSetSurface(reporter, NULL); 854 TestDeferredCanvasSetSurface(reporter, NULL);
855 } 855 }
856 856
857 DEF_GPUTEST(DeferredCanvas_GPU, reporter, factory) { 857 DEF_GPUTEST(DeferredCanvas_GPU, reporter, factory) {
858 if (factory != NULL) { 858 if (factory != NULL) {
859 TestDeferredCanvasSurface(reporter, factory); 859 TestDeferredCanvasSurface(reporter, factory);
860 TestDeferredCanvasSetSurface(reporter, factory); 860 TestDeferredCanvasSetSurface(reporter, factory);
861 } 861 }
862 } 862 }
OLDNEW
« no previous file with comments | « src/pipe/SkGPipeWrite.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698