OLD | NEW |
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 "SkSurface_Base.h" | 8 #include "SkSurface_Base.h" |
9 #include "SkImagePriv.h" | 9 #include "SkImagePriv.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 111 } |
112 return SkNEW_ARGS(SkSurface_Gpu, (target, props, false)); | 112 return SkNEW_ARGS(SkSurface_Gpu, (target, props, false)); |
113 } | 113 } |
114 | 114 |
115 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, i
nt sampleCount, | 115 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, i
nt sampleCount, |
116 const SkSurfaceProps* props) { | 116 const SkSurfaceProps* props) { |
117 if (NULL == ctx) { | 117 if (NULL == ctx) { |
118 return NULL; | 118 return NULL; |
119 } | 119 } |
120 | 120 |
121 GrTextureDesc desc; | 121 GrSurfaceDesc desc; |
122 desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFla
gBit; | 122 desc.fFlags = kRenderTarget_GrSurfaceFlag | kCheckAllocation_GrSurfaceFlag; |
123 desc.fWidth = info.width(); | 123 desc.fWidth = info.width(); |
124 desc.fHeight = info.height(); | 124 desc.fHeight = info.height(); |
125 desc.fConfig = SkImageInfo2GrPixelConfig(info); | 125 desc.fConfig = SkImageInfo2GrPixelConfig(info); |
126 desc.fSampleCnt = sampleCount; | 126 desc.fSampleCnt = sampleCount; |
127 | 127 |
128 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0)); | 128 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0)); |
129 if (NULL == tex) { | 129 if (NULL == tex) { |
130 return NULL; | 130 return NULL; |
131 } | 131 } |
132 | 132 |
133 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), props, true)); | 133 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), props, true)); |
134 } | 134 } |
135 | 135 |
136 SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo&
info, | 136 SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo&
info, |
137 int sampleCount, const SkSurfacePro
ps* props) { | 137 int sampleCount, const SkSurfacePro
ps* props) { |
138 if (NULL == ctx) { | 138 if (NULL == ctx) { |
139 return NULL; | 139 return NULL; |
140 } | 140 } |
141 | 141 |
142 GrTextureDesc desc; | 142 GrSurfaceDesc desc; |
143 desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFla
gBit; | 143 desc.fFlags = kRenderTarget_GrSurfaceFlag | kCheckAllocation_GrSurfaceFlag; |
144 desc.fWidth = info.width(); | 144 desc.fWidth = info.width(); |
145 desc.fHeight = info.height(); | 145 desc.fHeight = info.height(); |
146 desc.fConfig = SkImageInfo2GrPixelConfig(info); | 146 desc.fConfig = SkImageInfo2GrPixelConfig(info); |
147 desc.fSampleCnt = sampleCount; | 147 desc.fSampleCnt = sampleCount; |
148 | 148 |
149 SkAutoTUnref<GrTexture> tex(ctx->refScratchTexture(desc, GrContext::kExact_S
cratchTexMatch)); | 149 SkAutoTUnref<GrTexture> tex(ctx->refScratchTexture(desc, GrContext::kExact_S
cratchTexMatch)); |
150 | 150 |
151 if (NULL == tex) { | 151 if (NULL == tex) { |
152 return NULL; | 152 return NULL; |
153 } | 153 } |
154 | 154 |
155 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), props, true)); | 155 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), props, true)); |
156 } | 156 } |
OLD | NEW |