Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 691 if (useGpu) { | 691 if (useGpu) { |
| 692 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLCon textType) i; | 692 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLCon textType) i; |
| 693 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { | 693 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { |
| 694 continue; | 694 continue; |
| 695 } | 695 } |
| 696 GrContext* context = factory->get(glCtxType); | 696 GrContext* context = factory->get(glCtxType); |
| 697 if (NULL == context) { | 697 if (NULL == context) { |
| 698 return; | 698 return; |
| 699 } | 699 } |
| 700 | 700 |
| 701 surface = SkSurface::NewRenderTarget(context, imageSpec, 0, NULL); | 701 surface = |
| 702 SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, ima geSpec, 0, NULL); | |
| 702 } else | 703 } else |
| 703 #endif | 704 #endif |
| 704 { | 705 { |
| 705 surface = SkSurface::NewRaster(imageSpec); | 706 surface = SkSurface::NewRaster(imageSpec); |
| 706 } | 707 } |
| 707 SkASSERT(surface); | 708 SkASSERT(surface); |
| 708 SkAutoTUnref<SkSurface> aur(surface); | 709 SkAutoTUnref<SkSurface> aur(surface); |
| 709 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface)) ; | 710 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface)) ; |
| 710 | 711 |
| 711 SkImage* image1 = canvas->newImageSnapshot(); | 712 SkImage* image1 = canvas->newImageSnapshot(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 #if SK_SUPPORT_GPU | 774 #if SK_SUPPORT_GPU |
| 774 if (useGpu) { | 775 if (useGpu) { |
| 775 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLCon textType) i; | 776 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLCon textType) i; |
| 776 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { | 777 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { |
| 777 continue; | 778 continue; |
| 778 } | 779 } |
| 779 GrContext* context = factory->get(glCtxType); | 780 GrContext* context = factory->get(glCtxType); |
| 780 if (NULL == context) { | 781 if (NULL == context) { |
| 781 continue; | 782 continue; |
| 782 } | 783 } |
| 783 surface = SkSurface::NewRenderTarget(context, imageSpec, 0, NULL); | 784 surface = |
| 784 alternateSurface = SkSurface::NewRenderTarget(context, imageSpec, 0, NULL); | 785 SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, ima geSpec, 0, NULL); |
| 786 alternateSurface = | |
| 787 SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, ima geSpec, 0, NULL); | |
| 785 } else | 788 } else |
| 786 #endif | 789 #endif |
| 787 { | 790 { |
| 788 surface = SkSurface::NewRaster(imageSpec); | 791 surface = SkSurface::NewRaster(imageSpec); |
| 789 alternateSurface = SkSurface::NewRaster(imageSpec); | 792 alternateSurface = SkSurface::NewRaster(imageSpec); |
| 790 } | 793 } |
| 791 SkASSERT(surface); | 794 SkASSERT(surface); |
| 792 SkASSERT(alternateSurface); | 795 SkASSERT(alternateSurface); |
|
robertphillips
2015/01/15 21:30:36
Can we just make surface & alternateSurface be SkA
bsalomon
2015/01/15 22:15:50
Done (the ignoring, that is :) ) Just don't want
| |
| 793 SkAutoTUnref<SkSurface> aur1(surface); | 796 SkAutoTUnref<SkSurface> aur1(surface); |
| 794 SkAutoTUnref<SkSurface> aur2(alternateSurface); | 797 SkAutoTUnref<SkSurface> aur2(alternateSurface); |
| 795 PixelPtr pixels1 = get_surface_ptr(surface, useGpu); | 798 PixelPtr pixels1 = get_surface_ptr(surface, useGpu); |
| 796 PixelPtr pixels2 = get_surface_ptr(alternateSurface, useGpu); | 799 PixelPtr pixels2 = get_surface_ptr(alternateSurface, useGpu); |
| 797 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface)) ; | 800 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface)) ; |
| 798 SkAutoTUnref<SkImage> image1(canvas->newImageSnapshot()); | 801 SkAutoTUnref<SkImage> image1(canvas->newImageSnapshot()); |
| 799 canvas->setSurface(alternateSurface); | 802 canvas->setSurface(alternateSurface); |
| 800 SkAutoTUnref<SkImage> image2(canvas->newImageSnapshot()); | 803 SkAutoTUnref<SkImage> image2(canvas->newImageSnapshot()); |
| 801 REPORTER_ASSERT(reporter, image1->uniqueID() != image2->uniqueID()); | 804 REPORTER_ASSERT(reporter, image1->uniqueID() != image2->uniqueID()); |
| 802 // Verify that none of the above operations triggered a surface copy on write. | 805 // Verify that none of the above operations triggered a surface copy on write. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 899 TestDeferredCanvasSurface(reporter, NULL); | 902 TestDeferredCanvasSurface(reporter, NULL); |
| 900 TestDeferredCanvasSetSurface(reporter, NULL); | 903 TestDeferredCanvasSetSurface(reporter, NULL); |
| 901 } | 904 } |
| 902 | 905 |
| 903 DEF_GPUTEST(DeferredCanvas_GPU, reporter, factory) { | 906 DEF_GPUTEST(DeferredCanvas_GPU, reporter, factory) { |
| 904 if (factory != NULL) { | 907 if (factory != NULL) { |
| 905 TestDeferredCanvasSurface(reporter, factory); | 908 TestDeferredCanvasSurface(reporter, factory); |
| 906 TestDeferredCanvasSetSurface(reporter, factory); | 909 TestDeferredCanvasSetSurface(reporter, factory); |
| 907 } | 910 } |
| 908 } | 911 } |
| OLD | NEW |