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

Side by Side Diff: src/gpu/GrSurface.cpp

Issue 596053002: Make "priv" classes for GrTexure and GrSurface. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add SK_API 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/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrSurfacePriv.h » ('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 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 "GrSurface.h" 8 #include "GrSurface.h"
9 #include "GrSurfacePriv.h"
9 10
10 #include "SkBitmap.h" 11 #include "SkBitmap.h"
11 #include "SkGr.h" 12 #include "SkGr.h"
12 #include "SkImageEncoder.h" 13 #include "SkImageEncoder.h"
13 #include <stdio.h> 14 #include <stdio.h>
14 15
15 SkImageInfo GrSurface::info() const { 16 SkImageInfo GrSurface::info() const {
16 SkColorType colorType; 17 SkColorType colorType;
17 if (!GrPixelConfig2ColorType(this->config(), &colorType)) { 18 if (!GrPixelConfig2ColorType(this->config(), &colorType)) {
18 sk_throw(); 19 sk_throw();
19 } 20 }
20 return SkImageInfo::Make(this->width(), this->height(), colorType, kPremul_S kAlphaType); 21 return SkImageInfo::Make(this->width(), this->height(), colorType, kPremul_S kAlphaType);
21 } 22 }
22 23
24 // TODO: This should probably be a non-member helper function. It might only be needed in
25 // debug or developer builds.
23 bool GrSurface::savePixels(const char* filename) { 26 bool GrSurface::savePixels(const char* filename) {
24 SkBitmap bm; 27 SkBitmap bm;
25 if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(this->width(), this->heigh t()))) { 28 if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(this->width(), this->heigh t()))) {
26 return false; 29 return false;
27 } 30 }
28 31
29 bool result = readPixels(0, 0, this->width(), this->height(), kSkia8888_GrPi xelConfig, 32 bool result = this->readPixels(0, 0, this->width(), this->height(), kSkia888 8_GrPixelConfig,
30 bm.getPixels()); 33 bm.getPixels());
31 if (!result) { 34 if (!result) {
32 SkDebugf("------ failed to read pixels for %s\n", filename); 35 SkDebugf("------ failed to read pixels for %s\n", filename);
33 return false; 36 return false;
34 } 37 }
35 38
36 // remove any previous version of this file 39 // remove any previous version of this file
37 remove(filename); 40 remove(filename);
38 41
39 if (!SkImageEncoder::EncodeFile(filename, bm, SkImageEncoder::kPNG_Type, 100 )) { 42 if (!SkImageEncoder::EncodeFile(filename, bm, SkImageEncoder::kPNG_Type, 100 )) {
40 SkDebugf("------ failed to encode %s\n", filename); 43 SkDebugf("------ failed to encode %s\n", filename);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 const GrTexture* thisTex = this->asTexture(); 76 const GrTexture* thisTex = this->asTexture();
74 if (thisTex && thisTex->internalHasPendingIO()) { 77 if (thisTex && thisTex->internalHasPendingIO()) {
75 return true; 78 return true;
76 } 79 }
77 const GrRenderTarget* thisRT = this->asRenderTarget(); 80 const GrRenderTarget* thisRT = this->asRenderTarget();
78 if (thisRT && thisRT->internalHasPendingIO()) { 81 if (thisRT && thisRT->internalHasPendingIO()) {
79 return true; 82 return true;
80 } 83 }
81 return false; 84 return false;
82 } 85 }
86
87 bool GrSurface::isSameAs(const GrSurface* other) const {
88 const GrRenderTarget* thisRT = this->asRenderTarget();
89 if (thisRT) {
90 return thisRT == other->asRenderTarget();
91 } else {
92 const GrTexture* thisTex = this->asTexture();
93 SkASSERT(thisTex); // We must be one or the other
94 return thisTex == other->asTexture();
95 }
96 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrSurfacePriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698