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

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

Issue 665913002: Move code to dump GrSurface as a png to helper files (Closed) Base URL: https://skia.googlesource.com/skia.git@separate-image-encoder-01-skimage
Patch Set: address review comments Created 6 years, 1 month 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/gpu/GrTextStrike.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
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkImagesSupport.h"
9
10 #if SK_SUPPORT_GPU && defined(SK_DEVELOPER)
11 #include "GrSurface.h"
12 #include "SkBitmap.h"
13 #include "SkImageEncoder.h"
14 #include <stdio.h>
15 #endif
16
17 // This file should be compiled to images library when images library is part of the Skia library.
18
19 #if SK_SUPPORT_GPU && defined(SK_DEVELOPER)
20 bool SkSaveGrSurfacePixelsAsPNG(GrSurface* surface, const char* filename) {
21 SkBitmap bm;
22 if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(surface->width(), surface- >height()))) {
23 return false;
24 }
25
26 bool result = surface->readPixels(0, 0, surface->width(), surface->height(), kSkia8888_GrPixelConfig,
27 bm.getPixels());
28 if (!result) {
29 SkDebugf("------ failed to read pixels for %s\n", filename);
30 return false;
31 }
32
33 // remove any previous version of surface file
34 remove(filename);
35
36 if (!SkImageEncoder::EncodeFile(filename, bm, SkImageEncoder::kPNG_Type, 100 )) {
37 SkDebugf("------ failed to encode %s\n", filename);
38 remove(filename); // remove any partial file
39 return false;
40 }
41
42 return true;
43 }
44 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTextStrike.cpp ('k') | src/ports/SkImagesSupport_noimages.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698