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

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

Issue 947443003: Move clip off of draw target (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 5 years, 10 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/SkGpuDevice.h ('k') | src/gpu/effects/GrDashingEffect.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 "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "GrBitmapTextContext.h" 10 #include "GrBitmapTextContext.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 269
270 const SkBitmap& SkGpuDevice::onAccessBitmap() { 270 const SkBitmap& SkGpuDevice::onAccessBitmap() {
271 DO_DEFERRED_CLEAR(); 271 DO_DEFERRED_CLEAR();
272 return fLegacyBitmap; 272 return fLegacyBitmap;
273 } 273 }
274 274
275 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) { 275 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) {
276 INHERITED::onAttachToCanvas(canvas); 276 INHERITED::onAttachToCanvas(canvas);
277 277
278 // Canvas promises that this ptr is valid until onDetachFromCanvas is called 278 // Canvas promises that this ptr is valid until onDetachFromCanvas is called
279 fClipData.fClipStack.reset(SkRef(canvas->getClipStack())); 279 fClipStack.reset(SkRef(canvas->getClipStack()));
280 } 280 }
281 281
282 void SkGpuDevice::onDetachFromCanvas() { 282 void SkGpuDevice::onDetachFromCanvas() {
283 INHERITED::onDetachFromCanvas(); 283 INHERITED::onDetachFromCanvas();
284 fClipData.fClipStack.reset(NULL); 284 fClipData.reset();
285 fClipStack.reset(NULL);
285 } 286 }
286 287
287 // call this every draw call, to ensure that the context reflects our state, 288 // call this every draw call, to ensure that the context reflects our state,
288 // and not the state from some other canvas/device 289 // and not the state from some other canvas/device
289 void SkGpuDevice::prepareDraw(const SkDraw& draw) { 290 void SkGpuDevice::prepareDraw(const SkDraw& draw) {
290 SkASSERT(fClipData.fClipStack); 291 SkASSERT(fClipStack.get());
291 292
292 SkASSERT(draw.fClipStack && draw.fClipStack == fClipData.fClipStack); 293 SkASSERT(draw.fClipStack && draw.fClipStack == fClipStack);
293 294
294 fClipData.fOrigin = this->getOrigin(); 295 fClipData.setClipStack(fClipStack, &this->getOrigin());
295 296
296 fContext->setClip(&fClipData); 297 fContext->setClip(&fClipData);
297 298
298 DO_DEFERRED_CLEAR(); 299 DO_DEFERRED_CLEAR();
299 } 300 }
300 301
301 GrRenderTarget* SkGpuDevice::accessRenderTarget() { 302 GrRenderTarget* SkGpuDevice::accessRenderTarget() {
302 DO_DEFERRED_CLEAR(); 303 DO_DEFERRED_CLEAR();
303 return fRenderTarget; 304 return fRenderTarget;
304 } 305 }
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 } 903 }
903 904
904 // Given a bitmap, an optional src rect, and a context with a clip and matrix de termine what 905 // Given a bitmap, an optional src rect, and a context with a clip and matrix de termine what
905 // pixels from the bitmap are necessary. 906 // pixels from the bitmap are necessary.
906 static void determine_clipped_src_rect(const GrContext* context, 907 static void determine_clipped_src_rect(const GrContext* context,
907 const GrRenderTarget* rt, 908 const GrRenderTarget* rt,
908 const SkMatrix& viewMatrix, 909 const SkMatrix& viewMatrix,
909 const SkBitmap& bitmap, 910 const SkBitmap& bitmap,
910 const SkRect* srcRectPtr, 911 const SkRect* srcRectPtr,
911 SkIRect* clippedSrcIRect) { 912 SkIRect* clippedSrcIRect) {
912 const GrClipData* clip = context->getClip(); 913 const GrClip* clip = context->getClip();
913 clip->getConservativeBounds(rt, clippedSrcIRect, NULL); 914 clip->getConservativeBounds(rt, clippedSrcIRect, NULL);
914 SkMatrix inv; 915 SkMatrix inv;
915 if (!viewMatrix.invert(&inv)) { 916 if (!viewMatrix.invert(&inv)) {
916 clippedSrcIRect->setEmpty(); 917 clippedSrcIRect->setEmpty();
917 return; 918 return;
918 } 919 }
919 SkRect clippedSrcRect = SkRect::Make(*clippedSrcIRect); 920 SkRect clippedSrcRect = SkRect::Make(*clippedSrcIRect);
920 inv.mapRect(&clippedSrcRect); 921 inv.mapRect(&clippedSrcRect);
921 if (srcRectPtr) { 922 if (srcRectPtr) {
922 // we've setup src space 0,0 to map to the top left of the src rect. 923 // we've setup src space 0,0 to map to the top left of the src rect.
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 #endif 1954 #endif
1954 } 1955 }
1955 1956
1956 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1957 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1957 // We always return a transient cache, so it is freed after each 1958 // We always return a transient cache, so it is freed after each
1958 // filter traversal. 1959 // filter traversal.
1959 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1960 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1960 } 1961 }
1961 1962
1962 #endif 1963 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/effects/GrDashingEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698