gfx/skia/trunk/src/image/SkImage_Gpu.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.

     1 /*
     2  * Copyright 2012 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     8 #include "SkImage_Base.h"
     9 #include "SkImagePriv.h"
    10 #include "SkBitmap.h"
    11 #include "SkCanvas.h"
    12 #include "GrContext.h"
    13 #include "GrTexture.h"
    14 #include "SkGrPixelRef.h"
    16 class SkImage_Gpu : public SkImage_Base {
    17 public:
    18     SK_DECLARE_INST_COUNT(SkImage_Gpu)
    20     explicit SkImage_Gpu(const SkBitmap&);
    21     virtual ~SkImage_Gpu();
    23     virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) SK_OVERRIDE;
    24     virtual void onDrawRectToRect(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint*) SK_OVERRIDE;
    25     virtual GrTexture* onGetTexture() SK_OVERRIDE;
    26     virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE;
    28     GrTexture* getTexture() { return fBitmap.getTexture(); }
    30 private:
    31     SkBitmap    fBitmap;
    33     typedef SkImage_Base INHERITED;
    34 };
    36 ///////////////////////////////////////////////////////////////////////////////
    38 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap)
    39     : INHERITED(bitmap.width(), bitmap.height())
    40     , fBitmap(bitmap) {
    41     SkASSERT(NULL != fBitmap.getTexture());
    42 }
    44 SkImage_Gpu::~SkImage_Gpu() {
    45 }
    47 void SkImage_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y,
    48                          const SkPaint* paint) {
    49     canvas->drawBitmap(fBitmap, x, y, paint);
    50 }
    52 void SkImage_Gpu::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const SkRect& dst,
    53                          const SkPaint* paint) {
    54     canvas->drawBitmapRectToRect(fBitmap, src, dst, paint);
    55 }
    57 GrTexture* SkImage_Gpu::onGetTexture() {
    58     return fBitmap.getTexture();
    59 }
    61 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const {
    62     return fBitmap.copyTo(dst, kPMColor_SkColorType);
    63 }
    65 ///////////////////////////////////////////////////////////////////////////////
    67 SkImage* SkImage::NewTexture(const SkBitmap& bitmap) {
    68     if (NULL == bitmap.getTexture()) {
    69         return NULL;
    70     }
    72     return SkNEW_ARGS(SkImage_Gpu, (bitmap));
    73 }
    75 GrTexture* SkTextureImageGetTexture(SkImage* image) {
    76     return ((SkImage_Gpu*)image)->getTexture();
    77 }

mercurial