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

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

Issue 648863002: Devirtualize read/write pixels on surface. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: simplify return 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/GrRenderTarget.cpp ('k') | src/gpu/GrTexture.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 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 #include "GrSurfacePriv.h"
10 10
11 #include "SkBitmap.h" 11 #include "SkBitmap.h"
12 #include "SkGr.h" 12 #include "SkGr.h"
13 #include "SkImageEncoder.h" 13 #include "SkImageEncoder.h"
14 #include <stdio.h> 14 #include <stdio.h>
15 15
16 bool GrSurface::writePixels(int left, int top, int width, int height,
17 GrPixelConfig config, const void* buffer, size_t row Bytes,
18 uint32_t pixelOpsFlags) {
19 // go through context so that all necessary flushing occurs
20 GrContext* context = this->getContext();
21 if (NULL == context) {
22 return false;
23 }
24 return context->writeSurfacePixels(this, left, top, width, height, config, b uffer, rowBytes,
25 pixelOpsFlags);
26 }
27
28 bool GrSurface::readPixels(int left, int top, int width, int height,
29 GrPixelConfig config, void* buffer, size_t rowBytes,
30 uint32_t pixelOpsFlags) {
31 // go through context so that all necessary flushing occurs
32 GrContext* context = this->getContext();
33 if (NULL == context) {
34 return false;
35 }
36 GrRenderTarget* target = this->asRenderTarget();
37 if (target) {
38 return context->readRenderTargetPixels(target, left, top, width, height, config, buffer,
39 rowBytes, pixelOpsFlags);
40 }
41 return false;
42 }
43
16 SkImageInfo GrSurface::info() const { 44 SkImageInfo GrSurface::info() const {
17 SkColorType colorType; 45 SkColorType colorType;
18 if (!GrPixelConfig2ColorType(this->config(), &colorType)) { 46 if (!GrPixelConfig2ColorType(this->config(), &colorType)) {
19 sk_throw(); 47 sk_throw();
20 } 48 }
21 return SkImageInfo::Make(this->width(), this->height(), colorType, kPremul_S kAlphaType); 49 return SkImageInfo::Make(this->width(), this->height(), colorType, kPremul_S kAlphaType);
22 } 50 }
23 51
24 // TODO: This should probably be a non-member helper function. It might only be needed in 52 // TODO: This should probably be a non-member helper function. It might only be needed in
25 // debug or developer builds. 53 // debug or developer builds.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 bool GrSurface::isSameAs(const GrSurface* other) const { 121 bool GrSurface::isSameAs(const GrSurface* other) const {
94 const GrRenderTarget* thisRT = this->asRenderTarget(); 122 const GrRenderTarget* thisRT = this->asRenderTarget();
95 if (thisRT) { 123 if (thisRT) {
96 return thisRT == other->asRenderTarget(); 124 return thisRT == other->asRenderTarget();
97 } else { 125 } else {
98 const GrTexture* thisTex = this->asTexture(); 126 const GrTexture* thisTex = this->asTexture();
99 SkASSERT(thisTex); // We must be one or the other 127 SkASSERT(thisTex); // We must be one or the other
100 return thisTex == other->asTexture(); 128 return thisTex == other->asTexture();
101 } 129 }
102 } 130 }
OLDNEW
« no previous file with comments | « src/gpu/GrRenderTarget.cpp ('k') | src/gpu/GrTexture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698