gfx/skia/trunk/src/gpu/GrRenderTarget.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     2 /*
     3  * Copyright 2011 Google Inc.
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
    10 #include "GrRenderTarget.h"
    12 #include "GrContext.h"
    13 #include "GrGpu.h"
    14 #include "GrStencilBuffer.h"
    16 bool GrRenderTarget::readPixels(int left, int top, int width, int height,
    17                                 GrPixelConfig config,
    18                                 void* buffer,
    19                                 size_t rowBytes,
    20                                 uint32_t pixelOpsFlags) {
    21     // go through context so that all necessary flushing occurs
    22     GrContext* context = this->getContext();
    23     if (NULL == context) {
    24         return false;
    25     }
    26     return context->readRenderTargetPixels(this,
    27                                            left, top, width, height,
    28                                            config, buffer, rowBytes,
    29                                            pixelOpsFlags);
    30 }
    32 void GrRenderTarget::writePixels(int left, int top, int width, int height,
    33                                  GrPixelConfig config,
    34                                  const void* buffer,
    35                                  size_t rowBytes,
    36                                  uint32_t pixelOpsFlags) {
    37     // go through context so that all necessary flushing occurs
    38     GrContext* context = this->getContext();
    39     if (NULL == context) {
    40         return;
    41     }
    42     context->writeRenderTargetPixels(this,
    43                                      left, top, width, height,
    44                                      config, buffer, rowBytes,
    45                                      pixelOpsFlags);
    46 }
    48 void GrRenderTarget::resolve() {
    49     // go through context so that all necessary flushing occurs
    50     GrContext* context = this->getContext();
    51     if (NULL == context) {
    52         return;
    53     }
    54     context->resolveRenderTarget(this);
    55 }
    57 size_t GrRenderTarget::sizeInBytes() const {
    58     size_t colorBits;
    59     if (kUnknown_GrPixelConfig == fDesc.fConfig) {
    60         colorBits = 32; // don't know, make a guess
    61     } else {
    62         colorBits = GrBytesPerPixel(fDesc.fConfig);
    63     }
    64     uint64_t size = fDesc.fWidth;
    65     size *= fDesc.fHeight;
    66     size *= colorBits;
    67     size *= GrMax(1, fDesc.fSampleCnt);
    68     return (size_t)(size / 8);
    69 }
    71 void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) {
    72     if (kCanResolve_ResolveType == getResolveType()) {
    73         if (NULL != rect) {
    74             fResolveRect.join(*rect);
    75             if (!fResolveRect.intersect(0, 0, this->width(), this->height())) {
    76                 fResolveRect.setEmpty();
    77             }
    78         } else {
    79             fResolveRect.setLTRB(0, 0, this->width(), this->height());
    80         }
    81     }
    82 }
    84 void GrRenderTarget::overrideResolveRect(const SkIRect rect) {
    85     fResolveRect = rect;
    86     if (fResolveRect.isEmpty()) {
    87         fResolveRect.setLargestInverted();
    88     } else {
    89         if (!fResolveRect.intersect(0, 0, this->width(), this->height())) {
    90             fResolveRect.setLargestInverted();
    91         }
    92     }
    93 }
    95 void GrRenderTarget::setStencilBuffer(GrStencilBuffer* stencilBuffer) {
    96     SkRefCnt_SafeAssign(fStencilBuffer, stencilBuffer);
    97 }
    99 void GrRenderTarget::onRelease() {
   100     this->setStencilBuffer(NULL);
   102     INHERITED::onRelease();
   103 }
   105 void GrRenderTarget::onAbandon() {
   106     this->setStencilBuffer(NULL);
   108     INHERITED::onAbandon();
   109 }

mercurial