OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 225 } |
226 | 226 |
227 void GrGpu::clearStencilClip(const SkIRect& rect, | 227 void GrGpu::clearStencilClip(const SkIRect& rect, |
228 bool insideClip, | 228 bool insideClip, |
229 GrRenderTarget* renderTarget) { | 229 GrRenderTarget* renderTarget) { |
230 SkASSERT(renderTarget); | 230 SkASSERT(renderTarget); |
231 this->handleDirtyContext(); | 231 this->handleDirtyContext(); |
232 this->onClearStencilClip(renderTarget, rect, insideClip); | 232 this->onClearStencilClip(renderTarget, rect, insideClip); |
233 } | 233 } |
234 | 234 |
| 235 bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size
_t rowBytes, |
| 236 GrPixelConfig readConfig, DrawPreference* drawPref
erence, |
| 237 ReadPixelTempDrawInfo* tempDrawInfo) { |
| 238 SkASSERT(drawPreference); |
| 239 SkASSERT(tempDrawInfo); |
| 240 SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference); |
| 241 |
| 242 if (!this->onGetReadPixelsInfo(srcSurface, width, height, rowBytes, readConf
ig, drawPreference, |
| 243 tempDrawInfo)) { |
| 244 return false; |
| 245 } |
| 246 |
| 247 // Check to see if we're going to request that the caller draw when drawing
is not possible. |
| 248 if (!srcSurface->asTexture() || |
| 249 !this->caps()->isConfigRenderable(tempDrawInfo->fTempSurfaceDesc.fConfig
, false)) { |
| 250 // If we don't have a fallback to a straight read then fail. |
| 251 if (kRequireDraw_DrawPreference == *drawPreference) { |
| 252 return false; |
| 253 } |
| 254 *drawPreference = kNoDraw_DrawPreference; |
| 255 } |
| 256 |
| 257 return true; |
| 258 } |
| 259 bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, int width, int height, siz
e_t rowBytes, |
| 260 GrPixelConfig srcConfig, DrawPreference* drawPref
erence, |
| 261 WritePixelTempDrawInfo* tempDrawInfo) { |
| 262 SkASSERT(drawPreference); |
| 263 SkASSERT(tempDrawInfo); |
| 264 SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference); |
| 265 |
| 266 if (this->caps()->useDrawInsteadOfPartialRenderTargetWrite() && |
| 267 SkToBool(dstSurface->asRenderTarget()) && |
| 268 (width < dstSurface->width() || height < dstSurface->height())) { |
| 269 ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference); |
| 270 } |
| 271 |
| 272 if (!this->onGetWritePixelsInfo(dstSurface, width, height, rowBytes, srcConf
ig, drawPreference, |
| 273 tempDrawInfo)) { |
| 274 return false; |
| 275 } |
| 276 |
| 277 // Check to see if we're going to request that the caller draw when drawing
is not possible. |
| 278 if (!dstSurface->asRenderTarget() || |
| 279 !this->caps()->isConfigTexturable(tempDrawInfo->fTempSurfaceDesc.fConfig
)) { |
| 280 // If we don't have a fallback to a straight upload then fail. |
| 281 if (kRequireDraw_DrawPreference == *drawPreference || |
| 282 !this->caps()->isConfigTexturable(srcConfig)) { |
| 283 return false; |
| 284 } |
| 285 *drawPreference = kNoDraw_DrawPreference; |
| 286 } |
| 287 return true; |
| 288 } |
| 289 |
235 bool GrGpu::readPixels(GrRenderTarget* target, | 290 bool GrGpu::readPixels(GrRenderTarget* target, |
236 int left, int top, int width, int height, | 291 int left, int top, int width, int height, |
237 GrPixelConfig config, void* buffer, | 292 GrPixelConfig config, void* buffer, |
238 size_t rowBytes) { | 293 size_t rowBytes) { |
239 this->handleDirtyContext(); | 294 this->handleDirtyContext(); |
240 return this->onReadPixels(target, left, top, width, height, | 295 return this->onReadPixels(target, left, top, width, height, |
241 config, buffer, rowBytes); | 296 config, buffer, rowBytes); |
242 } | 297 } |
243 | 298 |
244 bool GrGpu::writeTexturePixels(GrTexture* texture, | 299 bool GrGpu::writeTexturePixels(GrTexture* texture, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 //////////////////////////////////////////////////////////////////////////////// | 359 //////////////////////////////////////////////////////////////////////////////// |
305 | 360 |
306 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { | 361 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { |
307 this->handleDirtyContext(); | 362 this->handleDirtyContext(); |
308 GrVertices::Iterator iter; | 363 GrVertices::Iterator iter; |
309 const GrNonInstancedVertices* verts = iter.init(vertices); | 364 const GrNonInstancedVertices* verts = iter.init(vertices); |
310 do { | 365 do { |
311 this->onDraw(args, *verts); | 366 this->onDraw(args, *verts); |
312 } while ((verts = iter.next())); | 367 } while ((verts = iter.next())); |
313 } | 368 } |
OLD | NEW |