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

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: rebase 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
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
23 bool GrSurface::savePixels(const char* filename) { 24 bool GrSurface::savePixels(const char* filename) {
24 SkBitmap bm; 25 SkBitmap bm;
25 if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(this->width(), this->heigh t()))) { 26 if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(this->width(), this->heigh t()))) {
26 return false; 27 return false;
27 } 28 }
28 29
29 bool result = readPixels(0, 0, this->width(), this->height(), kSkia8888_GrPi xelConfig, 30 bool result = this->readPixels(0, 0, this->width(), this->height(), kSkia888 8_GrPixelConfig,
30 bm.getPixels()); 31 bm.getPixels());
31 if (!result) { 32 if (!result) {
32 SkDebugf("------ failed to read pixels for %s\n", filename); 33 SkDebugf("------ failed to read pixels for %s\n", filename);
33 return false; 34 return false;
34 } 35 }
35 36
36 // remove any previous version of this file 37 // remove any previous version of this file
37 remove(filename); 38 remove(filename);
38 39
39 if (!SkImageEncoder::EncodeFile(filename, bm, SkImageEncoder::kPNG_Type, 100 )) { 40 if (!SkImageEncoder::EncodeFile(filename, bm, SkImageEncoder::kPNG_Type, 100 )) {
40 SkDebugf("------ failed to encode %s\n", filename); 41 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(); 74 const GrTexture* thisTex = this->asTexture();
74 if (thisTex && thisTex->internalHasPendingIO()) { 75 if (thisTex && thisTex->internalHasPendingIO()) {
75 return true; 76 return true;
76 } 77 }
77 const GrRenderTarget* thisRT = this->asRenderTarget(); 78 const GrRenderTarget* thisRT = this->asRenderTarget();
78 if (thisRT && thisRT->internalHasPendingIO()) { 79 if (thisRT && thisRT->internalHasPendingIO()) {
79 return true; 80 return true;
80 } 81 }
81 return false; 82 return false;
82 } 83 }
84
robertphillips 2014/09/29 13:34:27 It looks like GrSurfacePriv is careful to leave al
joshua.litt 2014/09/29 13:58:08 I think my preference is to move implementations o
bsalomon 2014/09/29 18:42:10 I don't feel strongly either way. The passthroughs
85 bool GrSurface::isSameAs(const GrSurface* other) const {
86 const GrRenderTarget* thisRT = this->asRenderTarget();
87 if (thisRT) {
88 return thisRT == other->asRenderTarget();
89 } else {
90 const GrTexture* thisTex = this->asTexture();
91 SkASSERT(thisTex); // We must be one or the other
92 return thisTex == other->asTexture();
93 }
94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698