OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkDecodingImageGenerator.h" | |
11 #include "SkImageEncoder.h" | 10 #include "SkImageEncoder.h" |
12 #include "SkRRect.h" | 11 #include "SkRRect.h" |
13 #include "SkSurface.h" | 12 #include "SkSurface.h" |
14 #include "SkUtils.h" | 13 #include "SkUtils.h" |
15 #include "Test.h" | 14 #include "Test.h" |
16 | 15 |
17 #if SK_SUPPORT_GPU | 16 #if SK_SUPPORT_GPU |
18 #include "GrContextFactory.h" | 17 #include "GrContextFactory.h" |
19 #else | 18 #else |
20 class GrContextFactory; | 19 class GrContextFactory; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 case kGpu_ImageType: { | 131 case kGpu_ImageType: { |
133 SkAutoTUnref<SkSurface> surf(SkSurface::NewRenderTarget(context, inf
o, 0)); | 132 SkAutoTUnref<SkSurface> surf(SkSurface::NewRenderTarget(context, inf
o, 0)); |
134 surf->getCanvas()->clear(color); | 133 surf->getCanvas()->clear(color); |
135 return surf->newImageSnapshot(); | 134 return surf->newImageSnapshot(); |
136 } | 135 } |
137 case kCodec_ImageType: { | 136 case kCodec_ImageType: { |
138 SkBitmap bitmap; | 137 SkBitmap bitmap; |
139 bitmap.installPixels(info, addr, rowBytes); | 138 bitmap.installPixels(info, addr, rowBytes); |
140 SkAutoTUnref<SkData> src( | 139 SkAutoTUnref<SkData> src( |
141 SkImageEncoder::EncodeData(bitmap, SkImageEncoder::kPNG_Type, 1
00)); | 140 SkImageEncoder::EncodeData(bitmap, SkImageEncoder::kPNG_Type, 1
00)); |
142 return SkImage::NewFromGenerator( | 141 return SkImage::NewFromData(src); |
143 SkDecodingImageGenerator::Create(src, SkDecodingImageGenerator::
Options())); | |
144 } | 142 } |
145 } | 143 } |
146 SkASSERT(false); | 144 SkASSERT(false); |
147 return NULL; | 145 return NULL; |
148 } | 146 } |
149 | 147 |
150 static void set_pixels(SkPMColor pixels[], int count, SkPMColor color) { | 148 static void set_pixels(SkPMColor pixels[], int count, SkPMColor color) { |
151 sk_memset32(pixels, color, count); | 149 sk_memset32(pixels, color, count); |
152 } | 150 } |
153 static bool has_pixels(const SkPMColor pixels[], int count, SkPMColor expected)
{ | 151 static bool has_pixels(const SkPMColor pixels[], int count, SkPMColor expected)
{ |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurfa
ce::kRetain_ContentChangeMode); | 529 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurfa
ce::kRetain_ContentChangeMode); |
532 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context,
SkSurface::kRetain_ContentChangeMode); | 530 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context,
SkSurface::kRetain_ContentChangeMode); |
533 TestGetTexture(reporter, kGpu_SurfaceType, context); | 531 TestGetTexture(reporter, kGpu_SurfaceType, context); |
534 TestGetTexture(reporter, kGpuScratch_SurfaceType, context); | 532 TestGetTexture(reporter, kGpuScratch_SurfaceType, context); |
535 test_empty_surface(reporter, context); | 533 test_empty_surface(reporter, context); |
536 } | 534 } |
537 } | 535 } |
538 } | 536 } |
539 #endif | 537 #endif |
540 } | 538 } |
OLD | NEW |