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

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

Issue 2173513002: Cleanup of code that converts from GPU-backed resources to SkImageInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@fix-sync
Patch Set: Created 4 years, 5 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 "GrContext.h" 9 #include "GrContext.h"
10 #include "GrSurfacePriv.h" 10 #include "GrSurfacePriv.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 uint32_t pixelOpsFlags) { 109 uint32_t pixelOpsFlags) {
110 // go through context so that all necessary flushing occurs 110 // go through context so that all necessary flushing occurs
111 GrContext* context = this->getContext(); 111 GrContext* context = this->getContext();
112 if (nullptr == context) { 112 if (nullptr == context) {
113 return false; 113 return false;
114 } 114 }
115 return context->readSurfacePixels(this, left, top, width, height, config, bu ffer, 115 return context->readSurfacePixels(this, left, top, width, height, config, bu ffer,
116 rowBytes, pixelOpsFlags); 116 rowBytes, pixelOpsFlags);
117 } 117 }
118 118
119 SkImageInfo GrSurface::info(SkAlphaType alphaType) const {
120 SkColorType colorType;
121 sk_sp<SkColorSpace> colorSpace;
122 if (!GrPixelConfigToColorAndColorSpace(this->config(), &colorType, &colorSpa ce)) {
123 sk_throw();
124 }
125 return SkImageInfo::Make(this->width(), this->height(), colorType, alphaType , colorSpace);
126 }
127
128 // TODO: This should probably be a non-member helper function. It might only be needed in 119 // TODO: This should probably be a non-member helper function. It might only be needed in
129 // debug or developer builds. 120 // debug or developer builds.
130 bool GrSurface::savePixels(const char* filename) { 121 bool GrSurface::savePixels(const char* filename) {
131 SkBitmap bm; 122 SkBitmap bm;
132 if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(this->width(), this->heigh t()))) { 123 if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(this->width(), this->heigh t()))) {
133 return false; 124 return false;
134 } 125 }
135 126
136 bool result = this->readPixels(0, 0, this->width(), this->height(), kSkia888 8_GrPixelConfig, 127 bool result = this->readPixels(0, 0, this->width(), this->height(), kSkia888 8_GrPixelConfig,
137 bm.getPixels()); 128 bm.getPixels());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 193
203 void GrSurface::onRelease() { 194 void GrSurface::onRelease() {
204 this->invokeReleaseProc(); 195 this->invokeReleaseProc();
205 this->INHERITED::onRelease(); 196 this->INHERITED::onRelease();
206 } 197 }
207 198
208 void GrSurface::onAbandon() { 199 void GrSurface::onAbandon() {
209 this->invokeReleaseProc(); 200 this->invokeReleaseProc();
210 this->INHERITED::onAbandon(); 201 this->INHERITED::onAbandon();
211 } 202 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrSurfacePriv.h » ('j') | src/image/SkImage_Gpu.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698