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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 SkCanvas canvas(bitmap); | 44 SkCanvas canvas(bitmap); |
45 | 45 |
46 SkPaint paint; | 46 SkPaint paint; |
47 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 47 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
48 surface->draw(&canvas, -SkIntToScalar(x), -SkIntToScalar(y), &paint); | 48 surface->draw(&canvas, -SkIntToScalar(x), -SkIntToScalar(y), &paint); |
49 return pixel; | 49 return pixel; |
50 } | 50 } |
51 | 51 |
52 class MockSurface : public SkSurface_Base { | 52 class MockSurface : public SkSurface_Base { |
53 public: | 53 public: |
54 MockSurface(int width, int height) : SkSurface_Base(width, height) { | 54 MockSurface(int width, int height) : SkSurface_Base(width, height, NULL) { |
55 clearCounts(); | 55 clearCounts(); |
56 fBitmap.allocN32Pixels(width, height); | 56 fBitmap.allocN32Pixels(width, height); |
57 } | 57 } |
58 | 58 |
59 virtual SkCanvas* onNewCanvas() SK_OVERRIDE { | 59 virtual SkCanvas* onNewCanvas() SK_OVERRIDE { |
60 return SkNEW_ARGS(SkCanvas, (fBitmap)); | 60 return SkNEW_ARGS(SkCanvas, (fBitmap)); |
61 } | 61 } |
62 | 62 |
63 virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE { | 63 virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE { |
64 return NULL; | 64 return NULL; |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 if (useGpu) { | 699 if (useGpu) { |
700 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLCon
textType) i; | 700 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLCon
textType) i; |
701 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { | 701 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { |
702 continue; | 702 continue; |
703 } | 703 } |
704 GrContext* context = factory->get(glCtxType); | 704 GrContext* context = factory->get(glCtxType); |
705 if (NULL == context) { | 705 if (NULL == context) { |
706 return; | 706 return; |
707 } | 707 } |
708 | 708 |
709 surface = SkSurface::NewRenderTarget(context, imageSpec); | 709 surface = SkSurface::NewRenderTarget(context, imageSpec, 0, NULL); |
710 } else | 710 } else |
711 #endif | 711 #endif |
712 { | 712 { |
713 surface = SkSurface::NewRaster(imageSpec); | 713 surface = SkSurface::NewRaster(imageSpec); |
714 } | 714 } |
715 SkASSERT(surface); | 715 SkASSERT(surface); |
716 SkAutoTUnref<SkSurface> aur(surface); | 716 SkAutoTUnref<SkSurface> aur(surface); |
717 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface))
; | 717 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface))
; |
718 | 718 |
719 SkImage* image1 = canvas->newImageSnapshot(); | 719 SkImage* image1 = canvas->newImageSnapshot(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 #if SK_SUPPORT_GPU | 781 #if SK_SUPPORT_GPU |
782 if (useGpu) { | 782 if (useGpu) { |
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, 0, NULL); |
792 alternateSurface = SkSurface::NewRenderTarget(context, imageSpec); | 792 alternateSurface = SkSurface::NewRenderTarget(context, imageSpec, 0,
NULL); |
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(surface); | 799 SkASSERT(surface); |
800 SkASSERT(alternateSurface); | 800 SkASSERT(alternateSurface); |
801 SkAutoTUnref<SkSurface> aur1(surface); | 801 SkAutoTUnref<SkSurface> aur1(surface); |
802 SkAutoTUnref<SkSurface> aur2(alternateSurface); | 802 SkAutoTUnref<SkSurface> aur2(alternateSurface); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 TestDeferredCanvasSurface(reporter, NULL); | 907 TestDeferredCanvasSurface(reporter, NULL); |
908 TestDeferredCanvasSetSurface(reporter, NULL); | 908 TestDeferredCanvasSetSurface(reporter, NULL); |
909 } | 909 } |
910 | 910 |
911 DEF_GPUTEST(DeferredCanvas_GPU, reporter, factory) { | 911 DEF_GPUTEST(DeferredCanvas_GPU, reporter, factory) { |
912 if (factory != NULL) { | 912 if (factory != NULL) { |
913 TestDeferredCanvasSurface(reporter, factory); | 913 TestDeferredCanvasSurface(reporter, factory); |
914 TestDeferredCanvasSetSurface(reporter, factory); | 914 TestDeferredCanvasSetSurface(reporter, factory); |
915 } | 915 } |
916 } | 916 } |
OLD | NEW |