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

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

Issue 685883003: Clip in grdrawtarget (Closed) Base URL: https://skia.googlesource.com/skia.git@drawtarget_on_clip_manager
Patch Set: dm cleaned up 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
OLDNEW
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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 6, 259 6,
260 MAX_QUADS, 260 MAX_QUADS,
261 4); 261 4);
262 } 262 }
263 263
264 return fQuadIndexBuffer; 264 return fQuadIndexBuffer;
265 } 265 }
266 266
267 //////////////////////////////////////////////////////////////////////////////// 267 ////////////////////////////////////////////////////////////////////////////////
268 268
269 bool GrGpu::setupClipAndFlushState(DrawType type,
270 const GrDeviceCoordTexture* dstCopy,
271 const SkRect* devBounds,
272 GrDrawState::AutoRestoreEffects* are,
273 GrDrawState::AutoRestoreStencil* ars) {
274 GrClipMaskManager::ScissorState scissorState;
275 if (!fClipMaskManager.setupClipping(this->getClip(),
276 devBounds,
277 are,
278 ars,
279 &scissorState)) {
280 return false;
281 }
282
283 if (!this->flushGraphicsState(type, scissorState, dstCopy)) {
284 return false;
285 }
286
287 return true;
288 }
289
290 ////////////////////////////////////////////////////////////////////////////////
291
292 void GrGpu::geometrySourceWillPush() { 269 void GrGpu::geometrySourceWillPush() {
293 const GeometrySrcState& geoSrc = this->getGeomSrc(); 270 const GeometrySrcState& geoSrc = this->getGeomSrc();
294 if (kArray_GeometrySrcType == geoSrc.fVertexSrc || 271 if (kArray_GeometrySrcType == geoSrc.fVertexSrc ||
295 kReserved_GeometrySrcType == geoSrc.fVertexSrc) { 272 kReserved_GeometrySrcType == geoSrc.fVertexSrc) {
296 this->finalizeReservedVertices(); 273 this->finalizeReservedVertices();
297 } 274 }
298 if (kArray_GeometrySrcType == geoSrc.fIndexSrc || 275 if (kArray_GeometrySrcType == geoSrc.fIndexSrc ||
299 kReserved_GeometrySrcType == geoSrc.fIndexSrc) { 276 kReserved_GeometrySrcType == geoSrc.fIndexSrc) {
300 this->finalizeReservedIndices(); 277 this->finalizeReservedIndices();
301 } 278 }
302 GeometryPoolState& newState = fGeomPoolStateStack.push_back(); 279 GeometryPoolState& newState = fGeomPoolStateStack.push_back();
303 #ifdef SK_DEBUG 280 #ifdef SK_DEBUG
304 newState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; 281 newState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER;
305 newState.fPoolStartVertex = DEBUG_INVAL_START_IDX; 282 newState.fPoolStartVertex = DEBUG_INVAL_START_IDX;
306 newState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; 283 newState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER;
307 newState.fPoolStartIndex = DEBUG_INVAL_START_IDX; 284 newState.fPoolStartIndex = DEBUG_INVAL_START_IDX;
308 #else 285 #else
309 (void) newState; // silence compiler warning 286 (void) newState; // silence compiler warning
310 #endif 287 #endif
311 } 288 }
312 289
313 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) { 290 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) {
314 // if popping last entry then pops are unbalanced with pushes 291 // if popping last entry then pops are unbalanced with pushes
315 SkASSERT(fGeomPoolStateStack.count() > 1); 292 SkASSERT(fGeomPoolStateStack.count() > 1);
316 fGeomPoolStateStack.pop_back(); 293 fGeomPoolStateStack.pop_back();
317 } 294 }
318 295
319 void GrGpu::onDraw(const DrawInfo& info) { 296 void GrGpu::onDraw(const DrawInfo& info, const GrClipMaskManager::ScissorState& scissorState) {
320 this->handleDirtyContext(); 297 this->handleDirtyContext();
321 GrDrawState::AutoRestoreEffects are; 298 if (!this->flushGraphicsState(PrimTypeToDrawType(info.primitiveType()),
322 GrDrawState::AutoRestoreStencil ars; 299 scissorState,
323 if (!this->setupClipAndFlushState(PrimTypeToDrawType(info.primitiveType()), 300 info.getDstCopy())) {
324 info.getDstCopy(),
325 info.getDevBounds(),
326 &are,
327 &ars)) {
328 return; 301 return;
329 } 302 }
330 this->onGpuDraw(info); 303 this->onGpuDraw(info);
331 } 304 }
332 305
333 306 void GrGpu::onStencilPath(const GrPath* path,
334 // TODO hack 307 const GrClipMaskManager::ScissorState& scissorState,
335 static const GrStencilSettings& winding_path_stencil_settings() { 308 const GrStencilSettings& stencilSettings) {
336 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
337 kIncClamp_StencilOp,
338 kIncClamp_StencilOp,
339 kAlwaysIfInClip_StencilFunc,
340 0xFFFF, 0xFFFF, 0xFFFF);
341 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
342 }
343
344 static const GrStencilSettings& even_odd_path_stencil_settings() {
345 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
346 kInvert_StencilOp,
347 kInvert_StencilOp,
348 kAlwaysIfInClip_StencilFunc,
349 0xFFFF, 0xFFFF, 0xFFFF);
350 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
351 }
352
353 static void get_path_stencil_settings_for_filltype(GrPathRendering::FillType fil l,
354 GrStencilSettings* outStencil Settings) {
355
356 switch (fill) {
357 default:
358 SkFAIL("Unexpected path fill.");
359 case GrPathRendering::kWinding_FillType:
360 *outStencilSettings = winding_path_stencil_settings();
361 break;
362 case GrPathRendering::kEvenOdd_FillType:
363 *outStencilSettings = even_odd_path_stencil_settings();
364 break;
365 }
366 }
367
368 void GrGpu::onStencilPath(const GrPath* path, GrPathRendering::FillType fill) {
369 this->handleDirtyContext(); 309 this->handleDirtyContext();
370 310
371 GrDrawState::AutoRestoreEffects are; 311 if (!this->flushGraphicsState(kStencilPath_DrawType, scissorState, NULL)) {
372 GrDrawState::AutoRestoreStencil ars;
373 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, NULL, &are, & ars)) {
374 return; 312 return;
375 } 313 }
376 314
377 GrStencilSettings stencilSettings;
378 get_path_stencil_settings_for_filltype(fill, &stencilSettings);
379 fClipMaskManager.adjustPathStencilParams(&stencilSettings);
380
381 this->pathRendering()->stencilPath(path, stencilSettings); 315 this->pathRendering()->stencilPath(path, stencilSettings);
382 } 316 }
383 317
384 318
385 void GrGpu::onDrawPath(const GrPath* path, GrPathRendering::FillType fill, 319 void GrGpu::onDrawPath(const GrPath* path,
320 const GrClipMaskManager::ScissorState& scissorState,
321 const GrStencilSettings& stencilSettings,
386 const GrDeviceCoordTexture* dstCopy) { 322 const GrDeviceCoordTexture* dstCopy) {
387 this->handleDirtyContext(); 323 this->handleDirtyContext();
388 324
389 drawState()->setDefaultVertexAttribs(); 325 drawState()->setDefaultVertexAttribs();
390 326
391 GrDrawState::AutoRestoreEffects are; 327 if (!this->flushGraphicsState(kDrawPath_DrawType, scissorState, dstCopy)) {
392 GrDrawState::AutoRestoreStencil ars;
393 if (!this->setupClipAndFlushState(kDrawPath_DrawType, dstCopy, NULL, &are, & ars)) {
394 return; 328 return;
395 } 329 }
396 330
397 GrStencilSettings stencilSettings;
398 get_path_stencil_settings_for_filltype(fill, &stencilSettings);
399 fClipMaskManager.adjustPathStencilParams(&stencilSettings);
400
401 this->pathRendering()->drawPath(path, stencilSettings); 331 this->pathRendering()->drawPath(path, stencilSettings);
402 } 332 }
403 333
404 void GrGpu::onDrawPaths(const GrPathRange* pathRange, 334 void GrGpu::onDrawPaths(const GrPathRange* pathRange,
405 const uint32_t indices[], int count, 335 const uint32_t indices[],
406 const float transforms[], PathTransformType transformsTy pe, 336 int count,
407 GrPathRendering::FillType fill, const GrDeviceCoordTextu re* dstCopy) { 337 const float transforms[],
338 PathTransformType transformsType,
339 const GrClipMaskManager::ScissorState& scissorState,
340 const GrStencilSettings& stencilSettings,
341 const GrDeviceCoordTexture* dstCopy) {
408 this->handleDirtyContext(); 342 this->handleDirtyContext();
409 343
410 drawState()->setDefaultVertexAttribs(); 344 drawState()->setDefaultVertexAttribs();
411 345
412 GrDrawState::AutoRestoreEffects are; 346 if (!this->flushGraphicsState(kDrawPaths_DrawType, scissorState, dstCopy)) {
413 GrDrawState::AutoRestoreStencil ars;
414 if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, NULL, &are, &ars)) {
415 return; 347 return;
416 } 348 }
417 349
418 GrStencilSettings stencilSettings;
419 get_path_stencil_settings_for_filltype(fill, &stencilSettings);
420 fClipMaskManager.adjustPathStencilParams(&stencilSettings);
421
422 pathRange->willDrawPaths(indices, count); 350 pathRange->willDrawPaths(indices, count);
423 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran sformsType, 351 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran sformsType,
424 stencilSettings); 352 stencilSettings);
425 } 353 }
426 354
427 void GrGpu::finalizeReservedVertices() { 355 void GrGpu::finalizeReservedVertices() {
428 SkASSERT(fVertexPool); 356 SkASSERT(fVertexPool);
429 fVertexPool->unmap(); 357 fVertexPool->unmap();
430 } 358 }
431 359
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 } 482 }
555 483
556 void GrGpu::releaseIndexArray() { 484 void GrGpu::releaseIndexArray() {
557 // if index source was array, we stowed data in the pool 485 // if index source was array, we stowed data in the pool
558 const GeometrySrcState& geoSrc = this->getGeomSrc(); 486 const GeometrySrcState& geoSrc = this->getGeomSrc();
559 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); 487 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc);
560 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); 488 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t);
561 fIndexPool->putBack(bytes); 489 fIndexPool->putBack(bytes);
562 --fIndexPoolUseCnt; 490 --fIndexPoolUseCnt;
563 } 491 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698