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

Side by Side Diff: src/ports/SkImagesSupport_default.cpp

Issue 647973006: Remove a SkImageDecoder reference from SkPicture.h (Closed) Base URL: https://skia.googlesource.com/skia.git@separate-image-encoder-02-debug-functionality
Patch Set: Created 6 years, 2 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/pdf/SkPDFDeviceFlattener.cpp ('k') | src/ports/SkImagesSupport_noimages.cpp » ('j') | 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 2014 Google Inc. 2 * Copyright 2014 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 "SkImagesSupport.h" 8 #include "SkImagesSupport.h"
9 #include "SkPicture.h"
10 #include "SkImageDecoder.h"
9 11
10 #if SK_SUPPORT_GPU && defined(SK_DEVELOPER) 12 #if SK_SUPPORT_GPU && defined(SK_DEVELOPER)
11 #include "GrSurface.h" 13 #include "GrSurface.h"
12 #include "SkBitmap.h" 14 #include "SkBitmap.h"
13 #include "SkImageEncoder.h" 15 #include "SkImageEncoder.h"
14 #include <stdio.h> 16 #include <stdio.h>
15 #endif 17 #endif
16 18
17 // This file should be compiled to images library when images library is part of the Skia library. 19 // This file should be compiled to images library when images library is part of the Skia library.
18 20
21 SkPicture* SkPicture::CreateFromStream(SkStream* stream) {
22 return SkPicture::CreateFromStream(stream, &SkImageDecoder::DecodeMemory);
23 }
24
19 #if SK_SUPPORT_GPU && defined(SK_DEVELOPER) 25 #if SK_SUPPORT_GPU && defined(SK_DEVELOPER)
20 bool SkSaveGrSurfacePixelsAsPNG(GrSurface* surface, const char* filename) { 26 bool SkSaveGrSurfacePixelsAsPNG(GrSurface* surface, const char* filename) {
21 SkBitmap bm; 27 SkBitmap bm;
22 if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(surface->width(), surface- >height()))) { 28 if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(surface->width(), surface- >height()))) {
23 return false; 29 return false;
24 } 30 }
25 31
26 bool result = surface->readPixels(0, 0, surface->width(), surface->height(), kSkia8888_GrPixelConfig, 32 bool result = surface->readPixels(0, 0, surface->width(), surface->height(), kSkia8888_GrPixelConfig,
27 bm.getPixels()); 33 bm.getPixels());
28 if (!result) { 34 if (!result) {
29 SkDebugf("------ failed to read pixels for %s\n", filename); 35 SkDebugf("------ failed to read pixels for %s\n", filename);
30 return false; 36 return false;
31 } 37 }
32 38
33 // remove any previous version of surface file 39 // remove any previous version of surface file
34 remove(filename); 40 remove(filename);
35 41
36 if (!SkImageEncoder::EncodeFile(filename, bm, SkImageEncoder::kPNG_Type, 100 )) { 42 if (!SkImageEncoder::EncodeFile(filename, bm, SkImageEncoder::kPNG_Type, 100 )) {
37 SkDebugf("------ failed to encode %s\n", filename); 43 SkDebugf("------ failed to encode %s\n", filename);
38 remove(filename); // remove any partial file 44 remove(filename); // remove any partial file
39 return false; 45 return false;
40 } 46 }
41 47
42 return true; 48 return true;
43 } 49 }
44 #endif 50 #endif
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDeviceFlattener.cpp ('k') | src/ports/SkImagesSupport_noimages.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698