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

Side by Side Diff: src/gpu/gl/GrGLRenderTarget.cpp

Issue 691523002: Separate out GrSurfaceConfig's fields from other structs used to create GrGL* GrSurface subclasses (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix indent 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/gl/GrGLRenderTarget.h ('k') | src/gpu/gl/GrGLTexture.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 2011 Google Inc. 2 * Copyright 2011 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 "GrGLRenderTarget.h" 8 #include "GrGLRenderTarget.h"
9 9
10 #include "GrGpuGL.h" 10 #include "GrGpuGL.h"
11 11
12 #define GPUGL static_cast<GrGpuGL*>(getGpu()) 12 #define GPUGL static_cast<GrGpuGL*>(getGpu())
13 13
14 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) 14 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
15 15
16 void GrGLRenderTarget::init(const Desc& desc, 16 void GrGLRenderTarget::init(const GrSurfaceDesc& desc,
17 const IDDesc& idDesc,
17 const GrGLIRect& viewport, 18 const GrGLIRect& viewport,
18 GrGLTexID* texID) { 19 GrGLTexID* texID) {
19 fRTFBOID = desc.fRTFBOID; 20 fRTFBOID = idDesc.fRTFBOID;
20 fTexFBOID = desc.fTexFBOID; 21 fTexFBOID = idDesc.fTexFBOID;
21 fMSColorRenderbufferID = desc.fMSColorRenderbufferID; 22 fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID;
22 fViewport = viewport; 23 fViewport = viewport;
23 fTexIDObj.reset(SkSafeRef(texID)); 24 fTexIDObj.reset(SkSafeRef(texID));
24 this->registerWithCache(); 25 this->registerWithCache();
25 } 26 }
26 27
27 namespace {
28 GrSurfaceDesc MakeDesc(GrSurfaceFlags flags,
29 int width, int height,
30 GrPixelConfig config, int sampleCnt,
31 GrSurfaceOrigin origin) {
32 GrSurfaceDesc temp;
33 temp.fFlags = flags;
34 temp.fWidth = width;
35 temp.fHeight = height;
36 temp.fConfig = config;
37 temp.fSampleCnt = sampleCnt;
38 temp.fOrigin = origin;
39 return temp;
40 }
41
42 };
43
44 GrGLRenderTarget::GrGLRenderTarget(GrGpuGL* gpu, 28 GrGLRenderTarget::GrGLRenderTarget(GrGpuGL* gpu,
45 const Desc& desc, 29 const IDDesc& idDesc,
46 const GrGLIRect& viewport, 30 const GrGLIRect& viewport,
47 GrGLTexID* texID, 31 GrGLTexID* texID,
48 GrGLTexture* texture) 32 GrGLTexture* texture)
49 : INHERITED(gpu, 33 : INHERITED(gpu, idDesc.fIsWrapped, texture, texture->desc()) {
50 desc.fIsWrapped,
51 texture,
52 MakeDesc(kNone_GrSurfaceFlags,
53 viewport.fWidth, viewport.fHeight,
54 desc.fConfig, desc.fSampleCnt,
55 desc.fOrigin)) {
56 SkASSERT(texID); 34 SkASSERT(texID);
57 SkASSERT(texture); 35 SkASSERT(texture);
58 // FBO 0 can't also be a texture, right? 36 // FBO 0 can't also be a texture, right?
59 SkASSERT(0 != desc.fRTFBOID); 37 SkASSERT(0 != idDesc.fRTFBOID);
60 SkASSERT(0 != desc.fTexFBOID); 38 SkASSERT(0 != idDesc.fTexFBOID);
61 39
62 // we assume this is true, TODO: get rid of viewport as a param. 40 // we assume this is true, TODO: get rid of viewport as a param.
63 SkASSERT(viewport.fWidth == texture->width()); 41 SkASSERT(viewport.fWidth == texture->width());
64 SkASSERT(viewport.fHeight == texture->height()); 42 SkASSERT(viewport.fHeight == texture->height());
65 43
66 this->init(desc, viewport, texID); 44 this->init(texture->desc(), idDesc, viewport, texID);
67 } 45 }
68 46
69 GrGLRenderTarget::GrGLRenderTarget(GrGpuGL* gpu, 47 GrGLRenderTarget::GrGLRenderTarget(GrGpuGL* gpu,
70 const Desc& desc, 48 const GrSurfaceDesc& desc,
49 const IDDesc& idDesc,
71 const GrGLIRect& viewport) 50 const GrGLIRect& viewport)
72 : INHERITED(gpu, 51 : INHERITED(gpu, idDesc.fIsWrapped, NULL, desc) {
73 desc.fIsWrapped, 52 this->init(desc, idDesc, viewport, NULL);
74 NULL,
75 MakeDesc(kNone_GrSurfaceFlags,
76 viewport.fWidth, viewport.fHeight,
77 desc.fConfig, desc.fSampleCnt,
78 desc.fOrigin)) {
79 this->init(desc, viewport, NULL);
80 } 53 }
81 54
82 void GrGLRenderTarget::onRelease() { 55 void GrGLRenderTarget::onRelease() {
83 if (!this->isWrapped()) { 56 if (!this->isWrapped()) {
84 if (fTexFBOID) { 57 if (fTexFBOID) {
85 GL_CALL(DeleteFramebuffers(1, &fTexFBOID)); 58 GL_CALL(DeleteFramebuffers(1, &fTexFBOID));
86 } 59 }
87 if (fRTFBOID && fRTFBOID != fTexFBOID) { 60 if (fRTFBOID && fRTFBOID != fTexFBOID) {
88 GL_CALL(DeleteFramebuffers(1, &fRTFBOID)); 61 GL_CALL(DeleteFramebuffers(1, &fRTFBOID));
89 } 62 }
(...skipping 11 matching lines...) Expand all
101 void GrGLRenderTarget::onAbandon() { 74 void GrGLRenderTarget::onAbandon() {
102 fRTFBOID = 0; 75 fRTFBOID = 0;
103 fTexFBOID = 0; 76 fTexFBOID = 0;
104 fMSColorRenderbufferID = 0; 77 fMSColorRenderbufferID = 0;
105 if (fTexIDObj.get()) { 78 if (fTexIDObj.get()) {
106 fTexIDObj->abandon(); 79 fTexIDObj->abandon();
107 fTexIDObj.reset(NULL); 80 fTexIDObj.reset(NULL);
108 } 81 }
109 INHERITED::onAbandon(); 82 INHERITED::onAbandon();
110 } 83 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLRenderTarget.h ('k') | src/gpu/gl/GrGLTexture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698